mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
requesthandler: Implement input, scene, and transition UUID support
Transition UUID support is partial due to the current state of the OBS frontend API. Most requests which accepted things like `sourceName` now allow `sourceUuid` (or equivalent) to be specified instead. While both fields on the various requests may be marked as optional, at least one field will still be required.
This commit is contained in:
parent
f18f46543b
commit
7adfb5874c
@ -43,7 +43,8 @@ RequestResult RequestHandler::GetSourceFilterKindList(const Request &)
|
|||||||
/**
|
/**
|
||||||
* Gets an array of all of a source's filters.
|
* Gets an array of all of a source's filters.
|
||||||
*
|
*
|
||||||
* @requestField sourceName | String | Name of the source
|
* @requestField ?sourceName | String | Name of the source
|
||||||
|
* @requestField ?sourceUuid | String | UUID of the source
|
||||||
*
|
*
|
||||||
* @responseField filters | Array<Object> | Array of filters
|
* @responseField filters | Array<Object> | Array of filters
|
||||||
*
|
*
|
||||||
@ -58,7 +59,7 @@ RequestResult RequestHandler::GetSourceFilterList(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSourceAutoRelease source = request.ValidateSource("sourceName", statusCode, comment);
|
OBSSourceAutoRelease source = request.ValidateSource("sourceName", "sourceUuid", statusCode, comment);
|
||||||
if (!source)
|
if (!source)
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -106,7 +107,8 @@ RequestResult RequestHandler::GetSourceFilterDefaultSettings(const Request &requ
|
|||||||
/**
|
/**
|
||||||
* Creates a new filter, adding it to the specified source.
|
* Creates a new filter, adding it to the specified source.
|
||||||
*
|
*
|
||||||
* @requestField sourceName | String | Name of the source to add the filter to
|
* @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
|
* @requestField filterName | String | Name of the new filter to be created
|
||||||
* @requestField filterKind | String | The kind of filter to be created
|
* @requestField filterKind | String | The kind of filter to be created
|
||||||
* @requestField ?filterSettings | Object | Settings object to initialize the filter with | Default settings used
|
* @requestField ?filterSettings | Object | Settings object to initialize the filter with | Default settings used
|
||||||
@ -123,7 +125,7 @@ RequestResult RequestHandler::CreateSourceFilter(const Request &request)
|
|||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
|
|
||||||
OBSSourceAutoRelease source = request.ValidateSource("sourceName", statusCode, comment);
|
OBSSourceAutoRelease source = request.ValidateSource("sourceName", "sourceUuid", statusCode, comment);
|
||||||
if (!(source && request.ValidateString("filterName", statusCode, comment) &&
|
if (!(source && request.ValidateString("filterName", statusCode, comment) &&
|
||||||
request.ValidateString("filterKind", statusCode, comment)))
|
request.ValidateString("filterKind", statusCode, comment)))
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
@ -159,7 +161,8 @@ RequestResult RequestHandler::CreateSourceFilter(const Request &request)
|
|||||||
/**
|
/**
|
||||||
* Removes a filter from a source.
|
* Removes a filter from a source.
|
||||||
*
|
*
|
||||||
* @requestField sourceName | String | Name of the source the filter is on
|
* @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
|
* @requestField filterName | String | Name of the filter to remove
|
||||||
*
|
*
|
||||||
* @requestType RemoveSourceFilter
|
* @requestType RemoveSourceFilter
|
||||||
@ -173,7 +176,7 @@ RequestResult RequestHandler::RemoveSourceFilter(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
FilterPair pair = request.ValidateFilter("sourceName", "filterName", statusCode, comment);
|
FilterPair pair = request.ValidateFilter(statusCode, comment);
|
||||||
if (!pair.filter)
|
if (!pair.filter)
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -185,7 +188,8 @@ RequestResult RequestHandler::RemoveSourceFilter(const Request &request)
|
|||||||
/**
|
/**
|
||||||
* Sets the name of a source filter (rename).
|
* Sets the name of a source filter (rename).
|
||||||
*
|
*
|
||||||
* @requestField sourceName | String | Name of the source the filter is on
|
* @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
|
* @requestField filterName | String | Current name of the filter
|
||||||
* @requestField newFilterName | String | New name for the filter
|
* @requestField newFilterName | String | New name for the filter
|
||||||
*
|
*
|
||||||
@ -200,7 +204,7 @@ RequestResult RequestHandler::SetSourceFilterName(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
FilterPair pair = request.ValidateFilter("sourceName", "filterName", statusCode, comment);
|
FilterPair pair = request.ValidateFilter(statusCode, comment);
|
||||||
if (!pair.filter || !request.ValidateString("newFilterName", statusCode, comment))
|
if (!pair.filter || !request.ValidateString("newFilterName", statusCode, comment))
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -218,7 +222,8 @@ RequestResult RequestHandler::SetSourceFilterName(const Request &request)
|
|||||||
/**
|
/**
|
||||||
* Gets the info for a specific source filter.
|
* Gets the info for a specific source filter.
|
||||||
*
|
*
|
||||||
* @requestField sourceName | String | Name of the source
|
* @requestField ?sourceName | String | Name of the source
|
||||||
|
* @requestField ?sourceUuid | String | UUID of the source
|
||||||
* @requestField filterName | String | Name of the filter
|
* @requestField filterName | String | Name of the filter
|
||||||
*
|
*
|
||||||
* @responseField filterEnabled | Boolean | Whether the filter is enabled
|
* @responseField filterEnabled | Boolean | Whether the filter is enabled
|
||||||
@ -237,7 +242,7 @@ RequestResult RequestHandler::GetSourceFilter(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
FilterPair pair = request.ValidateFilter("sourceName", "filterName", statusCode, comment);
|
FilterPair pair = request.ValidateFilter(statusCode, comment);
|
||||||
if (!pair.filter)
|
if (!pair.filter)
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -257,7 +262,8 @@ RequestResult RequestHandler::GetSourceFilter(const Request &request)
|
|||||||
/**
|
/**
|
||||||
* Sets the index position of a filter on a source.
|
* Sets the index position of a filter on a source.
|
||||||
*
|
*
|
||||||
* @requestField sourceName | String | Name of the source the filter is on
|
* @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
|
* @requestField filterName | String | Name of the filter
|
||||||
* @requestField filterIndex | Number | New index position of the filter | >= 0
|
* @requestField filterIndex | Number | New index position of the filter | >= 0
|
||||||
*
|
*
|
||||||
@ -272,7 +278,7 @@ RequestResult RequestHandler::SetSourceFilterIndex(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
FilterPair pair = request.ValidateFilter("sourceName", "filterName", statusCode, comment);
|
FilterPair pair = request.ValidateFilter(statusCode, comment);
|
||||||
if (!(pair.filter && request.ValidateNumber("filterIndex", statusCode, comment, 0, 8192)))
|
if (!(pair.filter && request.ValidateNumber("filterIndex", statusCode, comment, 0, 8192)))
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -286,7 +292,8 @@ RequestResult RequestHandler::SetSourceFilterIndex(const Request &request)
|
|||||||
/**
|
/**
|
||||||
* Sets the settings of a source filter.
|
* Sets the settings of a source filter.
|
||||||
*
|
*
|
||||||
* @requestField sourceName | String | Name of the source the filter is on
|
* @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
|
* @requestField filterName | String | Name of the filter to set the settings of
|
||||||
* @requestField filterSettings | Object | Object of settings to apply
|
* @requestField filterSettings | Object | Object of settings to apply
|
||||||
* @requestField ?overlay | Boolean | True == apply the settings on top of existing ones, False == reset the input to its defaults, then apply settings. | true
|
* @requestField ?overlay | Boolean | True == apply the settings on top of existing ones, False == reset the input to its defaults, then apply settings. | true
|
||||||
@ -302,7 +309,7 @@ RequestResult RequestHandler::SetSourceFilterSettings(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
FilterPair pair = request.ValidateFilter("sourceName", "filterName", statusCode, comment);
|
FilterPair pair = request.ValidateFilter(statusCode, comment);
|
||||||
if (!(pair.filter && request.ValidateObject("filterSettings", statusCode, comment, true)))
|
if (!(pair.filter && request.ValidateObject("filterSettings", statusCode, comment, true)))
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -334,7 +341,8 @@ RequestResult RequestHandler::SetSourceFilterSettings(const Request &request)
|
|||||||
/**
|
/**
|
||||||
* Sets the enable state of a source filter.
|
* Sets the enable state of a source filter.
|
||||||
*
|
*
|
||||||
* @requestField sourceName | String | Name of the source the filter is on
|
* @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
|
* @requestField filterName | String | Name of the filter
|
||||||
* @requestField filterEnabled | Boolean | New enable state of the filter
|
* @requestField filterEnabled | Boolean | New enable state of the filter
|
||||||
*
|
*
|
||||||
@ -349,7 +357,7 @@ RequestResult RequestHandler::SetSourceFilterEnabled(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
FilterPair pair = request.ValidateFilter("sourceName", "filterName", statusCode, comment);
|
FilterPair pair = request.ValidateFilter(statusCode, comment);
|
||||||
if (!(pair.filter && request.ValidateBoolean("filterEnabled", statusCode, comment)))
|
if (!(pair.filter && request.ValidateBoolean("filterEnabled", statusCode, comment)))
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
|
@ -123,12 +123,14 @@ RequestResult RequestHandler::GetSpecialInputs(const Request &)
|
|||||||
/**
|
/**
|
||||||
* Creates a new input, adding it as a scene item to the specified scene.
|
* Creates a new input, adding it as a scene item to the specified scene.
|
||||||
*
|
*
|
||||||
* @requestField sceneName | String | Name of the scene to add the input to as a scene item
|
* @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
|
* @requestField inputName | String | Name of the new input to created
|
||||||
* @requestField inputKind | String | The kind of input to be created
|
* @requestField inputKind | String | The kind of input to be created
|
||||||
* @requestField ?inputSettings | Object | Settings object to initialize the input with | Default settings used
|
* @requestField ?inputSettings | Object | Settings object to initialize the input with | Default settings used
|
||||||
* @requestField ?sceneItemEnabled | Boolean | Whether to set the created scene item to enabled or disabled | True
|
* @requestField ?sceneItemEnabled | Boolean | Whether to set the created scene item to enabled or disabled | True
|
||||||
*
|
*
|
||||||
|
* @responseField inputUuid | String | UUID of the newly created input
|
||||||
* @responseField sceneItemId | Number | ID of the newly created scene item
|
* @responseField sceneItemId | Number | ID of the newly created scene item
|
||||||
*
|
*
|
||||||
* @requestType CreateInput
|
* @requestType CreateInput
|
||||||
@ -142,7 +144,7 @@ RequestResult RequestHandler::CreateInput(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSourceAutoRelease sceneSource = request.ValidateScene("sceneName", statusCode, comment);
|
OBSSourceAutoRelease sceneSource = request.ValidateScene(statusCode, comment);
|
||||||
if (!(sceneSource && request.ValidateString("inputName", statusCode, comment) &&
|
if (!(sceneSource && request.ValidateString("inputName", statusCode, comment) &&
|
||||||
request.ValidateString("inputKind", statusCode, comment)))
|
request.ValidateString("inputKind", statusCode, comment)))
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
@ -185,6 +187,7 @@ RequestResult RequestHandler::CreateInput(const Request &request)
|
|||||||
return RequestResult::Error(RequestStatus::ResourceCreationFailed, "Creation of the input or scene item failed.");
|
return RequestResult::Error(RequestStatus::ResourceCreationFailed, "Creation of the input or scene item failed.");
|
||||||
|
|
||||||
json responseData;
|
json responseData;
|
||||||
|
responseData["inputUuid"] = obs_source_get_uuid(obs_sceneitem_get_source(sceneItem));
|
||||||
responseData["sceneItemId"] = obs_sceneitem_get_id(sceneItem);
|
responseData["sceneItemId"] = obs_sceneitem_get_id(sceneItem);
|
||||||
return RequestResult::Success(responseData);
|
return RequestResult::Success(responseData);
|
||||||
}
|
}
|
||||||
@ -194,7 +197,8 @@ RequestResult RequestHandler::CreateInput(const Request &request)
|
|||||||
*
|
*
|
||||||
* Note: Will immediately remove all associated scene items.
|
* Note: Will immediately remove all associated scene items.
|
||||||
*
|
*
|
||||||
* @requestField inputName | String | Name of the input to remove
|
* @requestField ?inputName | String | Name of the input to remove
|
||||||
|
* @requestField ?inputUuid | String | UUID of the input to remove
|
||||||
*
|
*
|
||||||
* @requestType RemoveInput
|
* @requestType RemoveInput
|
||||||
* @complexity 2
|
* @complexity 2
|
||||||
@ -207,7 +211,7 @@ RequestResult RequestHandler::RemoveInput(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSourceAutoRelease input = request.ValidateInput("inputName", statusCode, comment);
|
OBSSourceAutoRelease input = request.ValidateInput(statusCode, comment);
|
||||||
if (!input)
|
if (!input)
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -222,7 +226,8 @@ RequestResult RequestHandler::RemoveInput(const Request &request)
|
|||||||
/**
|
/**
|
||||||
* Sets the name of an input (rename).
|
* Sets the name of an input (rename).
|
||||||
*
|
*
|
||||||
* @requestField inputName | String | Current input name
|
* @requestField ?inputName | String | Current input name
|
||||||
|
* @requestField ?inputUuid | String | Current input UUID
|
||||||
* @requestField newInputName | String | New name for the input
|
* @requestField newInputName | String | New name for the input
|
||||||
*
|
*
|
||||||
* @requestType SetInputName
|
* @requestType SetInputName
|
||||||
@ -236,7 +241,7 @@ RequestResult RequestHandler::SetInputName(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSourceAutoRelease input = request.ValidateInput("inputName", statusCode, comment);
|
OBSSourceAutoRelease input = request.ValidateInput(statusCode, comment);
|
||||||
if (!(input && request.ValidateString("newInputName", statusCode, comment)))
|
if (!(input && request.ValidateString("newInputName", statusCode, comment)))
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -292,7 +297,8 @@ RequestResult RequestHandler::GetInputDefaultSettings(const Request &request)
|
|||||||
*
|
*
|
||||||
* Note: Does not include defaults. To create the entire settings object, overlay `inputSettings` over the `defaultInputSettings` provided by `GetInputDefaultSettings`.
|
* Note: Does not include defaults. To create the entire settings object, overlay `inputSettings` over the `defaultInputSettings` provided by `GetInputDefaultSettings`.
|
||||||
*
|
*
|
||||||
* @requestField inputName | String | Name of the input to get the settings of
|
* @requestField ?inputName | String | Name of the input to get the settings of
|
||||||
|
* @requestField ?inputUuid | String | UUID of the input to get the settings of
|
||||||
*
|
*
|
||||||
* @responseField inputSettings | Object | Object of settings for the input
|
* @responseField inputSettings | Object | Object of settings for the input
|
||||||
* @responseField inputKind | String | The kind of the input
|
* @responseField inputKind | String | The kind of the input
|
||||||
@ -308,7 +314,7 @@ RequestResult RequestHandler::GetInputSettings(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSourceAutoRelease input = request.ValidateInput("inputName", statusCode, comment);
|
OBSSourceAutoRelease input = request.ValidateInput(statusCode, comment);
|
||||||
if (!input)
|
if (!input)
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -323,7 +329,8 @@ RequestResult RequestHandler::GetInputSettings(const Request &request)
|
|||||||
/**
|
/**
|
||||||
* Sets the settings of an input.
|
* Sets the settings of an input.
|
||||||
*
|
*
|
||||||
* @requestField inputName | String | Name of the input to set the settings of
|
* @requestField ?inputName | String | Name of the input to set the settings of
|
||||||
|
* @requestField ?inputUuid | String | UUID of the input to set the settings of
|
||||||
* @requestField inputSettings | Object | Object of settings to apply
|
* @requestField inputSettings | Object | Object of settings to apply
|
||||||
* @requestField ?overlay | Boolean | True == apply the settings on top of existing ones, False == reset the input to its defaults, then apply settings. | true
|
* @requestField ?overlay | Boolean | True == apply the settings on top of existing ones, False == reset the input to its defaults, then apply settings. | true
|
||||||
*
|
*
|
||||||
@ -338,7 +345,7 @@ RequestResult RequestHandler::SetInputSettings(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSourceAutoRelease input = request.ValidateInput("inputName", statusCode, comment);
|
OBSSourceAutoRelease input = request.ValidateInput(statusCode, comment);
|
||||||
if (!(input && request.ValidateObject("inputSettings", statusCode, comment, true)))
|
if (!(input && request.ValidateObject("inputSettings", statusCode, comment, true)))
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -373,7 +380,8 @@ RequestResult RequestHandler::SetInputSettings(const Request &request)
|
|||||||
/**
|
/**
|
||||||
* Gets the audio mute state of an input.
|
* Gets the audio mute state of an input.
|
||||||
*
|
*
|
||||||
* @requestField inputName | String | Name of input to get the mute state of
|
* @requestField ?inputName | String | Name of input to get the mute state of
|
||||||
|
* @requestField ?inputUuid | String | UUID of input to get the mute state of
|
||||||
*
|
*
|
||||||
* @responseField inputMuted | Boolean | Whether the input is muted
|
* @responseField inputMuted | Boolean | Whether the input is muted
|
||||||
*
|
*
|
||||||
@ -388,7 +396,7 @@ RequestResult RequestHandler::GetInputMute(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSourceAutoRelease input = request.ValidateInput("inputName", statusCode, comment);
|
OBSSourceAutoRelease input = request.ValidateInput(statusCode, comment);
|
||||||
if (!input)
|
if (!input)
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -403,7 +411,8 @@ RequestResult RequestHandler::GetInputMute(const Request &request)
|
|||||||
/**
|
/**
|
||||||
* Sets the audio mute state of an input.
|
* Sets the audio mute state of an input.
|
||||||
*
|
*
|
||||||
* @requestField inputName | String | Name of the input to set the mute state of
|
* @requestField ?inputName | String | Name of the input to set the mute state of
|
||||||
|
* @requestField ?inputUuid | String | UUID of the input to set the mute state of
|
||||||
* @requestField inputMuted | Boolean | Whether to mute the input or not
|
* @requestField inputMuted | Boolean | Whether to mute the input or not
|
||||||
*
|
*
|
||||||
* @requestType SetInputMute
|
* @requestType SetInputMute
|
||||||
@ -417,7 +426,7 @@ RequestResult RequestHandler::SetInputMute(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSourceAutoRelease input = request.ValidateInput("inputName", statusCode, comment);
|
OBSSourceAutoRelease input = request.ValidateInput(statusCode, comment);
|
||||||
if (!(input && request.ValidateBoolean("inputMuted", statusCode, comment)))
|
if (!(input && request.ValidateBoolean("inputMuted", statusCode, comment)))
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -432,7 +441,8 @@ RequestResult RequestHandler::SetInputMute(const Request &request)
|
|||||||
/**
|
/**
|
||||||
* Toggles the audio mute state of an input.
|
* Toggles the audio mute state of an input.
|
||||||
*
|
*
|
||||||
* @requestField inputName | String | Name of the input to toggle the mute state of
|
* @requestField ?inputName | String | Name of the input to toggle the mute state of
|
||||||
|
* @requestField ?inputUuid | String | UUID of the input to toggle the mute state of
|
||||||
*
|
*
|
||||||
* @responseField inputMuted | Boolean | Whether the input has been muted or unmuted
|
* @responseField inputMuted | Boolean | Whether the input has been muted or unmuted
|
||||||
*
|
*
|
||||||
@ -447,7 +457,7 @@ RequestResult RequestHandler::ToggleInputMute(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSourceAutoRelease input = request.ValidateInput("inputName", statusCode, comment);
|
OBSSourceAutoRelease input = request.ValidateInput(statusCode, comment);
|
||||||
if (!input)
|
if (!input)
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -465,7 +475,8 @@ RequestResult RequestHandler::ToggleInputMute(const Request &request)
|
|||||||
/**
|
/**
|
||||||
* Gets the current volume setting of an input.
|
* Gets the current volume setting of an input.
|
||||||
*
|
*
|
||||||
* @requestField inputName | String | Name of the input to get the volume of
|
* @requestField ?inputName | String | Name of the input to get the volume of
|
||||||
|
* @requestField ?inputUuid | String | UUID of the input to get the volume of
|
||||||
*
|
*
|
||||||
* @responseField inputVolumeMul | Number | Volume setting in mul
|
* @responseField inputVolumeMul | Number | Volume setting in mul
|
||||||
* @responseField inputVolumeDb | Number | Volume setting in dB
|
* @responseField inputVolumeDb | Number | Volume setting in dB
|
||||||
@ -481,7 +492,7 @@ RequestResult RequestHandler::GetInputVolume(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSourceAutoRelease input = request.ValidateInput("inputName", statusCode, comment);
|
OBSSourceAutoRelease input = request.ValidateInput(statusCode, comment);
|
||||||
if (!input)
|
if (!input)
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -502,7 +513,8 @@ RequestResult RequestHandler::GetInputVolume(const Request &request)
|
|||||||
/**
|
/**
|
||||||
* Sets the volume setting of an input.
|
* Sets the volume setting of an input.
|
||||||
*
|
*
|
||||||
* @requestField inputName | String | Name of the input to set the volume of
|
* @requestField ?inputName | String | Name of the input to set the volume of
|
||||||
|
* @requestField ?inputUuid | String | UUID of the input to set the volume of
|
||||||
* @requestField ?inputVolumeMul | Number | Volume setting in mul | >= 0, <= 20 | `inputVolumeDb` should be specified
|
* @requestField ?inputVolumeMul | Number | Volume setting in mul | >= 0, <= 20 | `inputVolumeDb` should be specified
|
||||||
* @requestField ?inputVolumeDb | Number | Volume setting in dB | >= -100, <= 26 | `inputVolumeMul` should be specified
|
* @requestField ?inputVolumeDb | Number | Volume setting in dB | >= -100, <= 26 | `inputVolumeMul` should be specified
|
||||||
*
|
*
|
||||||
@ -517,7 +529,7 @@ RequestResult RequestHandler::SetInputVolume(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSourceAutoRelease input = request.ValidateInput("inputName", statusCode, comment);
|
OBSSourceAutoRelease input = request.ValidateInput(statusCode, comment);
|
||||||
if (!input)
|
if (!input)
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -552,7 +564,8 @@ RequestResult RequestHandler::SetInputVolume(const Request &request)
|
|||||||
/**
|
/**
|
||||||
* Gets the audio balance of an input.
|
* Gets the audio balance of an input.
|
||||||
*
|
*
|
||||||
* @requestField inputName | String | Name of the input to get the audio balance of
|
* @requestField ?inputName | String | Name of the input to get the audio balance of
|
||||||
|
* @requestField ?inputUuid | String | UUID of the input to get the audio balance of
|
||||||
*
|
*
|
||||||
* @responseField inputAudioBalance | Number | Audio balance value from 0.0-1.0
|
* @responseField inputAudioBalance | Number | Audio balance value from 0.0-1.0
|
||||||
*
|
*
|
||||||
@ -567,7 +580,7 @@ RequestResult RequestHandler::GetInputAudioBalance(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSourceAutoRelease input = request.ValidateInput("inputName", statusCode, comment);
|
OBSSourceAutoRelease input = request.ValidateInput(statusCode, comment);
|
||||||
if (!input)
|
if (!input)
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -583,7 +596,8 @@ RequestResult RequestHandler::GetInputAudioBalance(const Request &request)
|
|||||||
/**
|
/**
|
||||||
* Sets the audio balance of an input.
|
* Sets the audio balance of an input.
|
||||||
*
|
*
|
||||||
* @requestField inputName | String | Name of the input to set the audio balance of
|
* @requestField ?inputName | String | Name of the input to set the audio balance of
|
||||||
|
* @requestField ?inputUuid | String | UUID of the input to set the audio balance of
|
||||||
* @requestField inputAudioBalance | Number | New audio balance value | >= 0.0, <= 1.0
|
* @requestField inputAudioBalance | Number | New audio balance value | >= 0.0, <= 1.0
|
||||||
*
|
*
|
||||||
* @requestType SetInputAudioBalance
|
* @requestType SetInputAudioBalance
|
||||||
@ -597,7 +611,7 @@ RequestResult RequestHandler::SetInputAudioBalance(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSourceAutoRelease input = request.ValidateInput("inputName", statusCode, comment);
|
OBSSourceAutoRelease input = request.ValidateInput(statusCode, comment);
|
||||||
if (!(input && request.ValidateNumber("inputAudioBalance", statusCode, comment, 0.0, 1.0)))
|
if (!(input && request.ValidateNumber("inputAudioBalance", statusCode, comment, 0.0, 1.0)))
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -615,7 +629,8 @@ RequestResult RequestHandler::SetInputAudioBalance(const Request &request)
|
|||||||
*
|
*
|
||||||
* Note: The audio sync offset can be negative too!
|
* Note: The audio sync offset can be negative too!
|
||||||
*
|
*
|
||||||
* @requestField inputName | String | Name of the input to get the audio sync offset of
|
* @requestField ?inputName | String | Name of the input to get the audio sync offset of
|
||||||
|
* @requestField ?inputUuid | String | UUID of the input to get the audio sync offset of
|
||||||
*
|
*
|
||||||
* @responseField inputAudioSyncOffset | Number | Audio sync offset in milliseconds
|
* @responseField inputAudioSyncOffset | Number | Audio sync offset in milliseconds
|
||||||
*
|
*
|
||||||
@ -630,7 +645,7 @@ RequestResult RequestHandler::GetInputAudioSyncOffset(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSourceAutoRelease input = request.ValidateInput("inputName", statusCode, comment);
|
OBSSourceAutoRelease input = request.ValidateInput(statusCode, comment);
|
||||||
if (!input)
|
if (!input)
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -647,7 +662,8 @@ RequestResult RequestHandler::GetInputAudioSyncOffset(const Request &request)
|
|||||||
/**
|
/**
|
||||||
* Sets the audio sync offset of an input.
|
* Sets the audio sync offset of an input.
|
||||||
*
|
*
|
||||||
* @requestField inputName | String | Name of the input to set the audio sync offset of
|
* @requestField ?inputName | String | Name of the input to set the audio sync offset of
|
||||||
|
* @requestField ?inputUuid | String | UUID of the input to set the audio sync offset of
|
||||||
* @requestField inputAudioSyncOffset | Number | New audio sync offset in milliseconds | >= -950, <= 20000
|
* @requestField inputAudioSyncOffset | Number | New audio sync offset in milliseconds | >= -950, <= 20000
|
||||||
*
|
*
|
||||||
* @requestType SetInputAudioSyncOffset
|
* @requestType SetInputAudioSyncOffset
|
||||||
@ -661,7 +677,7 @@ RequestResult RequestHandler::SetInputAudioSyncOffset(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSourceAutoRelease input = request.ValidateInput("inputName", statusCode, comment);
|
OBSSourceAutoRelease input = request.ValidateInput(statusCode, comment);
|
||||||
if (!(input && request.ValidateNumber("inputAudioSyncOffset", statusCode, comment, -950, 20000)))
|
if (!(input && request.ValidateNumber("inputAudioSyncOffset", statusCode, comment, -950, 20000)))
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -683,7 +699,8 @@ RequestResult RequestHandler::SetInputAudioSyncOffset(const Request &request)
|
|||||||
* - `OBS_MONITORING_TYPE_MONITOR_ONLY`
|
* - `OBS_MONITORING_TYPE_MONITOR_ONLY`
|
||||||
* - `OBS_MONITORING_TYPE_MONITOR_AND_OUTPUT`
|
* - `OBS_MONITORING_TYPE_MONITOR_AND_OUTPUT`
|
||||||
*
|
*
|
||||||
* @requestField inputName | String | Name of the input to get the audio monitor type of
|
* @requestField ?inputName | String | Name of the input to get the audio monitor type of
|
||||||
|
* @requestField ?inputUuid | String | UUID of the input to get the audio monitor type of
|
||||||
*
|
*
|
||||||
* @responseField monitorType | String | Audio monitor type
|
* @responseField monitorType | String | Audio monitor type
|
||||||
*
|
*
|
||||||
@ -698,7 +715,7 @@ RequestResult RequestHandler::GetInputAudioMonitorType(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSourceAutoRelease input = request.ValidateInput("inputName", statusCode, comment);
|
OBSSourceAutoRelease input = request.ValidateInput(statusCode, comment);
|
||||||
if (!input)
|
if (!input)
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -714,7 +731,8 @@ RequestResult RequestHandler::GetInputAudioMonitorType(const Request &request)
|
|||||||
/**
|
/**
|
||||||
* Sets the audio monitor type of an input.
|
* Sets the audio monitor type of an input.
|
||||||
*
|
*
|
||||||
* @requestField inputName | String | Name of the input to set the audio monitor type of
|
* @requestField ?inputName | String | Name of the input to set the audio monitor type of
|
||||||
|
* @requestField ?inputUuid | String | UUID of the input to set the audio monitor type of
|
||||||
* @requestField monitorType | String | Audio monitor type
|
* @requestField monitorType | String | Audio monitor type
|
||||||
*
|
*
|
||||||
* @requestType SetInputAudioMonitorType
|
* @requestType SetInputAudioMonitorType
|
||||||
@ -728,7 +746,7 @@ RequestResult RequestHandler::SetInputAudioMonitorType(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSourceAutoRelease input = request.ValidateInput("inputName", statusCode, comment);
|
OBSSourceAutoRelease input = request.ValidateInput(statusCode, comment);
|
||||||
if (!(input && request.ValidateString("monitorType", statusCode, comment)))
|
if (!(input && request.ValidateString("monitorType", statusCode, comment)))
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -759,7 +777,8 @@ RequestResult RequestHandler::SetInputAudioMonitorType(const Request &request)
|
|||||||
/**
|
/**
|
||||||
* Gets the enable state of all audio tracks of an input.
|
* Gets the enable state of all audio tracks of an input.
|
||||||
*
|
*
|
||||||
* @requestField inputName | String | Name of the input
|
* @requestField ?inputName | String | Name of the input
|
||||||
|
* @requestField ?inputUuid | String | UUID of the input
|
||||||
*
|
*
|
||||||
* @responseField inputAudioTracks | Object | Object of audio tracks and associated enable states
|
* @responseField inputAudioTracks | Object | Object of audio tracks and associated enable states
|
||||||
*
|
*
|
||||||
@ -774,7 +793,7 @@ RequestResult RequestHandler::GetInputAudioTracks(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSourceAutoRelease input = request.ValidateInput("inputName", statusCode, comment);
|
OBSSourceAutoRelease input = request.ValidateInput(statusCode, comment);
|
||||||
if (!input)
|
if (!input)
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -797,7 +816,8 @@ RequestResult RequestHandler::GetInputAudioTracks(const Request &request)
|
|||||||
/**
|
/**
|
||||||
* Sets the enable state of audio tracks of an input.
|
* Sets the enable state of audio tracks of an input.
|
||||||
*
|
*
|
||||||
* @requestField inputName | String | Name of the input
|
* @requestField ?inputName | String | Name of the input
|
||||||
|
* @requestField ?inputUuid | String | UUID of the input
|
||||||
* @requestField inputAudioTracks | Object | Track settings to apply
|
* @requestField inputAudioTracks | Object | Track settings to apply
|
||||||
*
|
*
|
||||||
* @requestType SetInputAudioTracks
|
* @requestType SetInputAudioTracks
|
||||||
@ -811,7 +831,7 @@ RequestResult RequestHandler::SetInputAudioTracks(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSourceAutoRelease input = request.ValidateInput("inputName", statusCode, comment);
|
OBSSourceAutoRelease input = request.ValidateInput(statusCode, comment);
|
||||||
if (!input || !request.ValidateObject("inputAudioTracks", statusCode, comment))
|
if (!input || !request.ValidateObject("inputAudioTracks", statusCode, comment))
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -851,7 +871,8 @@ RequestResult RequestHandler::SetInputAudioTracks(const Request &request)
|
|||||||
*
|
*
|
||||||
* Note: Use this in cases where an input provides a dynamic, selectable list of items. For example, display capture, where it provides a list of available displays.
|
* Note: Use this in cases where an input provides a dynamic, selectable list of items. For example, display capture, where it provides a list of available displays.
|
||||||
*
|
*
|
||||||
* @requestField inputName | String | Name of the input
|
* @requestField ?inputName | String | Name of the input
|
||||||
|
* @requestField ?inputUuid | String | UUID of the input
|
||||||
* @requestField propertyName | String | Name of the list property to get the items of
|
* @requestField propertyName | String | Name of the list property to get the items of
|
||||||
*
|
*
|
||||||
* @responseField propertyItems | Array<Object> | Array of items in the list property
|
* @responseField propertyItems | Array<Object> | Array of items in the list property
|
||||||
@ -867,7 +888,7 @@ RequestResult RequestHandler::GetInputPropertiesListPropertyItems(const Request
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSourceAutoRelease input = request.ValidateInput("inputName", statusCode, comment);
|
OBSSourceAutoRelease input = request.ValidateInput(statusCode, comment);
|
||||||
if (!(input && request.ValidateString("propertyName", statusCode, comment)))
|
if (!(input && request.ValidateString("propertyName", statusCode, comment)))
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -895,7 +916,8 @@ RequestResult RequestHandler::GetInputPropertiesListPropertyItems(const Request
|
|||||||
*
|
*
|
||||||
* Note: Use this in cases where there is a button in the properties of an input that cannot be accessed in any other way. For example, browser sources, where there is a refresh button.
|
* Note: Use this in cases where there is a button in the properties of an input that cannot be accessed in any other way. For example, browser sources, where there is a refresh button.
|
||||||
*
|
*
|
||||||
* @requestField inputName | String | Name of the input
|
* @requestField ?inputName | String | Name of the input
|
||||||
|
* @requestField ?inputUuid | String | UUID of the input
|
||||||
* @requestField propertyName | String | Name of the button property to press
|
* @requestField propertyName | String | Name of the button property to press
|
||||||
*
|
*
|
||||||
* @requestType PressInputPropertiesButton
|
* @requestType PressInputPropertiesButton
|
||||||
@ -909,7 +931,7 @@ RequestResult RequestHandler::PressInputPropertiesButton(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSourceAutoRelease input = request.ValidateInput("inputName", statusCode, comment);
|
OBSSourceAutoRelease input = request.ValidateInput(statusCode, comment);
|
||||||
if (!(input && request.ValidateString("propertyName", statusCode, comment)))
|
if (!(input && request.ValidateString("propertyName", statusCode, comment)))
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
|
@ -39,7 +39,8 @@ bool IsMediaTimeValid(obs_source_t *input)
|
|||||||
* - `OBS_MEDIA_STATE_ENDED`
|
* - `OBS_MEDIA_STATE_ENDED`
|
||||||
* - `OBS_MEDIA_STATE_ERROR`
|
* - `OBS_MEDIA_STATE_ERROR`
|
||||||
*
|
*
|
||||||
* @requestField inputName | String | Name of the media input
|
* @requestField ?inputName | String | Name of the media input
|
||||||
|
* @requestField ?inputUuid | String | UUID of the media input
|
||||||
*
|
*
|
||||||
* @responseField mediaState | String | State of the media input
|
* @responseField mediaState | String | State of the media input
|
||||||
* @responseField mediaDuration | Number | Total duration of the playing media in milliseconds. `null` if not playing
|
* @responseField mediaDuration | Number | Total duration of the playing media in milliseconds. `null` if not playing
|
||||||
@ -56,7 +57,7 @@ RequestResult RequestHandler::GetMediaInputStatus(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSourceAutoRelease input = request.ValidateInput("inputName", statusCode, comment);
|
OBSSourceAutoRelease input = request.ValidateInput(statusCode, comment);
|
||||||
if (!input)
|
if (!input)
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -80,7 +81,8 @@ RequestResult RequestHandler::GetMediaInputStatus(const Request &request)
|
|||||||
*
|
*
|
||||||
* This request does not perform bounds checking of the cursor position.
|
* This request does not perform bounds checking of the cursor position.
|
||||||
*
|
*
|
||||||
* @requestField inputName | String | Name of the media input
|
* @requestField ?inputName | String | Name of the media input
|
||||||
|
* @requestField ?inputUuid | String | UUID of the media input
|
||||||
* @requestField mediaCursor | Number | New cursor position to set | >= 0
|
* @requestField mediaCursor | Number | New cursor position to set | >= 0
|
||||||
*
|
*
|
||||||
* @requestType SetMediaInputCursor
|
* @requestType SetMediaInputCursor
|
||||||
@ -94,7 +96,7 @@ RequestResult RequestHandler::SetMediaInputCursor(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSourceAutoRelease input = request.ValidateInput("inputName", statusCode, comment);
|
OBSSourceAutoRelease input = request.ValidateInput(statusCode, comment);
|
||||||
if (!(input && request.ValidateNumber("mediaCursor", statusCode, comment, 0)))
|
if (!(input && request.ValidateNumber("mediaCursor", statusCode, comment, 0)))
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -115,7 +117,8 @@ RequestResult RequestHandler::SetMediaInputCursor(const Request &request)
|
|||||||
*
|
*
|
||||||
* This request does not perform bounds checking of the cursor position.
|
* This request does not perform bounds checking of the cursor position.
|
||||||
*
|
*
|
||||||
* @requestField inputName | String | Name of the media input
|
* @requestField ?inputName | String | Name of the media input
|
||||||
|
* @requestField ?inputUuid | String | UUID of the media input
|
||||||
* @requestField mediaCursorOffset | Number | Value to offset the current cursor position by | None
|
* @requestField mediaCursorOffset | Number | Value to offset the current cursor position by | None
|
||||||
*
|
*
|
||||||
* @requestType OffsetMediaInputCursor
|
* @requestType OffsetMediaInputCursor
|
||||||
@ -129,7 +132,7 @@ RequestResult RequestHandler::OffsetMediaInputCursor(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSourceAutoRelease input = request.ValidateInput("inputName", statusCode, comment);
|
OBSSourceAutoRelease input = request.ValidateInput(statusCode, comment);
|
||||||
if (!(input && request.ValidateNumber("mediaCursorOffset", statusCode, comment)))
|
if (!(input && request.ValidateNumber("mediaCursorOffset", statusCode, comment)))
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -151,7 +154,8 @@ RequestResult RequestHandler::OffsetMediaInputCursor(const Request &request)
|
|||||||
/**
|
/**
|
||||||
* Triggers an action on a media input.
|
* Triggers an action on a media input.
|
||||||
*
|
*
|
||||||
* @requestField inputName | String | Name of the media input
|
* @requestField ?inputName | String | Name of the media input
|
||||||
|
* @requestField ?inputUuid | String | UUID of the media input
|
||||||
* @requestField mediaAction | String | Identifier of the `ObsMediaInputAction` enum
|
* @requestField mediaAction | String | Identifier of the `ObsMediaInputAction` enum
|
||||||
*
|
*
|
||||||
* @requestType TriggerMediaInputAction
|
* @requestType TriggerMediaInputAction
|
||||||
@ -165,7 +169,7 @@ RequestResult RequestHandler::TriggerMediaInputAction(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSourceAutoRelease input = request.ValidateInput("inputName", statusCode, comment);
|
OBSSourceAutoRelease input = request.ValidateInput(statusCode, comment);
|
||||||
if (!(input && request.ValidateString("mediaAction", statusCode, comment)))
|
if (!(input && request.ValidateString("mediaAction", statusCode, comment)))
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
|
@ -24,7 +24,8 @@ with this program. If not, see <https://www.gnu.org/licenses/>
|
|||||||
*
|
*
|
||||||
* Scenes only
|
* Scenes only
|
||||||
*
|
*
|
||||||
* @requestField sceneName | String | Name of the scene to get the items of
|
* @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
|
* @responseField sceneItems | Array<Object> | Array of scene items in the scene
|
||||||
*
|
*
|
||||||
@ -39,7 +40,7 @@ RequestResult RequestHandler::GetSceneItemList(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSourceAutoRelease scene = request.ValidateScene("sceneName", statusCode, comment);
|
OBSSourceAutoRelease scene = request.ValidateScene(statusCode, comment);
|
||||||
if (!scene)
|
if (!scene)
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -56,7 +57,8 @@ RequestResult RequestHandler::GetSceneItemList(const Request &request)
|
|||||||
*
|
*
|
||||||
* Groups only
|
* Groups only
|
||||||
*
|
*
|
||||||
* @requestField sceneName | String | Name of the group to get the items of
|
* @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
|
* @responseField sceneItems | Array<Object> | Array of scene items in the group
|
||||||
*
|
*
|
||||||
@ -71,7 +73,7 @@ RequestResult RequestHandler::GetGroupSceneItemList(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSourceAutoRelease scene = request.ValidateScene("sceneName", statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_GROUP_ONLY);
|
OBSSourceAutoRelease scene = request.ValidateScene(statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_GROUP_ONLY);
|
||||||
if (!scene)
|
if (!scene)
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -86,7 +88,8 @@ RequestResult RequestHandler::GetGroupSceneItemList(const Request &request)
|
|||||||
*
|
*
|
||||||
* Scenes and Groups
|
* Scenes and Groups
|
||||||
*
|
*
|
||||||
* @requestField sceneName | String | Name of the scene or group to search 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
|
* @requestField sourceName | String | Name of the source to find
|
||||||
* @requestField ?searchOffset | Number | Number of matches to skip during search. >= 0 means first forward. -1 means last (top) item | >= -1 | 0
|
* @requestField ?searchOffset | Number | Number of matches to skip during search. >= 0 means first forward. -1 means last (top) item | >= -1 | 0
|
||||||
*
|
*
|
||||||
@ -104,8 +107,8 @@ RequestResult RequestHandler::GetSceneItemId(const Request &request)
|
|||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSceneAutoRelease scene =
|
OBSSceneAutoRelease scene =
|
||||||
request.ValidateScene2("sceneName", statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
request.ValidateScene2(statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
||||||
if (!(scene && request.ValidateString("sourceName", statusCode, comment)))
|
if (!(scene && request.ValidateString("sourceName", statusCode, comment))) // TODO: Source UUID support
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
std::string sourceName = request.RequestData["sourceName"];
|
std::string sourceName = request.RequestData["sourceName"];
|
||||||
@ -131,10 +134,12 @@ RequestResult RequestHandler::GetSceneItemId(const Request &request)
|
|||||||
/**
|
/**
|
||||||
* Gets the source name of a scene item.
|
* Gets the source name of a scene item.
|
||||||
*
|
*
|
||||||
* @requestField sceneName | String | Name of the scene the item 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
|
* @requestField sceneItemId | Number | Numeric ID of the scene item | >= 0
|
||||||
*
|
*
|
||||||
* @responseField sourceName | String | Name of the source associated with the scene item
|
* @responseField sourceName | String | Name of the source associated with the scene item
|
||||||
|
* @responseField sourceUuid | String | UUID of the source associated with the scene item
|
||||||
*
|
*
|
||||||
* @requestType GetSceneItemSourceName
|
* @requestType GetSceneItemSourceName
|
||||||
* @complexity 3
|
* @complexity 3
|
||||||
@ -143,11 +148,11 @@ RequestResult RequestHandler::GetSceneItemId(const Request &request)
|
|||||||
* @api requests
|
* @api requests
|
||||||
* @category scene items
|
* @category scene items
|
||||||
*/
|
*/
|
||||||
RequestResult RequestHandler::GetSceneItemSourceName(const Request &request)
|
RequestResult RequestHandler::GetSceneItemSourceName(const Request &request) // TODO: Rename to `GetSceneItemSource`
|
||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem("sceneName", "sceneItemId", statusCode, comment);
|
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem(statusCode, comment);
|
||||||
if (!sceneItem)
|
if (!sceneItem)
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -155,6 +160,7 @@ RequestResult RequestHandler::GetSceneItemSourceName(const Request &request)
|
|||||||
|
|
||||||
json responseData;
|
json responseData;
|
||||||
responseData["sourceName"] = obs_source_get_name(source);
|
responseData["sourceName"] = obs_source_get_name(source);
|
||||||
|
responseData["sourceUuid"] = obs_source_get_uuid(source);
|
||||||
|
|
||||||
return RequestResult::Success(responseData);
|
return RequestResult::Success(responseData);
|
||||||
}
|
}
|
||||||
@ -164,8 +170,10 @@ RequestResult RequestHandler::GetSceneItemSourceName(const Request &request)
|
|||||||
*
|
*
|
||||||
* Scenes only
|
* Scenes only
|
||||||
*
|
*
|
||||||
* @requestField sceneName | String | Name of the scene to create the new item in
|
* @requestField ?sceneName | String | Name of the scene to create the new item in
|
||||||
* @requestField sourceName | String | Name of the source to add to the scene
|
* @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
|
||||||
|
* @requestField ?sourceUuid | String | UUID of the source to add to the scene
|
||||||
* @requestField ?sceneItemEnabled | Boolean | Enable state to apply to the scene item on creation | True
|
* @requestField ?sceneItemEnabled | Boolean | Enable state to apply to the scene item on creation | True
|
||||||
*
|
*
|
||||||
* @responseField sceneItemId | Number | Numeric ID of the scene item
|
* @responseField sceneItemId | Number | Numeric ID of the scene item
|
||||||
@ -181,17 +189,17 @@ RequestResult RequestHandler::CreateSceneItem(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSourceAutoRelease sceneSource = request.ValidateScene("sceneName", statusCode, comment);
|
OBSSourceAutoRelease sceneSource = request.ValidateScene(statusCode, comment);
|
||||||
if (!sceneSource)
|
if (!sceneSource)
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
OBSScene scene = obs_scene_from_source(sceneSource);
|
OBSScene scene = obs_scene_from_source(sceneSource);
|
||||||
|
|
||||||
OBSSourceAutoRelease source = request.ValidateSource("sourceName", statusCode, comment);
|
OBSSourceAutoRelease source = request.ValidateSource("sourceName", "sourceUuid", statusCode, comment);
|
||||||
if (!source)
|
if (!source)
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
if (request.RequestData["sceneName"] == request.RequestData["sourceName"])
|
if (sceneSource == source)
|
||||||
return RequestResult::Error(RequestStatus::CannotAct, "You cannot create scene item of a scene within itself.");
|
return RequestResult::Error(RequestStatus::CannotAct, "You cannot create scene item of a scene within itself.");
|
||||||
|
|
||||||
bool sceneItemEnabled = true;
|
bool sceneItemEnabled = true;
|
||||||
@ -216,7 +224,8 @@ RequestResult RequestHandler::CreateSceneItem(const Request &request)
|
|||||||
*
|
*
|
||||||
* Scenes only
|
* Scenes only
|
||||||
*
|
*
|
||||||
* @requestField sceneName | String | Name of the scene the item 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
|
* @requestField sceneItemId | Number | Numeric ID of the scene item | >= 0
|
||||||
*
|
*
|
||||||
* @requestType RemoveSceneItem
|
* @requestType RemoveSceneItem
|
||||||
@ -230,7 +239,7 @@ RequestResult RequestHandler::RemoveSceneItem(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem("sceneName", "sceneItemId", statusCode, comment);
|
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem(statusCode, comment);
|
||||||
if (!sceneItem)
|
if (!sceneItem)
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -245,9 +254,11 @@ RequestResult RequestHandler::RemoveSceneItem(const Request &request)
|
|||||||
*
|
*
|
||||||
* Scenes only
|
* Scenes only
|
||||||
*
|
*
|
||||||
* @requestField sceneName | String | Name of the scene the item 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
|
* @requestField sceneItemId | Number | Numeric ID of the scene item | >= 0
|
||||||
* @requestField ?destinationSceneName | String | Name of the scene to create the duplicated item in | `sceneName` is assumed
|
* @requestField ?destinationSceneName | String | Name of the scene to create the duplicated item in | From scene is assumed
|
||||||
|
* @requestField ?destinationSceneUuid | String | UUID of the scene to create the duplicated item in | From scene is assumed
|
||||||
*
|
*
|
||||||
* @responseField sceneItemId | Number | Numeric ID of the duplicated scene item
|
* @responseField sceneItemId | Number | Numeric ID of the duplicated scene item
|
||||||
*
|
*
|
||||||
@ -262,16 +273,24 @@ RequestResult RequestHandler::DuplicateSceneItem(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem("sceneName", "sceneItemId", statusCode, comment);
|
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem(statusCode, comment);
|
||||||
if (!sceneItem)
|
if (!sceneItem)
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
// Get destination scene
|
// Get destination scene
|
||||||
obs_scene_t *destinationScene;
|
obs_scene_t *destinationScene;
|
||||||
if (request.Contains("destinationSceneName")) {
|
if (request.Contains("destinationSceneName")) {
|
||||||
destinationScene = request.ValidateScene2("destinationSceneName", statusCode, comment);
|
OBSSourceAutoRelease destinationSceneSource = request.ValidateSource("destinationSceneName", "destinationSceneUuid", statusCode, comment);
|
||||||
if (!destinationScene)
|
if (!destinationSceneSource)
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
|
// Reimplementation of ValidateScene2
|
||||||
|
if (obs_source_get_type(destinationSceneSource) != OBS_SOURCE_TYPE_SCENE)
|
||||||
|
return RequestResult::Error(RequestStatus::InvalidResourceType, "The specified source is not a scene.");
|
||||||
|
if (obs_source_is_group(destinationSceneSource))
|
||||||
|
return RequestResult::Error(RequestStatus::InvalidResourceType, "The specified source is not a scene. (Is group)");
|
||||||
|
|
||||||
|
destinationScene = obs_scene_get_ref(obs_scene_from_source(destinationSceneSource));
|
||||||
} else {
|
} else {
|
||||||
destinationScene = obs_scene_get_ref(obs_sceneitem_get_scene(sceneItem));
|
destinationScene = obs_scene_get_ref(obs_sceneitem_get_scene(sceneItem));
|
||||||
if (!destinationScene)
|
if (!destinationScene)
|
||||||
@ -310,7 +329,8 @@ RequestResult RequestHandler::DuplicateSceneItem(const Request &request)
|
|||||||
*
|
*
|
||||||
* Scenes and Groups
|
* Scenes and Groups
|
||||||
*
|
*
|
||||||
* @requestField sceneName | String | Name of the scene the item 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
|
* @requestField sceneItemId | Number | Numeric ID of the scene item | >= 0
|
||||||
*
|
*
|
||||||
* @responseField sceneItemTransform | Object | Object containing scene item transform info
|
* @responseField sceneItemTransform | Object | Object containing scene item transform info
|
||||||
@ -326,8 +346,7 @@ RequestResult RequestHandler::GetSceneItemTransform(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem("sceneName", "sceneItemId", statusCode, comment,
|
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem(statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
||||||
OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
|
||||||
if (!sceneItem)
|
if (!sceneItem)
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -340,7 +359,8 @@ RequestResult RequestHandler::GetSceneItemTransform(const Request &request)
|
|||||||
/**
|
/**
|
||||||
* Sets the transform and crop info of a scene item.
|
* Sets the transform and crop info of a scene item.
|
||||||
*
|
*
|
||||||
* @requestField sceneName | String | Name of the scene the item 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
|
* @requestField sceneItemId | Number | Numeric ID of the scene item | >= 0
|
||||||
* @requestField sceneItemTransform | Object | Object containing scene item transform info to update
|
* @requestField sceneItemTransform | Object | Object containing scene item transform info to update
|
||||||
*
|
*
|
||||||
@ -355,8 +375,7 @@ RequestResult RequestHandler::SetSceneItemTransform(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem("sceneName", "sceneItemId", statusCode, comment,
|
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem(statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
||||||
OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
|
||||||
if (!(sceneItem && request.ValidateObject("sceneItemTransform", statusCode, comment)))
|
if (!(sceneItem && request.ValidateObject("sceneItemTransform", statusCode, comment)))
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -497,7 +516,8 @@ RequestResult RequestHandler::SetSceneItemTransform(const Request &request)
|
|||||||
*
|
*
|
||||||
* Scenes and Groups
|
* Scenes and Groups
|
||||||
*
|
*
|
||||||
* @requestField sceneName | String | Name of the scene the item 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
|
* @requestField sceneItemId | Number | Numeric ID of the scene item | >= 0
|
||||||
*
|
*
|
||||||
* @responseField sceneItemEnabled | Boolean | Whether the scene item is enabled. `true` for enabled, `false` for disabled
|
* @responseField sceneItemEnabled | Boolean | Whether the scene item is enabled. `true` for enabled, `false` for disabled
|
||||||
@ -513,8 +533,7 @@ RequestResult RequestHandler::GetSceneItemEnabled(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem("sceneName", "sceneItemId", statusCode, comment,
|
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem(statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
||||||
OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
|
||||||
if (!sceneItem)
|
if (!sceneItem)
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -529,7 +548,8 @@ RequestResult RequestHandler::GetSceneItemEnabled(const Request &request)
|
|||||||
*
|
*
|
||||||
* Scenes and Groups
|
* Scenes and Groups
|
||||||
*
|
*
|
||||||
* @requestField sceneName | String | Name of the scene the item 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
|
* @requestField sceneItemId | Number | Numeric ID of the scene item | >= 0
|
||||||
* @requestField sceneItemEnabled | Boolean | New enable state of the scene item
|
* @requestField sceneItemEnabled | Boolean | New enable state of the scene item
|
||||||
*
|
*
|
||||||
@ -544,8 +564,7 @@ RequestResult RequestHandler::SetSceneItemEnabled(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem("sceneName", "sceneItemId", statusCode, comment,
|
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem(statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
||||||
OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
|
||||||
if (!(sceneItem && request.ValidateBoolean("sceneItemEnabled", statusCode, comment)))
|
if (!(sceneItem && request.ValidateBoolean("sceneItemEnabled", statusCode, comment)))
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -561,7 +580,8 @@ RequestResult RequestHandler::SetSceneItemEnabled(const Request &request)
|
|||||||
*
|
*
|
||||||
* Scenes and Groups
|
* Scenes and Groups
|
||||||
*
|
*
|
||||||
* @requestField sceneName | String | Name of the scene the item 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
|
* @requestField sceneItemId | Number | Numeric ID of the scene item | >= 0
|
||||||
*
|
*
|
||||||
* @responseField sceneItemLocked | Boolean | Whether the scene item is locked. `true` for locked, `false` for unlocked
|
* @responseField sceneItemLocked | Boolean | Whether the scene item is locked. `true` for locked, `false` for unlocked
|
||||||
@ -577,8 +597,7 @@ RequestResult RequestHandler::GetSceneItemLocked(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem("sceneName", "sceneItemId", statusCode, comment,
|
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem(statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
||||||
OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
|
||||||
if (!sceneItem)
|
if (!sceneItem)
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -593,7 +612,8 @@ RequestResult RequestHandler::GetSceneItemLocked(const Request &request)
|
|||||||
*
|
*
|
||||||
* Scenes and Group
|
* Scenes and Group
|
||||||
*
|
*
|
||||||
* @requestField sceneName | String | Name of the scene the item 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
|
* @requestField sceneItemId | Number | Numeric ID of the scene item | >= 0
|
||||||
* @requestField sceneItemLocked | Boolean | New lock state of the scene item
|
* @requestField sceneItemLocked | Boolean | New lock state of the scene item
|
||||||
*
|
*
|
||||||
@ -608,8 +628,7 @@ RequestResult RequestHandler::SetSceneItemLocked(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem("sceneName", "sceneItemId", statusCode, comment,
|
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem(statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
||||||
OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
|
||||||
if (!(sceneItem && request.ValidateBoolean("sceneItemLocked", statusCode, comment)))
|
if (!(sceneItem && request.ValidateBoolean("sceneItemLocked", statusCode, comment)))
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -627,7 +646,8 @@ RequestResult RequestHandler::SetSceneItemLocked(const Request &request)
|
|||||||
*
|
*
|
||||||
* Scenes and Groups
|
* Scenes and Groups
|
||||||
*
|
*
|
||||||
* @requestField sceneName | String | Name of the scene the item 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
|
* @requestField sceneItemId | Number | Numeric ID of the scene item | >= 0
|
||||||
*
|
*
|
||||||
* @responseField sceneItemIndex | Number | Index position of the scene item
|
* @responseField sceneItemIndex | Number | Index position of the scene item
|
||||||
@ -643,8 +663,7 @@ RequestResult RequestHandler::GetSceneItemIndex(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem("sceneName", "sceneItemId", statusCode, comment,
|
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem(statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
||||||
OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
|
||||||
if (!sceneItem)
|
if (!sceneItem)
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -659,7 +678,8 @@ RequestResult RequestHandler::GetSceneItemIndex(const Request &request)
|
|||||||
*
|
*
|
||||||
* Scenes and Groups
|
* Scenes and Groups
|
||||||
*
|
*
|
||||||
* @requestField sceneName | String | Name of the scene the item 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
|
* @requestField sceneItemId | Number | Numeric ID of the scene item | >= 0
|
||||||
* @requestField sceneItemIndex | Number | New index position of the scene item | >= 0
|
* @requestField sceneItemIndex | Number | New index position of the scene item | >= 0
|
||||||
*
|
*
|
||||||
@ -674,8 +694,7 @@ RequestResult RequestHandler::SetSceneItemIndex(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem("sceneName", "sceneItemId", statusCode, comment,
|
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem(statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
||||||
OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
|
||||||
if (!(sceneItem && request.ValidateNumber("sceneItemIndex", statusCode, comment, 0, 8192)))
|
if (!(sceneItem && request.ValidateNumber("sceneItemIndex", statusCode, comment, 0, 8192)))
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -701,7 +720,8 @@ RequestResult RequestHandler::SetSceneItemIndex(const Request &request)
|
|||||||
*
|
*
|
||||||
* Scenes and Groups
|
* Scenes and Groups
|
||||||
*
|
*
|
||||||
* @requestField sceneName | String | Name of the scene the item 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
|
* @requestField sceneItemId | Number | Numeric ID of the scene item | >= 0
|
||||||
*
|
*
|
||||||
* @responseField sceneItemBlendMode | String | Current blend mode
|
* @responseField sceneItemBlendMode | String | Current blend mode
|
||||||
@ -717,8 +737,7 @@ RequestResult RequestHandler::GetSceneItemBlendMode(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem("sceneName", "sceneItemId", statusCode, comment,
|
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem(statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
||||||
OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
|
||||||
if (!sceneItem)
|
if (!sceneItem)
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -735,7 +754,8 @@ RequestResult RequestHandler::GetSceneItemBlendMode(const Request &request)
|
|||||||
*
|
*
|
||||||
* Scenes and Groups
|
* Scenes and Groups
|
||||||
*
|
*
|
||||||
* @requestField sceneName | String | Name of the scene the item 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
|
* @requestField sceneItemId | Number | Numeric ID of the scene item | >= 0
|
||||||
* @requestField sceneItemBlendMode | String | New blend mode
|
* @requestField sceneItemBlendMode | String | New blend mode
|
||||||
*
|
*
|
||||||
@ -750,8 +770,7 @@ RequestResult RequestHandler::SetSceneItemBlendMode(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem("sceneName", "sceneItemId", statusCode, comment,
|
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem(statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
||||||
OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
|
||||||
if (!(sceneItem && request.ValidateString("sceneItemBlendMode", statusCode, comment)))
|
if (!(sceneItem && request.ValidateString("sceneItemBlendMode", statusCode, comment)))
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -770,8 +789,7 @@ RequestResult RequestHandler::GetSceneItemPrivateSettings(const Request &request
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem("sceneName", "sceneItemId", statusCode, comment,
|
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem(statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
||||||
OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
|
||||||
if (!sceneItem)
|
if (!sceneItem)
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -788,8 +806,7 @@ RequestResult RequestHandler::SetSceneItemPrivateSettings(const Request &request
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem("sceneName", "sceneItemId", statusCode, comment,
|
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem(statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
||||||
OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
|
||||||
if (!sceneItem || !request.ValidateObject("sceneItemSettings", statusCode, comment, true))
|
if (!sceneItem || !request.ValidateObject("sceneItemSettings", statusCode, comment, true))
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
|
@ -22,8 +22,10 @@ with this program. If not, see <https://www.gnu.org/licenses/>
|
|||||||
/**
|
/**
|
||||||
* Gets an array of all scenes in OBS.
|
* Gets an array of all scenes in OBS.
|
||||||
*
|
*
|
||||||
* @responseField currentProgramSceneName | String | Current program scene
|
* @responseField currentProgramSceneName | String | Current program scene name. Can be `null` if internal state desync
|
||||||
* @responseField currentPreviewSceneName | String | Current preview scene. `null` if not in studio mode
|
* @responseField currentProgramSceneUuid | String | Current program scene UUID. Can be `null` if internal state desync
|
||||||
|
* @responseField currentPreviewSceneName | String | Current preview scene name. `null` if not in studio mode
|
||||||
|
* @responseField currentPreviewSceneUuid | String | Current preview scene UUID. `null` if not in studio mode
|
||||||
* @responseField scenes | Array<Object> | Array of scenes
|
* @responseField scenes | Array<Object> | Array of scenes
|
||||||
*
|
*
|
||||||
* @requestType GetSceneList
|
* @requestType GetSceneList
|
||||||
@ -38,16 +40,22 @@ RequestResult RequestHandler::GetSceneList(const Request &)
|
|||||||
json responseData;
|
json responseData;
|
||||||
|
|
||||||
OBSSourceAutoRelease currentProgramScene = obs_frontend_get_current_scene();
|
OBSSourceAutoRelease currentProgramScene = obs_frontend_get_current_scene();
|
||||||
if (currentProgramScene)
|
if (currentProgramScene) {
|
||||||
responseData["currentProgramSceneName"] = obs_source_get_name(currentProgramScene);
|
responseData["currentProgramSceneName"] = obs_source_get_name(currentProgramScene);
|
||||||
else
|
responseData["currentProgramSceneUuid"] = obs_source_get_uuid(currentProgramScene);
|
||||||
|
} else {
|
||||||
responseData["currentProgramSceneName"] = nullptr;
|
responseData["currentProgramSceneName"] = nullptr;
|
||||||
|
responseData["currentProgramSceneUuid"] = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
OBSSourceAutoRelease currentPreviewScene = obs_frontend_get_current_preview_scene();
|
OBSSourceAutoRelease currentPreviewScene = obs_frontend_get_current_preview_scene();
|
||||||
if (currentPreviewScene)
|
if (currentPreviewScene) {
|
||||||
responseData["currentPreviewSceneName"] = obs_source_get_name(currentPreviewScene);
|
responseData["currentPreviewSceneName"] = obs_source_get_name(currentPreviewScene);
|
||||||
else
|
responseData["currentPreviewSceneUuid"] = obs_source_get_uuid(currentPreviewScene);
|
||||||
|
} else {
|
||||||
responseData["currentPreviewSceneName"] = nullptr;
|
responseData["currentPreviewSceneName"] = nullptr;
|
||||||
|
responseData["currentPreviewSceneUuid"] = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
responseData["scenes"] = Utils::Obs::ArrayHelper::GetSceneList();
|
responseData["scenes"] = Utils::Obs::ArrayHelper::GetSceneList();
|
||||||
|
|
||||||
@ -80,7 +88,12 @@ RequestResult RequestHandler::GetGroupList(const Request &)
|
|||||||
/**
|
/**
|
||||||
* Gets the current program scene.
|
* Gets the current program scene.
|
||||||
*
|
*
|
||||||
* @responseField currentProgramSceneName | String | Current program scene
|
* Note: This request is slated to have the `currentProgram`-prefixed fields removed from in an upcoming RPC version.
|
||||||
|
*
|
||||||
|
* @responseField sceneName | String | Current program scene name
|
||||||
|
* @responseField sceneUuid | String | Current program scene UUID
|
||||||
|
* @responseField currentProgramSceneName | String | Current program scene name (Deprecated)
|
||||||
|
* @responseField currentProgramSceneUuid | String | Current program scene UUID (Deprecated)
|
||||||
*
|
*
|
||||||
* @requestType GetCurrentProgramScene
|
* @requestType GetCurrentProgramScene
|
||||||
* @complexity 1
|
* @complexity 1
|
||||||
@ -93,7 +106,8 @@ RequestResult RequestHandler::GetCurrentProgramScene(const Request &)
|
|||||||
{
|
{
|
||||||
json responseData;
|
json responseData;
|
||||||
OBSSourceAutoRelease currentProgramScene = obs_frontend_get_current_scene();
|
OBSSourceAutoRelease currentProgramScene = obs_frontend_get_current_scene();
|
||||||
responseData["currentProgramSceneName"] = obs_source_get_name(currentProgramScene);
|
responseData["sceneName"] = responseData["currentProgramSceneName"] = obs_source_get_name(currentProgramScene);
|
||||||
|
responseData["sceneUuid"] = responseData["currentProgramSceneUuid"] = obs_source_get_uuid(currentProgramScene);
|
||||||
|
|
||||||
return RequestResult::Success(responseData);
|
return RequestResult::Success(responseData);
|
||||||
}
|
}
|
||||||
@ -101,7 +115,8 @@ RequestResult RequestHandler::GetCurrentProgramScene(const Request &)
|
|||||||
/**
|
/**
|
||||||
* Sets the current program scene.
|
* Sets the current program scene.
|
||||||
*
|
*
|
||||||
* @requestField sceneName | String | Scene to set as the current program scene
|
* @requestField ?sceneName | String | Scene name to set as the current program scene
|
||||||
|
* @requestField ?sceneUuid | String | Scene UUID to set as the current program scene
|
||||||
*
|
*
|
||||||
* @requestType SetCurrentProgramScene
|
* @requestType SetCurrentProgramScene
|
||||||
* @complexity 1
|
* @complexity 1
|
||||||
@ -114,7 +129,7 @@ RequestResult RequestHandler::SetCurrentProgramScene(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSourceAutoRelease scene = request.ValidateScene("sceneName", statusCode, comment);
|
OBSSourceAutoRelease scene = request.ValidateScene(statusCode, comment);
|
||||||
if (!scene)
|
if (!scene)
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -128,7 +143,12 @@ RequestResult RequestHandler::SetCurrentProgramScene(const Request &request)
|
|||||||
*
|
*
|
||||||
* Only available when studio mode is enabled.
|
* Only available when studio mode is enabled.
|
||||||
*
|
*
|
||||||
* @responseField currentPreviewSceneName | String | Current preview scene
|
* Note: This request is slated to have the `currentPreview`-prefixed fields removed from in an upcoming RPC version.
|
||||||
|
*
|
||||||
|
* @responseField sceneName | String | Current preview scene name
|
||||||
|
* @responseField sceneUuid | String | Current preview scene UUID
|
||||||
|
* @responseField currentPreviewSceneName | String | Current preview scene name
|
||||||
|
* @responseField currentPreviewSceneUuid | String | Current preview scene UUID
|
||||||
*
|
*
|
||||||
* @requestType GetCurrentPreviewScene
|
* @requestType GetCurrentPreviewScene
|
||||||
* @complexity 1
|
* @complexity 1
|
||||||
@ -145,7 +165,8 @@ RequestResult RequestHandler::GetCurrentPreviewScene(const Request &)
|
|||||||
OBSSourceAutoRelease currentPreviewScene = obs_frontend_get_current_preview_scene();
|
OBSSourceAutoRelease currentPreviewScene = obs_frontend_get_current_preview_scene();
|
||||||
|
|
||||||
json responseData;
|
json responseData;
|
||||||
responseData["currentPreviewSceneName"] = obs_source_get_name(currentPreviewScene);
|
responseData["sceneName"] = responseData["currentPreviewSceneName"] = obs_source_get_name(currentPreviewScene);
|
||||||
|
responseData["sceneUuid"] = responseData["currentPreviewSceneUuid"] = obs_source_get_uuid(currentPreviewScene);
|
||||||
|
|
||||||
return RequestResult::Success(responseData);
|
return RequestResult::Success(responseData);
|
||||||
}
|
}
|
||||||
@ -155,7 +176,8 @@ RequestResult RequestHandler::GetCurrentPreviewScene(const Request &)
|
|||||||
*
|
*
|
||||||
* Only available when studio mode is enabled.
|
* Only available when studio mode is enabled.
|
||||||
*
|
*
|
||||||
* @requestField sceneName | String | Scene to set as the current preview scene
|
* @requestField ?sceneName | String | Scene name to set as the current preview scene
|
||||||
|
* @requestField ?sceneUuid | String | Scene UUID to set as the current preview scene
|
||||||
*
|
*
|
||||||
* @requestType SetCurrentPreviewScene
|
* @requestType SetCurrentPreviewScene
|
||||||
* @complexity 1
|
* @complexity 1
|
||||||
@ -171,7 +193,7 @@ RequestResult RequestHandler::SetCurrentPreviewScene(const Request &request)
|
|||||||
|
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSourceAutoRelease scene = request.ValidateScene("sceneName", statusCode, comment);
|
OBSSourceAutoRelease scene = request.ValidateScene(statusCode, comment);
|
||||||
if (!scene)
|
if (!scene)
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -185,6 +207,8 @@ RequestResult RequestHandler::SetCurrentPreviewScene(const Request &request)
|
|||||||
*
|
*
|
||||||
* @requestField sceneName | String | Name for the new scene
|
* @requestField sceneName | String | Name for the new scene
|
||||||
*
|
*
|
||||||
|
* @responseField sceneUuid | String | UUID of the created scene
|
||||||
|
*
|
||||||
* @requestType CreateScene
|
* @requestType CreateScene
|
||||||
* @complexity 2
|
* @complexity 2
|
||||||
* @rpcVersion -1
|
* @rpcVersion -1
|
||||||
@ -205,19 +229,21 @@ RequestResult RequestHandler::CreateScene(const Request &request)
|
|||||||
if (scene)
|
if (scene)
|
||||||
return RequestResult::Error(RequestStatus::ResourceAlreadyExists, "A source already exists by that scene name.");
|
return RequestResult::Error(RequestStatus::ResourceAlreadyExists, "A source already exists by that scene name.");
|
||||||
|
|
||||||
obs_scene_t *createdScene = obs_scene_create(sceneName.c_str());
|
OBSSceneAutoRelease createdScene = obs_scene_create(sceneName.c_str());
|
||||||
if (!createdScene)
|
if (!createdScene)
|
||||||
return RequestResult::Error(RequestStatus::ResourceCreationFailed, "Failed to create the scene.");
|
return RequestResult::Error(RequestStatus::ResourceCreationFailed, "Failed to create the scene.");
|
||||||
|
|
||||||
obs_scene_release(createdScene);
|
json responseData;
|
||||||
|
responseData["sceneUuid"] = obs_source_get_uuid(obs_scene_get_source(createdScene));
|
||||||
|
|
||||||
return RequestResult::Success();
|
return RequestResult::Success(responseData);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a scene from OBS.
|
* Removes a scene from OBS.
|
||||||
*
|
*
|
||||||
* @requestField sceneName | String | Name of the scene to remove
|
* @requestField ?sceneName | String | Name of the scene to remove
|
||||||
|
* @requestField ?sceneUuid | String | UUID of the scene to remove
|
||||||
*
|
*
|
||||||
* @requestType RemoveScene
|
* @requestType RemoveScene
|
||||||
* @complexity 2
|
* @complexity 2
|
||||||
@ -230,7 +256,7 @@ RequestResult RequestHandler::RemoveScene(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSourceAutoRelease scene = request.ValidateScene("sceneName", statusCode, comment);
|
OBSSourceAutoRelease scene = request.ValidateScene(statusCode, comment);
|
||||||
if (!scene)
|
if (!scene)
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -246,7 +272,8 @@ RequestResult RequestHandler::RemoveScene(const Request &request)
|
|||||||
/**
|
/**
|
||||||
* Sets the name of a scene (rename).
|
* Sets the name of a scene (rename).
|
||||||
*
|
*
|
||||||
* @requestField sceneName | String | Name of the scene to be renamed
|
* @requestField ?sceneName | String | Name of the scene to be renamed
|
||||||
|
* @requestField ?sceneUuid | String | UUID of the scene to be renamed
|
||||||
* @requestField newSceneName | String | New name for the scene
|
* @requestField newSceneName | String | New name for the scene
|
||||||
*
|
*
|
||||||
* @requestType SetSceneName
|
* @requestType SetSceneName
|
||||||
@ -260,7 +287,7 @@ RequestResult RequestHandler::SetSceneName(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSourceAutoRelease scene = request.ValidateScene("sceneName", statusCode, comment);
|
OBSSourceAutoRelease scene = request.ValidateScene(statusCode, comment);
|
||||||
if (!(scene && request.ValidateString("newSceneName", statusCode, comment)))
|
if (!(scene && request.ValidateString("newSceneName", statusCode, comment)))
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -279,7 +306,10 @@ RequestResult RequestHandler::SetSceneName(const Request &request)
|
|||||||
/**
|
/**
|
||||||
* Gets the scene transition overridden for a scene.
|
* Gets the scene transition overridden for a scene.
|
||||||
*
|
*
|
||||||
* @requestField sceneName | String | Name of the scene
|
* Note: A transition UUID response field is not currently able to be implemented as of 2024-1-18.
|
||||||
|
*
|
||||||
|
* @requestField ?sceneName | String | Name of the scene
|
||||||
|
* @requestField ?sceneUuid | String | UUID of the scene
|
||||||
*
|
*
|
||||||
* @responseField transitionName | String | Name of the overridden scene transition, else `null`
|
* @responseField transitionName | String | Name of the overridden scene transition, else `null`
|
||||||
* @responseField transitionDuration | Number | Duration of the overridden scene transition, else `null`
|
* @responseField transitionDuration | Number | Duration of the overridden scene transition, else `null`
|
||||||
@ -295,7 +325,7 @@ RequestResult RequestHandler::GetSceneSceneTransitionOverride(const Request &req
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSourceAutoRelease scene = request.ValidateScene("sceneName", statusCode, comment);
|
OBSSourceAutoRelease scene = request.ValidateScene(statusCode, comment);
|
||||||
if (!scene)
|
if (!scene)
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -319,7 +349,8 @@ RequestResult RequestHandler::GetSceneSceneTransitionOverride(const Request &req
|
|||||||
/**
|
/**
|
||||||
* Sets the scene transition overridden for a scene.
|
* Sets the scene transition overridden for a scene.
|
||||||
*
|
*
|
||||||
* @requestField sceneName | String | Name of the scene
|
* @requestField ?sceneName | String | Name of the scene
|
||||||
|
* @requestField ?sceneUuid | String | UUID of the scene
|
||||||
* @requestField ?transitionName | String | Name of the scene transition to use as override. Specify `null` to remove | Unchanged
|
* @requestField ?transitionName | String | Name of the scene transition to use as override. Specify `null` to remove | Unchanged
|
||||||
* @requestField ?transitionDuration | Number | Duration to use for any overridden transition. Specify `null` to remove | >= 50, <= 20000 | Unchanged
|
* @requestField ?transitionDuration | Number | Duration to use for any overridden transition. Specify `null` to remove | >= 50, <= 20000 | Unchanged
|
||||||
*
|
*
|
||||||
@ -334,7 +365,7 @@ RequestResult RequestHandler::SetSceneSceneTransitionOverride(const Request &req
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSourceAutoRelease scene = request.ValidateScene("sceneName", statusCode, comment);
|
OBSSourceAutoRelease scene = request.ValidateScene(statusCode, comment);
|
||||||
if (!scene)
|
if (!scene)
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
|
@ -114,7 +114,8 @@ bool IsImageFormatValid(std::string format)
|
|||||||
*
|
*
|
||||||
* **Compatible with inputs and scenes.**
|
* **Compatible with inputs and scenes.**
|
||||||
*
|
*
|
||||||
* @requestField sourceName | String | Name of the source to get the active state of
|
* @requestField ?sourceName | String | Name of the source to get the active state of
|
||||||
|
* @requestField ?sourceUuid | String | UUID of the source to get the active state of
|
||||||
*
|
*
|
||||||
* @responseField videoActive | Boolean | Whether the source is showing in Program
|
* @responseField videoActive | Boolean | Whether the source is showing in Program
|
||||||
* @responseField videoShowing | Boolean | Whether the source is showing in the UI (Preview, Projector, Properties)
|
* @responseField videoShowing | Boolean | Whether the source is showing in the UI (Preview, Projector, Properties)
|
||||||
@ -130,7 +131,7 @@ RequestResult RequestHandler::GetSourceActive(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSourceAutoRelease source = request.ValidateSource("sourceName", statusCode, comment);
|
OBSSourceAutoRelease source = request.ValidateSource("sourceName", "sourceUuid", statusCode, comment);
|
||||||
if (!source)
|
if (!source)
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -151,7 +152,8 @@ RequestResult RequestHandler::GetSourceActive(const Request &request)
|
|||||||
*
|
*
|
||||||
* **Compatible with inputs and scenes.**
|
* **Compatible with inputs and scenes.**
|
||||||
*
|
*
|
||||||
* @requestField sourceName | String | Name of the source to take a screenshot of
|
* @requestField ?sourceName | String | Name of the source to take a screenshot of
|
||||||
|
* @requestField ?sourceUuid | String | UUID of the source to take a screenshot of
|
||||||
* @requestField imageFormat | String | Image compression format to use. Use `GetVersion` to get compatible image formats
|
* @requestField imageFormat | String | Image compression format to use. Use `GetVersion` to get compatible image formats
|
||||||
* @requestField ?imageWidth | Number | Width to scale the screenshot to | >= 8, <= 4096 | Source value is used
|
* @requestField ?imageWidth | Number | Width to scale the screenshot to | >= 8, <= 4096 | Source value is used
|
||||||
* @requestField ?imageHeight | Number | Height to scale the screenshot to | >= 8, <= 4096 | Source value is used
|
* @requestField ?imageHeight | Number | Height to scale the screenshot to | >= 8, <= 4096 | Source value is used
|
||||||
@ -170,7 +172,7 @@ RequestResult RequestHandler::GetSourceScreenshot(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSourceAutoRelease source = request.ValidateSource("sourceName", statusCode, comment);
|
OBSSourceAutoRelease source = request.ValidateSource("sourceName", "sourceUuid", statusCode, comment);
|
||||||
if (!(source && request.ValidateString("imageFormat", statusCode, comment)))
|
if (!(source && request.ValidateString("imageFormat", statusCode, comment)))
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -238,7 +240,8 @@ RequestResult RequestHandler::GetSourceScreenshot(const Request &request)
|
|||||||
*
|
*
|
||||||
* **Compatible with inputs and scenes.**
|
* **Compatible with inputs and scenes.**
|
||||||
*
|
*
|
||||||
* @requestField sourceName | String | Name of the source to take a screenshot of
|
* @requestField ?sourceName | String | Name of the source to take a screenshot of
|
||||||
|
* @requestField ?sourceUuid | String | UUID of the source to take a screenshot of
|
||||||
* @requestField imageFormat | String | Image compression format to use. Use `GetVersion` to get compatible image formats
|
* @requestField imageFormat | String | Image compression format to use. Use `GetVersion` to get compatible image formats
|
||||||
* @requestField imageFilePath | String | Path to save the screenshot file to. Eg. `C:\Users\user\Desktop\screenshot.png`
|
* @requestField imageFilePath | String | Path to save the screenshot file to. Eg. `C:\Users\user\Desktop\screenshot.png`
|
||||||
* @requestField ?imageWidth | Number | Width to scale the screenshot to | >= 8, <= 4096 | Source value is used
|
* @requestField ?imageWidth | Number | Width to scale the screenshot to | >= 8, <= 4096 | Source value is used
|
||||||
@ -256,7 +259,7 @@ RequestResult RequestHandler::SaveSourceScreenshot(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSourceAutoRelease source = request.ValidateSource("sourceName", statusCode, comment);
|
OBSSourceAutoRelease source = request.ValidateSource("sourceName", "sourceUuid", statusCode, comment);
|
||||||
if (!(source && request.ValidateString("imageFormat", statusCode, comment) &&
|
if (!(source && request.ValidateString("imageFormat", statusCode, comment) &&
|
||||||
request.ValidateString("imageFilePath", statusCode, comment)))
|
request.ValidateString("imageFilePath", statusCode, comment)))
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
@ -319,7 +322,7 @@ RequestResult RequestHandler::GetSourcePrivateSettings(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSourceAutoRelease source = request.ValidateSource("sourceName", statusCode, comment);
|
OBSSourceAutoRelease source = request.ValidateSource("sourceName", "sourceUuid", statusCode, comment);
|
||||||
if (!source)
|
if (!source)
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -336,7 +339,7 @@ RequestResult RequestHandler::SetSourcePrivateSettings(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSourceAutoRelease source = request.ValidateSource("sourceName", statusCode, comment);
|
OBSSourceAutoRelease source = request.ValidateSource("sourceName", "sourceUuid", statusCode, comment);
|
||||||
if (!source || !request.ValidateObject("sourceSettings", statusCode, comment, true))
|
if (!source || !request.ValidateObject("sourceSettings", statusCode, comment, true))
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
|
@ -46,6 +46,7 @@ RequestResult RequestHandler::GetTransitionKindList(const Request &)
|
|||||||
* Gets an array of all scene transitions in OBS.
|
* Gets an array of all scene transitions in OBS.
|
||||||
*
|
*
|
||||||
* @responseField currentSceneTransitionName | String | Name of the current scene transition. Can be null
|
* @responseField currentSceneTransitionName | String | Name of the current scene transition. Can be null
|
||||||
|
* @responseField currentSceneTransitionUuid | String | UUID of the current scene transition. Can be null
|
||||||
* @responseField currentSceneTransitionKind | String | Kind of the current scene transition. Can be null
|
* @responseField currentSceneTransitionKind | String | Kind of the current scene transition. Can be null
|
||||||
* @responseField transitions | Array<Object> | Array of transitions
|
* @responseField transitions | Array<Object> | Array of transitions
|
||||||
*
|
*
|
||||||
@ -63,9 +64,11 @@ RequestResult RequestHandler::GetSceneTransitionList(const Request &)
|
|||||||
OBSSourceAutoRelease transition = obs_frontend_get_current_transition();
|
OBSSourceAutoRelease transition = obs_frontend_get_current_transition();
|
||||||
if (transition) {
|
if (transition) {
|
||||||
responseData["currentSceneTransitionName"] = obs_source_get_name(transition);
|
responseData["currentSceneTransitionName"] = obs_source_get_name(transition);
|
||||||
|
responseData["currentSceneTransitionUuid"] = obs_source_get_uuid(transition);
|
||||||
responseData["currentSceneTransitionKind"] = obs_source_get_id(transition);
|
responseData["currentSceneTransitionKind"] = obs_source_get_id(transition);
|
||||||
} else {
|
} else {
|
||||||
responseData["currentSceneTransitionName"] = nullptr;
|
responseData["currentSceneTransitionName"] = nullptr;
|
||||||
|
responseData["currentSceneTransitionUuid"] = nullptr;
|
||||||
responseData["currentSceneTransitionKind"] = nullptr;
|
responseData["currentSceneTransitionKind"] = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,6 +81,7 @@ RequestResult RequestHandler::GetSceneTransitionList(const Request &)
|
|||||||
* Gets information about the current scene transition.
|
* Gets information about the current scene transition.
|
||||||
*
|
*
|
||||||
* @responseField transitionName | String | Name of the transition
|
* @responseField transitionName | String | Name of the transition
|
||||||
|
* @responseField transitionUuid | String | UUID of the transition
|
||||||
* @responseField transitionKind | String | Kind of the transition
|
* @responseField transitionKind | String | Kind of the transition
|
||||||
* @responseField transitionFixed | Boolean | Whether the transition uses a fixed (unconfigurable) duration
|
* @responseField transitionFixed | Boolean | Whether the transition uses a fixed (unconfigurable) duration
|
||||||
* @responseField transitionDuration | Number | Configured transition duration in milliseconds. `null` if transition is fixed
|
* @responseField transitionDuration | Number | Configured transition duration in milliseconds. `null` if transition is fixed
|
||||||
@ -100,6 +104,7 @@ RequestResult RequestHandler::GetCurrentSceneTransition(const Request &)
|
|||||||
|
|
||||||
json responseData;
|
json responseData;
|
||||||
responseData["transitionName"] = obs_source_get_name(transition);
|
responseData["transitionName"] = obs_source_get_name(transition);
|
||||||
|
responseData["transitionUuid"] = obs_source_get_uuid(transition);
|
||||||
responseData["transitionKind"] = obs_source_get_id(transition);
|
responseData["transitionKind"] = obs_source_get_id(transition);
|
||||||
|
|
||||||
if (obs_transition_fixed(transition)) {
|
if (obs_transition_fixed(transition)) {
|
||||||
|
@ -82,7 +82,8 @@ RequestResult RequestHandler::SetStudioModeEnabled(const Request &request)
|
|||||||
/**
|
/**
|
||||||
* Opens the properties dialog of an input.
|
* Opens the properties dialog of an input.
|
||||||
*
|
*
|
||||||
* @requestField inputName | String | Name of the input to open the dialog of
|
* @requestField ?inputName | String | Name of the input to open the dialog of
|
||||||
|
* @requestField ?inputUuid | String | UUID of the input to open the dialog of
|
||||||
*
|
*
|
||||||
* @requestType OpenInputPropertiesDialog
|
* @requestType OpenInputPropertiesDialog
|
||||||
* @complexity 1
|
* @complexity 1
|
||||||
@ -95,7 +96,7 @@ RequestResult RequestHandler::OpenInputPropertiesDialog(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSourceAutoRelease input = request.ValidateInput("inputName", statusCode, comment);
|
OBSSourceAutoRelease input = request.ValidateInput(statusCode, comment);
|
||||||
if (!input)
|
if (!input)
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -107,7 +108,8 @@ RequestResult RequestHandler::OpenInputPropertiesDialog(const Request &request)
|
|||||||
/**
|
/**
|
||||||
* Opens the filters dialog of an input.
|
* Opens the filters dialog of an input.
|
||||||
*
|
*
|
||||||
* @requestField inputName | String | Name of the input to open the dialog of
|
* @requestField ?inputName | String | Name of the input to open the dialog of
|
||||||
|
* @requestField ?inputUuid | String | UUID of the input to open the dialog of
|
||||||
*
|
*
|
||||||
* @requestType OpenInputFiltersDialog
|
* @requestType OpenInputFiltersDialog
|
||||||
* @complexity 1
|
* @complexity 1
|
||||||
@ -120,7 +122,7 @@ RequestResult RequestHandler::OpenInputFiltersDialog(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSourceAutoRelease input = request.ValidateInput("inputName", statusCode, comment);
|
OBSSourceAutoRelease input = request.ValidateInput(statusCode, comment);
|
||||||
if (!input)
|
if (!input)
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -132,7 +134,8 @@ RequestResult RequestHandler::OpenInputFiltersDialog(const Request &request)
|
|||||||
/**
|
/**
|
||||||
* Opens the interact dialog of an input.
|
* Opens the interact dialog of an input.
|
||||||
*
|
*
|
||||||
* @requestField inputName | String | Name of the input to open the dialog of
|
* @requestField ?inputName | String | Name of the input to open the dialog of
|
||||||
|
* @requestField ?inputUuid | String | UUID of the input to open the dialog of
|
||||||
*
|
*
|
||||||
* @requestType OpenInputInteractDialog
|
* @requestType OpenInputInteractDialog
|
||||||
* @complexity 1
|
* @complexity 1
|
||||||
@ -145,7 +148,7 @@ RequestResult RequestHandler::OpenInputInteractDialog(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSourceAutoRelease input = request.ValidateInput("inputName", statusCode, comment);
|
OBSSourceAutoRelease input = request.ValidateInput(statusCode, comment);
|
||||||
if (!input)
|
if (!input)
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
@ -262,7 +265,8 @@ RequestResult RequestHandler::OpenVideoMixProjector(const Request &request)
|
|||||||
*
|
*
|
||||||
* Note: This request serves to provide feature parity with 4.x. It is very likely to be changed/deprecated in a future release.
|
* Note: This request serves to provide feature parity with 4.x. It is very likely to be changed/deprecated in a future release.
|
||||||
*
|
*
|
||||||
* @requestField sourceName | String | Name of the source to open a projector for
|
* @requestField ?sourceName | String | Name of the source to open a projector for
|
||||||
|
* @requestField ?sourceUuid | String | UUID of the source to open a projector for
|
||||||
* @requestField ?monitorIndex | Number | Monitor index, use `GetMonitorList` to obtain index | None | -1: Opens projector in windowed mode
|
* @requestField ?monitorIndex | Number | Monitor index, use `GetMonitorList` to obtain index | None | -1: Opens projector in windowed mode
|
||||||
* @requestField ?projectorGeometry | String | Size/Position data for a windowed projector, in Qt Base64 encoded format. Mutually exclusive with `monitorIndex` | N/A
|
* @requestField ?projectorGeometry | String | Size/Position data for a windowed projector, in Qt Base64 encoded format. Mutually exclusive with `monitorIndex` | N/A
|
||||||
*
|
*
|
||||||
@ -277,7 +281,7 @@ RequestResult RequestHandler::OpenSourceProjector(const Request &request)
|
|||||||
{
|
{
|
||||||
RequestStatus::RequestStatus statusCode;
|
RequestStatus::RequestStatus statusCode;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
OBSSourceAutoRelease source = request.ValidateSource("sourceName", statusCode, comment);
|
OBSSourceAutoRelease source = request.ValidateSource("sourceName", "sourceUuid", statusCode, comment);
|
||||||
if (!source)
|
if (!source)
|
||||||
return RequestResult::Error(statusCode, comment);
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
|
@ -211,28 +211,39 @@ bool Request::ValidateArray(const std::string &keyName, RequestStatus::RequestSt
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
obs_source_t *Request::ValidateSource(const std::string &keyName, RequestStatus::RequestStatus &statusCode,
|
obs_source_t *Request::ValidateSource(const std::string &nameKeyName, const std::string &uuidKeyName, RequestStatus::RequestStatus &statusCode,
|
||||||
std::string &comment) const
|
std::string &comment) const
|
||||||
{
|
{
|
||||||
if (!ValidateString(keyName, statusCode, comment))
|
if (ValidateString(nameKeyName, statusCode, comment)) {
|
||||||
return nullptr;
|
std::string sourceName = RequestData[nameKeyName];
|
||||||
|
|
||||||
std::string sourceName = RequestData[keyName];
|
|
||||||
|
|
||||||
obs_source_t *ret = obs_get_source_by_name(sourceName.c_str());
|
obs_source_t *ret = obs_get_source_by_name(sourceName.c_str());
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
statusCode = RequestStatus::ResourceNotFound;
|
statusCode = RequestStatus::ResourceNotFound;
|
||||||
comment = std::string("No source was found by the name of `") + sourceName + "`.";
|
comment = std::string("No source was found by the name of `") + sourceName + "`.";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
obs_source_t *Request::ValidateScene(const std::string &keyName, RequestStatus::RequestStatus &statusCode, std::string &comment,
|
if (ValidateString(uuidKeyName, statusCode, comment)) {
|
||||||
const ObsWebSocketSceneFilter filter) const
|
std::string sourceUuid = RequestData[uuidKeyName];
|
||||||
|
obs_source_t *ret = obs_get_source_by_uuid(sourceUuid.c_str());
|
||||||
|
if (!ret) {
|
||||||
|
statusCode = RequestStatus::ResourceNotFound;
|
||||||
|
comment = std::string("No source was found by the UUID of `") + sourceUuid + "`.";
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
statusCode = RequestStatus::MissingRequestField;
|
||||||
|
comment = std::string("Your request must contain at least one of the following fields: `") + nameKeyName + "` or `" + uuidKeyName + "`.";
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
obs_source_t *Request::ValidateScene(RequestStatus::RequestStatus &statusCode, std::string &comment, const ObsWebSocketSceneFilter filter) const
|
||||||
{
|
{
|
||||||
obs_source_t *ret = ValidateSource(keyName, statusCode, comment);
|
obs_source_t *ret = ValidateSource("sceneName", "sceneUuid", statusCode, comment);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
@ -259,10 +270,9 @@ obs_source_t *Request::ValidateScene(const std::string &keyName, RequestStatus::
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
obs_scene_t *Request::ValidateScene2(const std::string &keyName, RequestStatus::RequestStatus &statusCode, std::string &comment,
|
obs_scene_t *Request::ValidateScene2(RequestStatus::RequestStatus &statusCode, std::string &comment, const ObsWebSocketSceneFilter filter) const
|
||||||
const ObsWebSocketSceneFilter filter) const
|
|
||||||
{
|
{
|
||||||
OBSSourceAutoRelease sceneSource = ValidateSource(keyName, statusCode, comment);
|
OBSSourceAutoRelease sceneSource = ValidateSource("sceneName", "sceneUuid", statusCode, comment);
|
||||||
if (!sceneSource)
|
if (!sceneSource)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
@ -290,10 +300,9 @@ obs_scene_t *Request::ValidateScene2(const std::string &keyName, RequestStatus::
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
obs_source_t *Request::ValidateInput(const std::string &keyName, RequestStatus::RequestStatus &statusCode,
|
obs_source_t *Request::ValidateInput(RequestStatus::RequestStatus &statusCode, std::string &comment) const
|
||||||
std::string &comment) const
|
|
||||||
{
|
{
|
||||||
obs_source_t *ret = ValidateSource(keyName, statusCode, comment);
|
obs_source_t *ret = ValidateSource("inputName", "inputUuid", statusCode, comment);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
@ -307,47 +316,44 @@ obs_source_t *Request::ValidateInput(const std::string &keyName, RequestStatus::
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
FilterPair Request::ValidateFilter(const std::string &sourceKeyName, const std::string &filterKeyName,
|
FilterPair Request::ValidateFilter(RequestStatus::RequestStatus &statusCode, std::string &comment) const
|
||||||
RequestStatus::RequestStatus &statusCode, std::string &comment) const
|
|
||||||
{
|
{
|
||||||
obs_source_t *source = ValidateSource(sourceKeyName, statusCode, comment);
|
obs_source_t *source = ValidateSource("sourceName", "sourceUuid", statusCode, comment);
|
||||||
if (!source)
|
if (!source)
|
||||||
return FilterPair{source, nullptr};
|
return FilterPair{source, nullptr};
|
||||||
|
|
||||||
if (!ValidateString(filterKeyName, statusCode, comment))
|
if (!ValidateString("filterName", statusCode, comment))
|
||||||
return FilterPair{source, nullptr};
|
return FilterPair{source, nullptr};
|
||||||
|
|
||||||
std::string filterName = RequestData[filterKeyName];
|
std::string filterName = RequestData["filterName"];
|
||||||
|
|
||||||
obs_source_t *filter = obs_source_get_filter_by_name(source, filterName.c_str());
|
obs_source_t *filter = obs_source_get_filter_by_name(source, filterName.c_str());
|
||||||
if (!filter) {
|
if (!filter) {
|
||||||
|
std::string sourceName = obs_source_get_name(source);
|
||||||
statusCode = RequestStatus::ResourceNotFound;
|
statusCode = RequestStatus::ResourceNotFound;
|
||||||
comment = std::string("No filter was found in the source `") + RequestData[sourceKeyName].get<std::string>() +
|
comment = std::string("No filter was found in the source `") + sourceName + "` with the name `" + filterName + "`.";
|
||||||
"` with the name `" + filterName + "`.";
|
|
||||||
return FilterPair{source, nullptr};
|
return FilterPair{source, nullptr};
|
||||||
}
|
}
|
||||||
|
|
||||||
return FilterPair{source, filter};
|
return FilterPair{source, filter};
|
||||||
}
|
}
|
||||||
|
|
||||||
obs_sceneitem_t *Request::ValidateSceneItem(const std::string &sceneKeyName, const std::string &sceneItemIdKeyName,
|
obs_sceneitem_t *Request::ValidateSceneItem(RequestStatus::RequestStatus &statusCode, std::string &comment, const ObsWebSocketSceneFilter filter) const
|
||||||
RequestStatus::RequestStatus &statusCode, std::string &comment,
|
|
||||||
const ObsWebSocketSceneFilter filter) const
|
|
||||||
{
|
{
|
||||||
OBSSceneAutoRelease scene = ValidateScene2(sceneKeyName, statusCode, comment, filter);
|
OBSSceneAutoRelease scene = ValidateScene2(statusCode, comment, filter);
|
||||||
if (!scene)
|
if (!scene)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
if (!ValidateNumber(sceneItemIdKeyName, statusCode, comment, 0))
|
if (!ValidateNumber("sceneItemId", statusCode, comment, 0))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
int64_t sceneItemId = RequestData[sceneItemIdKeyName];
|
int64_t sceneItemId = RequestData["sceneItemId"];
|
||||||
|
|
||||||
OBSSceneItem sceneItem = obs_scene_find_sceneitem_by_id(scene, sceneItemId);
|
OBSSceneItem sceneItem = obs_scene_find_sceneitem_by_id(scene, sceneItemId);
|
||||||
if (!sceneItem) {
|
if (!sceneItem) {
|
||||||
|
std::string sceneName = obs_source_get_name(obs_scene_get_source(scene));
|
||||||
statusCode = RequestStatus::ResourceNotFound;
|
statusCode = RequestStatus::ResourceNotFound;
|
||||||
comment = std::string("No scene items were found in scene `") + RequestData[sceneKeyName].get<std::string>() +
|
comment = std::string("No scene items were found in scene `") + sceneName + "` with the ID `" + std::to_string(sceneItemId) + "`.";
|
||||||
"` with the ID `" + std::to_string(sceneItemId) + "`.";
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,21 +64,13 @@ struct Request {
|
|||||||
const bool allowEmpty = false) const;
|
const bool allowEmpty = false) const;
|
||||||
|
|
||||||
// All return values have incremented refcounts
|
// All return values have incremented refcounts
|
||||||
obs_source_t *ValidateSource(const std::string &keyName, RequestStatus::RequestStatus &statusCode,
|
obs_source_t *ValidateSource(const std::string &nameKeyName, const std::string &uuidKeyName, RequestStatus::RequestStatus &statusCode, std::string &comment) const;
|
||||||
std::string &comment) const;
|
obs_source_t *ValidateScene(RequestStatus::RequestStatus &statusCode, std::string &comment, const ObsWebSocketSceneFilter filter = OBS_WEBSOCKET_SCENE_FILTER_SCENE_ONLY) const;
|
||||||
obs_source_t *ValidateScene(const std::string &keyName, RequestStatus::RequestStatus &statusCode, std::string &comment,
|
obs_scene_t *ValidateScene2(RequestStatus::RequestStatus &statusCode, std::string &comment, const ObsWebSocketSceneFilter filter = OBS_WEBSOCKET_SCENE_FILTER_SCENE_ONLY) const;
|
||||||
const ObsWebSocketSceneFilter filter = OBS_WEBSOCKET_SCENE_FILTER_SCENE_ONLY) const;
|
obs_source_t *ValidateInput(RequestStatus::RequestStatus &statusCode, std::string &comment) const;
|
||||||
obs_scene_t *ValidateScene2(const std::string &keyName, RequestStatus::RequestStatus &statusCode, std::string &comment,
|
FilterPair ValidateFilter(RequestStatus::RequestStatus &statusCode, std::string &comment) const;
|
||||||
const ObsWebSocketSceneFilter filter = OBS_WEBSOCKET_SCENE_FILTER_SCENE_ONLY) const;
|
obs_sceneitem_t *ValidateSceneItem(RequestStatus::RequestStatus &statusCode, std::string &comment, const ObsWebSocketSceneFilter filter = OBS_WEBSOCKET_SCENE_FILTER_SCENE_ONLY) const;
|
||||||
obs_source_t *ValidateInput(const std::string &keyName, RequestStatus::RequestStatus &statusCode,
|
obs_output_t *ValidateOutput(const std::string &keyName, RequestStatus::RequestStatus &statusCode, std::string &comment) const;
|
||||||
std::string &comment) const;
|
|
||||||
FilterPair ValidateFilter(const std::string &sourceKeyName, const std::string &filterKeyName,
|
|
||||||
RequestStatus::RequestStatus &statusCode, std::string &comment) const;
|
|
||||||
obs_sceneitem_t *ValidateSceneItem(const std::string &sceneKeyName, const std::string &sceneItemIdKeyName,
|
|
||||||
RequestStatus::RequestStatus &statusCode, std::string &comment,
|
|
||||||
const ObsWebSocketSceneFilter filter = OBS_WEBSOCKET_SCENE_FILTER_SCENE_ONLY) const;
|
|
||||||
obs_output_t *ValidateOutput(const std::string &keyName, RequestStatus::RequestStatus &statusCode,
|
|
||||||
std::string &comment) const;
|
|
||||||
|
|
||||||
std::string RequestType;
|
std::string RequestType;
|
||||||
bool HasRequestData;
|
bool HasRequestData;
|
||||||
|
Loading…
Reference in New Issue
Block a user