UI: Handle mac-vth264 encoder ID change

Before OBS Studio 27, we used our own hard-coded internal encoder IDs on
for the mac-vth264 plugin: vt_h264_hw and vt_h264_sw. As of OBS Studio
27, we changed to using the encoder IDs that Apple's API reports.
Specifically, this behavior occurs due to PR #4105 and commit
6a9f25c8ea1b244b4a439667be33f4a5cc6cdf4b.

Unfortunately, this change in encoder IDs failed to take into account
existing user configurations, resulting in users with broken encoder
settings. This change attempts to gracefully upgrade user configurations
to handle the changed encoder IDs.

Fixes #4799.
This commit is contained in:
Ryan Foster 2021-06-09 19:33:59 -04:00 committed by Jim
parent 5998f4cc4d
commit e0edd753ad

View File

@ -1188,6 +1188,17 @@ static void ApplyEncoderDefaults(OBSData &settings,
#define ADV_ARCHIVE_NAME "adv_archive_aac"
#ifdef __APPLE__
static void translate_macvth264_encoder(const char *&encoder)
{
if (strcmp(encoder, "vt_h264_hw") == 0) {
encoder = "com.apple.videotoolbox.videoencoder.h264.gva";
} else if (strcmp(encoder, "vt_h264_sw") == 0) {
encoder = "com.apple.videotoolbox.videoencoder.h264";
}
}
#endif
AdvancedOutput::AdvancedOutput(OBSBasic *main_) : BasicOutputHandler(main_)
{
const char *recType =
@ -1196,6 +1207,10 @@ AdvancedOutput::AdvancedOutput(OBSBasic *main_) : BasicOutputHandler(main_)
config_get_string(main->Config(), "AdvOut", "Encoder");
const char *recordEncoder =
config_get_string(main->Config(), "AdvOut", "RecEncoder");
#ifdef __APPLE__
translate_macvth264_encoder(streamEncoder);
translate_macvth264_encoder(recordEncoder);
#endif
ffmpegOutput = astrcmpi(recType, "FFmpeg") == 0;
ffmpegRecording =