-
-
Notifications
You must be signed in to change notification settings - Fork 713
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Requests: Add Deinterlacing Functionality #1192
base: master
Are you sure you want to change the base?
Requests: Add Deinterlacing Functionality #1192
Conversation
Added GetSourceDeinterlaceMode, SetSourceDeinterlaceMode, GetSourceDeinterlaceFieldOrder, SetSourceDeinterlaceFieldOrder
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look, I am not an OBS maintainer, but you mentioned you are desperate for some feedback, so I decided to donate some of my time to your cause.
I think a good first step for you to get this PR back in motion is to switch to using NLOHMANN_JSON_SERIALIZE_ENUM
, so that your contributions conform with what already exists
case OBS_DEINTERLACE_MODE_DISABLE: | ||
responseData["sourceDeinterlaceMode"] = "OBS_DEINTERLACE_MODE_DISABLE"; | ||
break; | ||
case OBS_DEINTERLACE_MODE_DISCARD: | ||
responseData["sourceDeinterlaceMode"] = "OBS_DEINTERLACE_MODE_DISCARD"; | ||
break; | ||
case OBS_DEINTERLACE_MODE_RETRO: | ||
responseData["sourceDeinterlaceMode"] = "OBS_DEINTERLACE_MODE_RETRO"; | ||
break; | ||
case OBS_DEINTERLACE_MODE_BLEND: | ||
responseData["sourceDeinterlaceMode"] = "OBS_DEINTERLACE_MODE_BLEND"; | ||
break; | ||
case OBS_DEINTERLACE_MODE_BLEND_2X: | ||
responseData["sourceDeinterlaceMode"] = "OBS_DEINTERLACE_MODE_BLEND_2X"; | ||
break; | ||
case OBS_DEINTERLACE_MODE_LINEAR: | ||
responseData["sourceDeinterlaceMode"] = "OBS_DEINTERLACE_MODE_LINEAR"; | ||
break; | ||
case OBS_DEINTERLACE_MODE_LINEAR_2X: | ||
responseData["sourceDeinterlaceMode"] = "OBS_DEINTERLACE_MODE_LINEAR_2X"; | ||
break; | ||
case OBS_DEINTERLACE_MODE_YADIF: | ||
responseData["sourceDeinterlaceMode"] = "OBS_DEINTERLACE_MODE_YADIF"; | ||
break; | ||
case OBS_DEINTERLACE_MODE_YADIF_2X: | ||
responseData["sourceDeinterlaceMode"] = "OBS_DEINTERLACE_MODE_YADIF_2X"; | ||
break; | ||
default: | ||
responseData["sourceDeinterlaceMode"] = "OBS_DEINTERLACE_MODE_DISABLE"; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAICT, hardcoding these outputs with a switch is an anti-pattern.
Previous contributions all use the NLOHMANN_JSON_SERIALIZE_ENUM
macro.
For example, take a look at RequestHandler::GetMediaInputStatus
.
Specifically, these lines:
json responseData;
responseData["mediaState"] = obs_source_media_get_state(input);
obs_source_media_get_state
returns enum obs_media_state
not a string.
I suggest you follow the same pattern, if you want this to be merged.
See obs-studio\plugins\obs-websocket\src\utils\Json.h
. This seems to be the place where this syntactic sugar is setup.
For example:
NLOHMANN_JSON_SERIALIZE_ENUM(obs_media_state, {
{OBS_MEDIA_STATE_NONE, "OBS_MEDIA_STATE_NONE"},
{OBS_MEDIA_STATE_PLAYING, "OBS_MEDIA_STATE_PLAYING"},
{OBS_MEDIA_STATE_OPENING, "OBS_MEDIA_STATE_OPENING"},
{OBS_MEDIA_STATE_BUFFERING, "OBS_MEDIA_STATE_BUFFERING"},
{OBS_MEDIA_STATE_PAUSED, "OBS_MEDIA_STATE_PAUSED"},
{OBS_MEDIA_STATE_STOPPED, "OBS_MEDIA_STATE_STOPPED"},
{OBS_MEDIA_STATE_ENDED, "OBS_MEDIA_STATE_ENDED"},
{OBS_MEDIA_STATE_ERROR, "OBS_MEDIA_STATE_ERROR"},
})
if (sourceDeinterlaceModeString == "OBS_DEINTERLACE_MODE_DISABLE") { | ||
deinterlaceMode = OBS_DEINTERLACE_MODE_DISABLE; | ||
} else if (sourceDeinterlaceModeString == "OBS_DEINTERLACE_MODE_DISCARD") { | ||
deinterlaceMode = OBS_DEINTERLACE_MODE_DISCARD; | ||
} else if (sourceDeinterlaceModeString == "OBS_DEINTERLACE_MODE_RETRO") { | ||
deinterlaceMode = OBS_DEINTERLACE_MODE_RETRO; | ||
} else if (sourceDeinterlaceModeString == "OBS_DEINTERLACE_MODE_BLEND") { | ||
deinterlaceMode = OBS_DEINTERLACE_MODE_BLEND; | ||
} else if (sourceDeinterlaceModeString == "OBS_DEINTERLACE_MODE_BLEND_2X") { | ||
deinterlaceMode = OBS_DEINTERLACE_MODE_BLEND_2X; | ||
} else if (sourceDeinterlaceModeString == "OBS_DEINTERLACE_MODE_LINEAR") { | ||
deinterlaceMode = OBS_DEINTERLACE_MODE_LINEAR; | ||
} else if (sourceDeinterlaceModeString == "OBS_DEINTERLACE_MODE_LINEAR_2X") { | ||
deinterlaceMode = OBS_DEINTERLACE_MODE_LINEAR_2X; | ||
} else if (sourceDeinterlaceModeString == "OBS_DEINTERLACE_MODE_YADIF") { | ||
deinterlaceMode = OBS_DEINTERLACE_MODE_YADIF; | ||
} else if (sourceDeinterlaceModeString == "OBS_DEINTERLACE_MODE_YADIF_2X") { | ||
deinterlaceMode = OBS_DEINTERLACE_MODE_YADIF_2X; | ||
} else { | ||
return RequestResult::Error(RequestStatus::InvalidRequestField, | ||
"Your specified deinterlace mode is invalid or not supported by this system."); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto here. This can all be replaced by taking advantage of the NLOHMANN_JSON_SERIALIZE_ENUM
macro. Possibly there is other setup required for it to work, too, but you can find that out by trying it out yourself
Description
Added GetSourceDeinterlaceMode, SetSourceDeinterlaceMode, GetSourceDeinterlaceFieldOrder, SetSourceDeinterlaceFieldOrder
Motivation and Context
There's currently no way to get/set the deinterlacing settings on a source. I needed the ability to enable deinterlacing via websockets for an automation project.
This PR addresses #1183
How Has This Been Tested?
I built the plugin with the latest release of OBS and tested using postman calls.
Tested OS(s):
Types of changes
Checklist:
master
or arelease/*
branch.