提交 be8ddc06 编写于 作者: J jp9000

rtmp-services: Ensure set URL exists within server list

If the user had a valid service selected, but the server that the user
originally was using is now (for whatever reason) no longer listed, the
rtmp-common service would still use that server rather than any of the
newer servers, and the user would have to physically go in to their
settings to reconfigure to get it to use that new server.

Instead, make sure that the server the user has selected exists within
the server list, and if it doesn't, use the first server in the list
instead by default.
上级 a17c2822
......@@ -26,6 +26,37 @@ static inline const char *get_string_val(json_t *service, const char *key);
extern void twitch_ingests_refresh(int seconds);
static void ensure_valid_url(struct rtmp_common *service, json_t *json,
obs_data_t *settings)
{
json_t *servers = json_object_get(json, "servers");
const char *top_url = NULL;
json_t *server;
size_t index;
if (!service->server || !servers || !json_is_array(servers))
return;
json_array_foreach (servers, index, server) {
const char *url = get_string_val(server, "url");
if (!url)
continue;
if (!top_url)
top_url = url;
if (astrcmpi(service->server, url) == 0)
return;
}
/* server was not found in server list, use first server instead */
if (top_url) {
bfree(service->server);
service->server = bstrdup(top_url);
obs_data_set_string(settings, "server", top_url);
}
}
static void rtmp_common_update(void *data, obs_data_t *settings)
{
struct rtmp_common *service = data;
......@@ -50,6 +81,8 @@ static void rtmp_common_update(void *data, obs_data_t *settings)
if (out)
service->output = bstrdup(out);
}
ensure_valid_url(service, serv, settings);
}
}
json_decref(root);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册