Skip to content

Commit 4050e25

Browse files
authored
Merge pull request #1657 from streamlabs/mh-clear-key-on-service-change
Clear stream key on service change
2 parents 01c18f4 + c01d0db commit 4050e25

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

obs-studio-server/source/nodeobs_settings.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,9 @@ bool OBS_settings::saveStreamSettings(std::vector<SubCategory> streamSettings, S
820820
std::string currentServiceName = obs_data_get_string(obs_service_get_settings(currentService), "service");
821821
std::string newServiceValue;
822822

823+
//get existing key to compare with new key later - if service is changed we will clear the key since keys don't carry over between services
824+
const char *currentKey = obs_service_get_connect_info(currentService, OBS_SERVICE_CONNECT_INFO_STREAM_KEY);
825+
823826
SubCategory sc;
824827
bool serviceChanged = false;
825828
bool serviceSettingsInvalid = false;
@@ -928,6 +931,14 @@ bool OBS_settings::saveStreamSettings(std::vector<SubCategory> streamSettings, S
928931
obs_data_set_string(settings, "server", defaultServer.c_str());
929932
obs_service_update(newService, settings);
930933
}
934+
935+
//if service changed but key didn't we also need to clear out the key since services don't share keys
936+
const char *newKey = obs_data_get_string(settings, "key");
937+
if (currentKey != nullptr && newKey != nullptr && strcmp(currentKey, newKey) == 0) {
938+
blog(LOG_INFO, "MLH clearing stream key since service was changed and key wasn't");
939+
obs_data_set_string(settings, "key", "");
940+
obs_service_update(newService, settings);
941+
}
931942
}
932943

933944
obs_data_release(hotkeyData);

0 commit comments

Comments
 (0)