@@ -72,6 +72,8 @@ void OBS_settings::Register(ipc::server &srv)
7272 cls->register_function (std::make_shared<ipc::function>(
7373 " OBS_settings_saveSettings" , std::vector<ipc::type>{ipc::type::String, ipc::type::UInt32, ipc::type::UInt32, ipc::type::Binary},
7474 OBS_settings_saveSettings));
75+ cls->register_function (
76+ std::make_shared<ipc::function>(" OBS_settings_isValidEncoder" , std::vector<ipc::type>{}, OBS_settings_isValidEncoder));
7577 cls->register_function (
7678 std::make_shared<ipc::function>(" OBS_settings_getInputAudioDevices" , std::vector<ipc::type>{}, OBS_settings_getInputAudioDevices));
7779 cls->register_function (
@@ -1196,6 +1198,61 @@ static void converOldJimNvencEncoder(config_t *config, const std::string &config
11961198 }
11971199}
11981200
1201+ static bool validateEncoderForService (StreamServiceId serviceId, const char *encoderToFind)
1202+ {
1203+ bool validEncoder = false ;
1204+
1205+ // have encoder - find in encoders_set, validate 'streaming' flag and check availability based on 'check_availability_streaming' flag
1206+ for (int i = 0 ; i < encoders_set.size (); i++) {
1207+ if (std::string (encoderToFind) == encoders_set[i].simple_name || std::string (encoderToFind) == encoders_set[i].advanced_name ) {
1208+ if (encoders_set[i].streaming ) {
1209+ if (encoders_set[i].check_availability_streaming ) {
1210+ if (isEncoderAvailableForStreaming (encoderToFind, OBS_service::getService (serviceId))) {
1211+ validEncoder = true ;
1212+ break ;
1213+ }
1214+ } else {
1215+ validEncoder = true ;
1216+ }
1217+ }
1218+ break ;
1219+ }
1220+ }
1221+
1222+ return validEncoder;
1223+ }
1224+
1225+ void OBS_settings::OBS_settings_isValidEncoder (void *data, const int64_t id, const std::vector<ipc::value> &args, std::vector<ipc::value> &rval)
1226+ {
1227+ const char *mode = NULL ;
1228+ const char *curEncoder = NULL ;
1229+ bool validEncoder = false ;
1230+ std::string serviceToCheck = args[0 ].value_str ;
1231+
1232+ // get mode and configured encoder
1233+ mode = config_get_string (ConfigManager::getInstance ().getBasic (), " Output" , " Mode" );
1234+ if (mode == NULL ) {
1235+ mode = " Simple" ;
1236+ }
1237+ if (strcmp (mode, " Advanced" ) == 0 ) {
1238+ curEncoder = config_get_string (ConfigManager::getInstance ().getBasic (), " AdvOut" , " Encoder" );
1239+ } else {
1240+ curEncoder = config_get_string (ConfigManager::getInstance ().getBasic (), " SimpleOutput" , " StreamingEncoder" );
1241+ }
1242+
1243+ if (serviceToCheck == " Both" ) {
1244+ validEncoder = validateEncoderForService (StreamServiceId::Main, curEncoder) && validateEncoderForService (StreamServiceId::Second, curEncoder);
1245+ } else if (serviceToCheck == " Stream" ) {
1246+ validEncoder = validateEncoderForService (StreamServiceId::Main, curEncoder);
1247+ } else if (serviceToCheck == " StreamSecond" ) {
1248+ validEncoder = validateEncoderForService (StreamServiceId::Second, curEncoder);
1249+ }
1250+
1251+ rval.push_back (ipc::value ((uint64_t )ErrorCode::Ok));
1252+ rval.push_back (ipc::value (validEncoder));
1253+ }
1254+
1255+
11991256void OBS_settings::getSimpleOutputSettings (std::vector<SubCategory> *outputSettings, config_t *config, bool isCategoryEnabled)
12001257{
12011258 converOldJimNvencEncoder (config, " SimpleOutput" , " StreamEncoder" , " RecEncoder" );
0 commit comments