UI: Use connect infos check in before stream check

Ask the service directly rather than checking the presence of a key and
a URL.
This commit is contained in:
tytan652 2023-01-19 16:08:58 +01:00
parent d917ceafe8
commit 215426b65b

View File

@ -59,26 +59,24 @@ bool UIValidation::NoSourcesConfirmation(QWidget *parent)
StreamSettingsAction
UIValidation::StreamSettingsConfirmation(QWidget *parent, OBSService service)
{
// Custom services can user API key in URL or user/pass combo.
// So only check there is a URL
char const *serviceType = obs_service_get_type(service);
bool isCustomUrlService = (strcmp(serviceType, "rtmp_custom") == 0);
char const *streamUrl = obs_service_get_url(service);
char const *streamKey = obs_service_get_key(service);
bool hasStreamUrl = (streamUrl != NULL && streamUrl[0] != '\0');
bool hasStreamKey = ((streamKey != NULL && streamKey[0] != '\0') ||
isCustomUrlService);
if (hasStreamUrl && hasStreamKey)
if (obs_service_can_try_to_connect(service))
return StreamSettingsAction::ContinueStream;
QString msg;
char const *serviceType = obs_service_get_type(service);
bool isCustomService = (strcmp(serviceType, "rtmp_custom") == 0);
if (!hasStreamUrl && !hasStreamKey) {
char const *streamUrl = obs_service_get_connect_info(
service, OBS_SERVICE_CONNECT_INFO_SERVER_URL);
char const *streamKey = obs_service_get_connect_info(
service, OBS_SERVICE_CONNECT_INFO_STREAM_KEY);
bool streamUrlMissing = !(streamUrl != NULL && streamUrl[0] != '\0');
bool streamKeyMissing = !(streamKey != NULL && streamKey[0] != '\0');
QString msg;
if (!isCustomService && streamUrlMissing && streamKeyMissing) {
msg = QTStr("Basic.Settings.Stream.MissingUrlAndApiKey");
} else if (!hasStreamKey) {
} else if (!isCustomService && streamKeyMissing) {
msg = QTStr("Basic.Settings.Stream.MissingStreamKey");
} else {
msg = QTStr("Basic.Settings.Stream.MissingUrl");