mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
Lots of changes
- Move `SetTBarPosition` to transitions category - Add another check to `SetTBarPosition` so that we dont break the fabric of time with the wrong values - Create `GetTransitionPosition` request in transitions category
This commit is contained in:
parent
93c2dab634
commit
4eb7bed2ff
@ -84,6 +84,8 @@ const QHash<QString, RpcMethodHandler> WSRequestHandler::messageMap {
|
|||||||
{ "SetCurrentTransition", &WSRequestHandler::SetCurrentTransition },
|
{ "SetCurrentTransition", &WSRequestHandler::SetCurrentTransition },
|
||||||
{ "SetTransitionDuration", &WSRequestHandler::SetTransitionDuration },
|
{ "SetTransitionDuration", &WSRequestHandler::SetTransitionDuration },
|
||||||
{ "GetTransitionDuration", &WSRequestHandler::GetTransitionDuration },
|
{ "GetTransitionDuration", &WSRequestHandler::GetTransitionDuration },
|
||||||
|
{ "SetTBarPosition", &WSRequestHandler::SetTBarPosition },
|
||||||
|
{ "GetTransitionPosition", &WSRequestHandler::GetTransitionPosition },
|
||||||
|
|
||||||
{ "SetVolume", &WSRequestHandler::SetVolume },
|
{ "SetVolume", &WSRequestHandler::SetVolume },
|
||||||
{ "GetVolume", &WSRequestHandler::GetVolume },
|
{ "GetVolume", &WSRequestHandler::GetVolume },
|
||||||
@ -130,7 +132,6 @@ const QHash<QString, RpcMethodHandler> WSRequestHandler::messageMap {
|
|||||||
{ "EnableStudioMode", &WSRequestHandler::EnableStudioMode },
|
{ "EnableStudioMode", &WSRequestHandler::EnableStudioMode },
|
||||||
{ "DisableStudioMode", &WSRequestHandler::DisableStudioMode },
|
{ "DisableStudioMode", &WSRequestHandler::DisableStudioMode },
|
||||||
{ "ToggleStudioMode", &WSRequestHandler::ToggleStudioMode },
|
{ "ToggleStudioMode", &WSRequestHandler::ToggleStudioMode },
|
||||||
{ "SetTBarPosition", &WSRequestHandler::SetTBarPosition },
|
|
||||||
|
|
||||||
{ "SetTextGDIPlusProperties", &WSRequestHandler::SetTextGDIPlusProperties },
|
{ "SetTextGDIPlusProperties", &WSRequestHandler::SetTextGDIPlusProperties },
|
||||||
{ "GetTextGDIPlusProperties", &WSRequestHandler::GetTextGDIPlusProperties },
|
{ "GetTextGDIPlusProperties", &WSRequestHandler::GetTextGDIPlusProperties },
|
||||||
|
@ -99,6 +99,10 @@ class WSRequestHandler {
|
|||||||
RpcResponse GetTransitionList(const RpcRequest&);
|
RpcResponse GetTransitionList(const RpcRequest&);
|
||||||
RpcResponse GetCurrentTransition(const RpcRequest&);
|
RpcResponse GetCurrentTransition(const RpcRequest&);
|
||||||
RpcResponse SetCurrentTransition(const RpcRequest&);
|
RpcResponse SetCurrentTransition(const RpcRequest&);
|
||||||
|
RpcResponse SetTransitionDuration(const RpcRequest&);
|
||||||
|
RpcResponse GetTransitionDuration(const RpcRequest&);
|
||||||
|
RpcResponse SetTBarPosition(const RpcRequest&);
|
||||||
|
RpcResponse GetTransitionPosition(const RpcRequest&);
|
||||||
|
|
||||||
RpcResponse SetVolume(const RpcRequest&);
|
RpcResponse SetVolume(const RpcRequest&);
|
||||||
RpcResponse GetVolume(const RpcRequest&);
|
RpcResponse GetVolume(const RpcRequest&);
|
||||||
@ -138,9 +142,6 @@ class WSRequestHandler {
|
|||||||
RpcResponse SendCaptions(const RpcRequest&);
|
RpcResponse SendCaptions(const RpcRequest&);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
RpcResponse SetTransitionDuration(const RpcRequest&);
|
|
||||||
RpcResponse GetTransitionDuration(const RpcRequest&);
|
|
||||||
|
|
||||||
RpcResponse GetStudioModeStatus(const RpcRequest&);
|
RpcResponse GetStudioModeStatus(const RpcRequest&);
|
||||||
RpcResponse GetPreviewScene(const RpcRequest&);
|
RpcResponse GetPreviewScene(const RpcRequest&);
|
||||||
RpcResponse SetPreviewScene(const RpcRequest&);
|
RpcResponse SetPreviewScene(const RpcRequest&);
|
||||||
@ -148,7 +149,6 @@ class WSRequestHandler {
|
|||||||
RpcResponse EnableStudioMode(const RpcRequest&);
|
RpcResponse EnableStudioMode(const RpcRequest&);
|
||||||
RpcResponse DisableStudioMode(const RpcRequest&);
|
RpcResponse DisableStudioMode(const RpcRequest&);
|
||||||
RpcResponse ToggleStudioMode(const RpcRequest&);
|
RpcResponse ToggleStudioMode(const RpcRequest&);
|
||||||
RpcResponse SetTBarPosition(const RpcRequest&);
|
|
||||||
|
|
||||||
RpcResponse SetTextGDIPlusProperties(const RpcRequest&);
|
RpcResponse SetTextGDIPlusProperties(const RpcRequest&);
|
||||||
RpcResponse GetTextGDIPlusProperties(const RpcRequest&);
|
RpcResponse GetTextGDIPlusProperties(const RpcRequest&);
|
||||||
|
@ -177,30 +177,3 @@ RpcResponse WSRequestHandler::ToggleStudioMode(const RpcRequest& request) {
|
|||||||
|
|
||||||
return request.success();
|
return request.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the position of the T-Bar (in Studio Mode) to the specified value. Will return an error if OBS is not in studio mode
|
|
||||||
* or if the current transition doesn't support T-Bar control.
|
|
||||||
*
|
|
||||||
* @param {double} `position` T-Bar position. This value will be clamped between 0.0 and 1.0.
|
|
||||||
*
|
|
||||||
* @api requests
|
|
||||||
* @name SetTBarPosition
|
|
||||||
* @category studio mode
|
|
||||||
* @since 4.8.0
|
|
||||||
*/
|
|
||||||
RpcResponse WSRequestHandler::SetTBarPosition(const RpcRequest& request) {
|
|
||||||
if (!obs_frontend_preview_program_mode_active()) {
|
|
||||||
return request.failed("studio mode not enabled");
|
|
||||||
}
|
|
||||||
|
|
||||||
OBSSourceAutoRelease currentTransition = obs_frontend_get_current_transition();
|
|
||||||
if (obs_transition_fixed(currentTransition)) {
|
|
||||||
return request.failed("current transition doesn't support t-bar control");
|
|
||||||
}
|
|
||||||
|
|
||||||
double position = obs_data_get_double(request.parameters(), "position");
|
|
||||||
obs_transition_set_manual_time(currentTransition, position);
|
|
||||||
|
|
||||||
return request.success();
|
|
||||||
}
|
|
||||||
|
@ -120,3 +120,53 @@ RpcResponse WSRequestHandler::GetTransitionDuration(const RpcRequest& request) {
|
|||||||
obs_data_set_int(response, "transition-duration", obs_frontend_get_transition_duration());
|
obs_data_set_int(response, "transition-duration", obs_frontend_get_transition_duration());
|
||||||
return request.success(response);
|
return request.success(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the manual position of the T-Bar (in Studio Mode) to the specified value. Will return an error if OBS is not in studio mode
|
||||||
|
* or if the current transition doesn't support T-Bar control.
|
||||||
|
*
|
||||||
|
* @param {double} `position` T-Bar position. This value must be between 0.0 and 1.0.
|
||||||
|
*
|
||||||
|
* @api requests
|
||||||
|
* @name SetTBarPosition
|
||||||
|
* @category transitions
|
||||||
|
* @since 4.8.0
|
||||||
|
*/
|
||||||
|
RpcResponse WSRequestHandler::SetTBarPosition(const RpcRequest& request) {
|
||||||
|
if (!obs_frontend_preview_program_mode_active()) {
|
||||||
|
return request.failed("studio mode not enabled");
|
||||||
|
}
|
||||||
|
|
||||||
|
OBSSourceAutoRelease currentTransition = obs_frontend_get_current_transition();
|
||||||
|
if (obs_transition_fixed(currentTransition)) {
|
||||||
|
return request.failed("current transition doesn't support t-bar control");
|
||||||
|
}
|
||||||
|
|
||||||
|
double position = obs_data_get_double(request.parameters(), "position");
|
||||||
|
if (position < 0.0 || position > 1.0) {
|
||||||
|
return request.failed("position is out of range");
|
||||||
|
}
|
||||||
|
|
||||||
|
obs_transition_set_manual_time(currentTransition, position);
|
||||||
|
|
||||||
|
return request.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the position of the current transition.
|
||||||
|
*
|
||||||
|
* @return {double} `position` current transition position. This value will be between 0.0 and 1.0. Note: Transition returns 1.0 when not active.
|
||||||
|
*
|
||||||
|
* @api requests
|
||||||
|
* @name GetTransitionPosition
|
||||||
|
* @category transitions
|
||||||
|
* @since 4.8.0
|
||||||
|
*/
|
||||||
|
RpcResponse WSRequestHandler::GetTransitionPosition(const RpcRequest& request) {
|
||||||
|
OBSSourceAutoRelease currentTransition = obs_frontend_get_current_transition();
|
||||||
|
|
||||||
|
OBSDataAutoRelease response = obs_data_create();
|
||||||
|
obs_data_set_double(response, "position", obs_transition_get_time(currentTransition));
|
||||||
|
|
||||||
|
return request.success(response);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user