mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
Utils: Add GetSceneItemTransform
This commit is contained in:
parent
96dcc49adb
commit
3d2fb65357
@ -119,6 +119,20 @@ std::string Utils::Obs::StringHelper::GetLastReplayBufferFilePath()
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string Utils::Obs::StringHelper::GetSceneItemBoundsTypeString(enum obs_bounds_type type)
|
||||
{
|
||||
switch (type) {
|
||||
default:
|
||||
CASE(OBS_BOUNDS_NONE)
|
||||
CASE(OBS_BOUNDS_STRETCH)
|
||||
CASE(OBS_BOUNDS_SCALE_INNER)
|
||||
CASE(OBS_BOUNDS_SCALE_OUTER)
|
||||
CASE(OBS_BOUNDS_SCALE_TO_WIDTH)
|
||||
CASE(OBS_BOUNDS_SCALE_TO_HEIGHT)
|
||||
CASE(OBS_BOUNDS_MAX_ONLY)
|
||||
}
|
||||
}
|
||||
|
||||
std::string Utils::Obs::StringHelper::GetOutputTimecodeString(obs_output_t *output)
|
||||
{
|
||||
if (!output || !obs_output_active(output))
|
||||
@ -364,6 +378,45 @@ json Utils::Obs::DataHelper::GetStats()
|
||||
return ret;
|
||||
}
|
||||
|
||||
json Utils::Obs::DataHelper::GetSceneItemTransform(obs_sceneitem_t *item)
|
||||
{
|
||||
json ret;
|
||||
|
||||
obs_transform_info osi;
|
||||
obs_sceneitem_crop crop;
|
||||
obs_sceneitem_get_info(item, &osi);
|
||||
obs_sceneitem_get_crop(item, &crop);
|
||||
|
||||
OBSSource source = obs_sceneitem_get_source(item);
|
||||
float sourceWidth = float(obs_source_get_width(source));
|
||||
float sourceHeight = float(obs_source_get_height(source));
|
||||
|
||||
ret["sourceWidth"] = sourceWidth;
|
||||
ret["sourceHeight"] = sourceHeight;
|
||||
|
||||
ret["positionX"] = osi.pos.x;
|
||||
ret["positionY"] = osi.pos.y;
|
||||
|
||||
ret["rotation"] = osi.rot;
|
||||
|
||||
ret["width"] = osi.scale.x * sourceWidth;
|
||||
ret["height"] = osi.scale.y * sourceHeight;
|
||||
|
||||
ret["alignment"] = osi.alignment;
|
||||
|
||||
ret["boundsType"] = StringHelper::GetSceneItemBoundsTypeString(osi.bounds_type);
|
||||
ret["boundsAlignment"] = osi.bounds_alignment;
|
||||
ret["boundsWidth"] = osi.bounds.x;
|
||||
ret["boundsHeight"] = osi.bounds.y;
|
||||
|
||||
ret["cropLeft"] = int(crop.left);
|
||||
ret["cropRight"] = int(crop.right);
|
||||
ret["cropTop"] = int(crop.top);
|
||||
ret["cropBottom"] = int(crop.bottom);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
obs_hotkey_t *Utils::Obs::SearchHelper::GetHotkeyByName(std::string name)
|
||||
{
|
||||
auto hotkeys = ListHelper::GetHotkeyList();
|
||||
|
@ -35,6 +35,7 @@ namespace Utils {
|
||||
std::string GetInputMonitorTypeString(obs_source_t *input);
|
||||
std::string GetMediaInputStateString(obs_source_t *input);
|
||||
std::string GetLastReplayBufferFilePath();
|
||||
std::string GetSceneItemBoundsTypeString(enum obs_bounds_type type);
|
||||
std::string GetOutputTimecodeString(obs_output_t *output);
|
||||
}
|
||||
|
||||
@ -57,6 +58,7 @@ namespace Utils {
|
||||
|
||||
namespace DataHelper {
|
||||
json GetStats();
|
||||
json GetSceneItemTransform(obs_sceneitem_t *item);
|
||||
}
|
||||
|
||||
namespace SearchHelper {
|
||||
|
Loading…
Reference in New Issue
Block a user