requesthandler: Add GetSpecialInputs

This commit is contained in:
tt2468 2021-12-31 16:49:18 -08:00
parent c0308d6ce1
commit 24e43d0276
3 changed files with 39 additions and 0 deletions

View File

@ -71,6 +71,7 @@ const std::unordered_map<std::string, RequestMethodHandler> RequestHandler::_han
// Inputs // Inputs
{"GetInputList", &RequestHandler::GetInputList}, {"GetInputList", &RequestHandler::GetInputList},
{"GetInputKindList", &RequestHandler::GetInputKindList}, {"GetInputKindList", &RequestHandler::GetInputKindList},
{"GetSpecialInputs", &RequestHandler::GetSpecialInputs},
{"CreateInput", &RequestHandler::CreateInput}, {"CreateInput", &RequestHandler::CreateInput},
{"RemoveInput", &RequestHandler::RemoveInput}, {"RemoveInput", &RequestHandler::RemoveInput},
{"SetInputName", &RequestHandler::SetInputName}, {"SetInputName", &RequestHandler::SetInputName},

View File

@ -89,6 +89,7 @@ class RequestHandler {
// Inputs // Inputs
RequestResult GetInputList(const Request&); RequestResult GetInputList(const Request&);
RequestResult GetInputKindList(const Request&); RequestResult GetInputKindList(const Request&);
RequestResult GetSpecialInputs(const Request&);
RequestResult CreateInput(const Request&); RequestResult CreateInput(const Request&);
RequestResult RemoveInput(const Request&); RequestResult RemoveInput(const Request&);
RequestResult SetInputName(const Request&); RequestResult SetInputName(const Request&);

View File

@ -83,6 +83,43 @@ RequestResult RequestHandler::GetInputKindList(const Request& request)
return RequestResult::Success(responseData); return RequestResult::Success(responseData);
} }
/**
* Gets the names of all special inputs.
*
* @responseField desktop1 | String | Name of the Desktop Audio input
* @responseField desktop2 | String | Name of the Desktop Audio 2 input
* @responseField mic1 | String | Name of the Mic/Auxiliary Audio input
* @responseField mic2 | String | Name of the Mic/Auxiliary Audio 2 input
* @responseField mic3 | String | Name of the Mic/Auxiliary Audio 3 input
* @responseField mic4 | String | Name of the Mic/Auxiliary Audio 4 input
*
* @requestType GetSpecialInputs
* @complexity 2
* @rpcVersion -1
* @initialVersion 5.0.0
* @api requests
* @category inputs
*/
RequestResult RequestHandler::GetSpecialInputs(const Request&)
{
json responseData;
std::vector<std::string> channels = {"desktop1", "desktop2", "mic1", "mic2", "mic3", "mic4"};
size_t channelId = 1;
for (auto &channel : channels) {
OBSSourceAutoRelease input = obs_get_output_source(channelId);
if (!input)
responseData[channel] = nullptr;
else
responseData[channel] = obs_source_get_name(input);
channelId++;
}
return RequestResult::Success(responseData);
}
/** /**
* 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.
* *