mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
RequestHandler: Add audio balance requests
This commit is contained in:
parent
1ed095de48
commit
9113ff9021
@ -77,6 +77,8 @@ const std::map<std::string, RequestMethodHandler> RequestHandler::_handlerMap
|
||||
{"ToggleInputMute", &RequestHandler::ToggleInputMute},
|
||||
{"GetInputVolume", &RequestHandler::GetInputVolume},
|
||||
{"SetInputVolume", &RequestHandler::SetInputVolume},
|
||||
{"GetInputAudioBalance", &RequestHandler::GetInputAudioBalance},
|
||||
{"SetInputAudioBalance", &RequestHandler::SetInputAudioBalance},
|
||||
{"GetInputAudioSyncOffset", &RequestHandler::GetInputAudioSyncOffset},
|
||||
{"SetInputAudioSyncOffset", &RequestHandler::SetInputAudioSyncOffset},
|
||||
{"GetInputAudioMonitorType", &RequestHandler::GetInputAudioMonitorType},
|
||||
|
@ -99,6 +99,8 @@ class RequestHandler {
|
||||
RequestResult ToggleInputMute(const Request&);
|
||||
RequestResult GetInputVolume(const Request&);
|
||||
RequestResult SetInputVolume(const Request&);
|
||||
RequestResult GetInputAudioBalance(const Request&);
|
||||
RequestResult SetInputAudioBalance(const Request&);
|
||||
RequestResult GetInputAudioSyncOffset(const Request&);
|
||||
RequestResult SetInputAudioSyncOffset(const Request&);
|
||||
RequestResult GetInputAudioMonitorType(const Request&);
|
||||
|
@ -488,6 +488,61 @@ RequestResult RequestHandler::SetInputVolume(const Request& request)
|
||||
return RequestResult::Success();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the audio balance of an input.
|
||||
*
|
||||
* @requestField inputName | String | Name of the input to get the audio balance of
|
||||
*
|
||||
* @responseField inputAudioBalance | Number | Audio balance value from 0.0-1.0
|
||||
*
|
||||
* @requestType GetInputAudioBalance
|
||||
* @complexity 2
|
||||
* @rpcVersion -1
|
||||
* @initialVersion 5.0.0
|
||||
* @api requests
|
||||
* @category inputs
|
||||
*/
|
||||
RequestResult RequestHandler::GetInputAudioBalance(const Request& request)
|
||||
{
|
||||
RequestStatus::RequestStatus statusCode;
|
||||
std::string comment;
|
||||
OBSSourceAutoRelease input = request.ValidateInput("inputName", statusCode, comment);
|
||||
if (!input)
|
||||
return RequestResult::Error(statusCode, comment);
|
||||
|
||||
json responseData;
|
||||
responseData["inputAudioBalance"] = obs_source_get_balance_value(input);
|
||||
|
||||
return RequestResult::Success(responseData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the audio balance of an input.
|
||||
*
|
||||
* @requestField inputName | String | Name of the input to set the audio balance of
|
||||
* @requestField inputAudioBalance | Number | New audio balance value | >= 0.0, <= 1.0
|
||||
*
|
||||
* @requestType SetInputAudioBalance
|
||||
* @complexity 2
|
||||
* @rpcVersion -1
|
||||
* @initialVersion 5.0.0
|
||||
* @api requests
|
||||
* @category inputs
|
||||
*/
|
||||
RequestResult RequestHandler::SetInputAudioBalance(const Request& request)
|
||||
{
|
||||
RequestStatus::RequestStatus statusCode;
|
||||
std::string comment;
|
||||
OBSSourceAutoRelease input = request.ValidateInput("inputName", statusCode, comment);
|
||||
if (!(input && request.ValidateNumber("inputAudioBalance", statusCode, comment, 0.0, 1.0)))
|
||||
return RequestResult::Error(statusCode, comment);
|
||||
|
||||
float inputAudioBalance = request.RequestData["inputAudioBalance"];
|
||||
obs_source_set_balance_value(input, inputAudioBalance);
|
||||
|
||||
return RequestResult::Success();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the audio sync offset of an input.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user