clang-format: Increase column limit from 80 to 120

This commit is contained in:
Ryan Foster
2024-10-04 17:33:58 -04:00
parent 109f64c446
commit a1fbf1015f
736 changed files with 22684 additions and 45435 deletions
+58 -115
View File
@@ -34,8 +34,7 @@ static const char *rtmp_common_getname(void *unused)
}
static json_t *open_services_file(void);
static inline json_t *find_service(json_t *root, const char *name,
const char **p_new_name);
static inline json_t *find_service(json_t *root, const char *name, const char **p_new_name);
static inline bool get_bool_val(json_t *service, const char *key);
static inline const char *get_string_val(json_t *service, const char *key);
static inline int get_int_val(json_t *service, const char *key);
@@ -43,8 +42,7 @@ static inline int get_int_val(json_t *service, const char *key);
extern void twitch_ingests_refresh(int seconds);
extern void amazon_ivs_ingests_refresh(int seconds);
static void ensure_valid_url(struct rtmp_common *service, json_t *json,
obs_data_t *settings)
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;
@@ -171,11 +169,9 @@ static void rtmp_common_update(void *data, obs_data_t *settings)
service->service = bstrdup(new_name);
}
if ((service->protocol == NULL ||
service->protocol[0] == '\0')) {
if ((service->protocol == NULL || service->protocol[0] == '\0')) {
bfree(service->protocol);
service->protocol =
bstrdup(get_protocol(serv, settings));
service->protocol = bstrdup(get_protocol(serv, settings));
}
if (serv) {
@@ -186,8 +182,8 @@ static void rtmp_common_update(void *data, obs_data_t *settings)
update_recommendations(service, rec);
}
service->supports_additional_audio_track = get_bool_val(
serv, "supports_additional_audio_track");
service->supports_additional_audio_track =
get_bool_val(serv, "supports_additional_audio_track");
ensure_valid_url(service, serv, settings);
}
}
@@ -272,8 +268,7 @@ static bool is_protocol_available(json_t *service)
return ret;
}
static void add_service(obs_property_t *list, json_t *service, bool show_all,
const char *cur_service)
static void add_service(obs_property_t *list, json_t *service, bool show_all, const char *cur_service)
{
json_t *servers;
const char *name;
@@ -309,8 +304,7 @@ static void add_service(obs_property_t *list, json_t *service, bool show_all,
obs_property_list_add_string(list, name, name);
}
static void add_services(obs_property_t *list, json_t *root, bool show_all,
const char *cur_service)
static void add_services(obs_property_t *list, json_t *root, bool show_all, const char *cur_service)
{
json_t *service;
size_t index;
@@ -330,8 +324,7 @@ static void add_services(obs_property_t *list, json_t *root, bool show_all,
service = find_service(root, cur_service, NULL);
if (!service && cur_service && *cur_service) {
obs_property_list_insert_string(list, 0, cur_service,
cur_service);
obs_property_list_insert_string(list, 0, cur_service, cur_service);
obs_property_list_item_disable(list, 0, true);
}
}
@@ -405,8 +398,7 @@ static json_t *open_services_file(void)
return root;
}
static void build_service_list(obs_property_t *list, json_t *root,
bool show_all, const char *cur_service)
static void build_service_list(obs_property_t *list, json_t *root, bool show_all, const char *cur_service)
{
obs_property_list_clear(list);
add_services(list, root, show_all, cur_service);
@@ -423,16 +415,14 @@ static bool fill_twitch_servers_locked(obs_property_t *servers_prop)
{
size_t count = twitch_ingest_count();
obs_property_list_add_string(servers_prop,
obs_module_text("Server.Auto"), "auto");
obs_property_list_add_string(servers_prop, obs_module_text("Server.Auto"), "auto");
if (count <= 1)
return false;
for (size_t i = 0; i < count; i++) {
struct ingest twitch_ing = twitch_ingest(i);
obs_property_list_add_string(servers_prop, twitch_ing.name,
twitch_ing.url);
obs_property_list_add_string(servers_prop, twitch_ing.name, twitch_ing.url);
}
return true;
@@ -456,12 +446,9 @@ static bool fill_amazon_ivs_servers_locked(obs_property_t *servers_prop)
bool rtmps_available = obs_is_output_protocol_registered("RTMPS");
if (rtmps_available) {
obs_property_list_add_string(
servers_prop, obs_module_text("Server.AutoRTMPS"),
"auto-rtmps");
obs_property_list_add_string(servers_prop, obs_module_text("Server.AutoRTMPS"), "auto-rtmps");
}
obs_property_list_add_string(
servers_prop, obs_module_text("Server.AutoRTMP"), "auto-rtmp");
obs_property_list_add_string(servers_prop, obs_module_text("Server.AutoRTMP"), "auto-rtmp");
if (count <= 1)
return false;
@@ -469,19 +456,15 @@ static bool fill_amazon_ivs_servers_locked(obs_property_t *servers_prop)
if (rtmps_available) {
for (size_t i = 0; i < count; i++) {
struct ingest amazon_ivs_ing = amazon_ivs_ingest(i);
dstr_printf(&name_buffer, "%s (RTMPS)",
amazon_ivs_ing.name);
obs_property_list_add_string(servers_prop,
name_buffer.array,
amazon_ivs_ing.rtmps_url);
dstr_printf(&name_buffer, "%s (RTMPS)", amazon_ivs_ing.name);
obs_property_list_add_string(servers_prop, name_buffer.array, amazon_ivs_ing.rtmps_url);
}
}
for (size_t i = 0; i < count; i++) {
struct ingest amazon_ivs_ing = amazon_ivs_ingest(i);
dstr_printf(&name_buffer, "%s (RTMP)", amazon_ivs_ing.name);
obs_property_list_add_string(servers_prop, name_buffer.array,
amazon_ivs_ing.url);
obs_property_list_add_string(servers_prop, name_buffer.array, amazon_ivs_ing.url);
}
dstr_free(&name_buffer);
@@ -500,8 +483,7 @@ static inline bool fill_amazon_ivs_servers(obs_property_t *servers_prop)
return success;
}
static void fill_servers(obs_property_t *servers_prop, json_t *service,
const char *name)
static void fill_servers(obs_property_t *servers_prop, json_t *service, const char *name)
{
json_t *servers, *server;
size_t index;
@@ -526,8 +508,7 @@ static void fill_servers(obs_property_t *servers_prop, json_t *service,
/* Assumption: Nimo TV should be RTMP only, so no RTMPS check in the ingest */
if (strcmp(name, "Nimo TV") == 0) {
obs_property_list_add_string(
servers_prop, obs_module_text("Server.Auto"), "auto");
obs_property_list_add_string(servers_prop, obs_module_text("Server.Auto"), "auto");
}
if (strcmp(name, "Amazon IVS") == 0) {
@@ -543,17 +524,14 @@ static void fill_servers(obs_property_t *servers_prop, json_t *service,
continue;
/* Skip RTMPS server if protocol not registered */
if ((!obs_is_output_protocol_registered("RTMPS")) &&
(strncmp(url, "rtmps://", 8) == 0))
if ((!obs_is_output_protocol_registered("RTMPS")) && (strncmp(url, "rtmps://", 8) == 0))
continue;
obs_property_list_add_string(servers_prop, server_name, url);
}
}
static void copy_string_from_json_if_available(json_t *service,
obs_data_t *settings,
const char *name)
static void copy_string_from_json_if_available(json_t *service, obs_data_t *settings, const char *name)
{
const char *string = get_string_val(service, name);
if (string)
@@ -567,8 +545,7 @@ static void fill_more_info_link(json_t *service, obs_data_t *settings)
static void fill_stream_key_link(json_t *service, obs_data_t *settings)
{
copy_string_from_json_if_available(service, settings,
"stream_key_link");
copy_string_from_json_if_available(service, settings, "stream_key_link");
}
static void update_protocol(json_t *service, obs_data_t *settings)
@@ -600,29 +577,22 @@ static void copy_info_to_settings(json_t *service, obs_data_t *settings)
fill_more_info_link(service, settings);
fill_stream_key_link(service, settings);
copy_string_from_json_if_available(
service, settings, "multitrack_video_configuration_url");
copy_string_from_json_if_available(service, settings,
"multitrack_video_name");
copy_string_from_json_if_available(service, settings, "multitrack_video_configuration_url");
copy_string_from_json_if_available(service, settings, "multitrack_video_name");
if (!obs_data_has_user_value(settings, "multitrack_video_name")) {
obs_data_set_string(settings, "multitrack_video_name",
"Multitrack Video");
obs_data_set_string(settings, "multitrack_video_name", "Multitrack Video");
}
const char *learn_more_link_url =
get_string_val(service, "multitrack_video_learn_more_link");
const char *learn_more_link_url = get_string_val(service, "multitrack_video_learn_more_link");
struct dstr learn_more_link = {0};
if (learn_more_link_url) {
dstr_init_copy(
&learn_more_link,
obs_module_text("MultitrackVideo.LearnMoreLink"));
dstr_init_copy(&learn_more_link, obs_module_text("MultitrackVideo.LearnMoreLink"));
dstr_replace(&learn_more_link, "%1", learn_more_link_url);
}
struct dstr str;
dstr_init_copy(&str, obs_module_text("MultitrackVideo.Disclaimer"));
dstr_replace(&str, "%1",
obs_data_get_string(settings, "multitrack_video_name"));
dstr_replace(&str, "%1", obs_data_get_string(settings, "multitrack_video_name"));
dstr_replace(&str, "%2", name);
if (learn_more_link.array) {
dstr_cat(&str, learn_more_link.array);
@@ -634,8 +604,7 @@ static void copy_info_to_settings(json_t *service, obs_data_t *settings)
update_protocol(service, settings);
}
static inline json_t *find_service(json_t *root, const char *name,
const char **p_new_name)
static inline json_t *find_service(json_t *root, const char *name, const char **p_new_name)
{
size_t index;
json_t *service;
@@ -671,8 +640,7 @@ static inline json_t *find_service(json_t *root, const char *name,
return NULL;
}
static bool service_selected(obs_properties_t *props, obs_property_t *p,
obs_data_t *settings)
static bool service_selected(obs_properties_t *props, obs_property_t *p, obs_data_t *settings)
{
const char *name = obs_data_get_string(settings, "service");
json_t *root = obs_properties_get_param(props);
@@ -705,8 +673,7 @@ static bool service_selected(obs_properties_t *props, obs_property_t *p,
return true;
}
static bool show_all_services_toggled(obs_properties_t *ppts, obs_property_t *p,
obs_data_t *settings)
static bool show_all_services_toggled(obs_properties_t *ppts, obs_property_t *p, obs_data_t *settings)
{
const char *cur_service = obs_data_get_string(settings, "service");
bool show_all = obs_data_get_bool(settings, "show_all");
@@ -715,8 +682,7 @@ static bool show_all_services_toggled(obs_properties_t *ppts, obs_property_t *p,
if (!root)
return false;
build_service_list(obs_properties_get(ppts, "service"), root, show_all,
cur_service);
build_service_list(obs_properties_get(ppts, "service"), root, show_all, cur_service);
UNUSED_PARAMETER(p);
return true;
@@ -734,29 +700,25 @@ static obs_properties_t *rtmp_common_properties(void *unused)
if (root)
obs_properties_set_param(ppts, root, properties_data_destroy);
p = obs_properties_add_list(ppts, "service", obs_module_text("Service"),
OBS_COMBO_TYPE_LIST,
p = obs_properties_add_list(ppts, "service", obs_module_text("Service"), OBS_COMBO_TYPE_LIST,
OBS_COMBO_FORMAT_STRING);
obs_property_set_modified_callback(p, service_selected);
p = obs_properties_add_bool(ppts, "show_all",
obs_module_text("ShowAll"));
p = obs_properties_add_bool(ppts, "show_all", obs_module_text("ShowAll"));
obs_property_set_modified_callback(p, show_all_services_toggled);
obs_properties_add_list(ppts, "server", obs_module_text("Server"),
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING);
obs_properties_add_list(ppts, "server", obs_module_text("Server"), OBS_COMBO_TYPE_LIST,
OBS_COMBO_FORMAT_STRING);
obs_properties_add_text(ppts, "key", obs_module_text("StreamKey"),
OBS_TEXT_PASSWORD);
obs_properties_add_text(ppts, "key", obs_module_text("StreamKey"), OBS_TEXT_PASSWORD);
return ppts;
}
static int get_bitrate_matrix_max(json_t *array);
static void apply_video_encoder_settings(obs_data_t *settings,
json_t *recommended)
static void apply_video_encoder_settings(obs_data_t *settings, json_t *recommended)
{
json_t *item = json_object_get(recommended, "keyint");
if (json_is_integer(item)) {
@@ -768,8 +730,7 @@ static void apply_video_encoder_settings(obs_data_t *settings,
item = json_object_get(recommended, "profile");
obs_data_item_t *enc_item = obs_data_item_byname(settings, "profile");
if (json_is_string(item) &&
obs_data_item_gettype(enc_item) == OBS_DATA_STRING) {
if (json_is_string(item) && obs_data_item_gettype(enc_item) == OBS_DATA_STRING) {
const char *profile = json_string_value(item);
obs_data_set_string(settings, "profile", profile);
}
@@ -787,8 +748,7 @@ static void apply_video_encoder_settings(obs_data_t *settings,
max_bitrate = (int)json_integer_value(item);
}
if (max_bitrate &&
obs_data_get_int(settings, "bitrate") > max_bitrate) {
if (max_bitrate && obs_data_get_int(settings, "bitrate") > max_bitrate) {
obs_data_set_int(settings, "bitrate", max_bitrate);
obs_data_set_int(settings, "buffer_size", max_bitrate);
}
@@ -802,8 +762,7 @@ static void apply_video_encoder_settings(obs_data_t *settings,
item = json_object_get(recommended, "x264opts");
if (json_is_string(item)) {
const char *x264_settings = json_string_value(item);
const char *cur_settings =
obs_data_get_string(settings, "x264opts");
const char *cur_settings = obs_data_get_string(settings, "x264opts");
struct dstr opts;
dstr_init_copy(&opts, cur_settings);
@@ -816,8 +775,7 @@ static void apply_video_encoder_settings(obs_data_t *settings,
}
}
static void apply_audio_encoder_settings(obs_data_t *settings,
json_t *recommended)
static void apply_audio_encoder_settings(obs_data_t *settings, json_t *recommended)
{
json_t *item = json_object_get(recommended, "max audio bitrate");
if (json_is_integer(item)) {
@@ -827,8 +785,7 @@ static void apply_audio_encoder_settings(obs_data_t *settings,
}
}
static void initialize_output(struct rtmp_common *service, json_t *root,
obs_data_t *video_settings,
static void initialize_output(struct rtmp_common *service, json_t *root, obs_data_t *video_settings,
obs_data_t *audio_settings)
{
json_t *json_service = find_service(root, service->service, NULL);
@@ -853,15 +810,13 @@ static void initialize_output(struct rtmp_common *service, json_t *root,
apply_audio_encoder_settings(audio_settings, recommended);
}
static void rtmp_common_apply_settings(void *data, obs_data_t *video_settings,
obs_data_t *audio_settings)
static void rtmp_common_apply_settings(void *data, obs_data_t *video_settings, obs_data_t *audio_settings)
{
struct rtmp_common *service = data;
json_t *root = open_services_file();
if (root) {
initialize_output(service, root, video_settings,
audio_settings);
initialize_output(service, root, video_settings, audio_settings);
json_decref(root);
}
}
@@ -885,8 +840,7 @@ static const char *rtmp_common_url(void *data)
}
if (service->service && strcmp(service->service, "Amazon IVS") == 0) {
if (service->server &&
strncmp(service->server, "auto", 4) == 0) {
if (service->server && strncmp(service->server, "auto", 4) == 0) {
struct ingest amazon_ivs_ing;
bool rtmp = strcmp(service->server, "auto-rtmp") == 0;
@@ -896,8 +850,7 @@ static const char *rtmp_common_url(void *data)
amazon_ivs_ing = amazon_ivs_ingest(0);
amazon_ivs_ingests_unlock();
return rtmp ? amazon_ivs_ing.url
: amazon_ivs_ing.rtmps_url;
return rtmp ? amazon_ivs_ing.url : amazon_ivs_ing.rtmps_url;
}
}
@@ -910,8 +863,7 @@ static const char *rtmp_common_url(void *data)
if (service->service && strcmp(service->service, "SHOWROOM") == 0) {
if (service->server && service->key) {
struct showroom_ingest *ingest;
ingest = showroom_get_ingest(service->server,
service->key);
ingest = showroom_get_ingest(service->server, service->key);
return ingest->url;
}
}
@@ -934,8 +886,7 @@ static const char *rtmp_common_key(void *data)
if (service->service && strcmp(service->service, "SHOWROOM") == 0) {
if (service->server && service->key) {
struct showroom_ingest *ingest;
ingest = showroom_get_ingest(service->server,
service->key);
ingest = showroom_get_ingest(service->server, service->key);
return ingest->key;
}
}
@@ -950,16 +901,14 @@ static const char *rtmp_common_key(void *data)
return service->key;
}
static void rtmp_common_get_supported_resolutions(
void *data, struct obs_service_resolution **resolutions, size_t *count)
static void rtmp_common_get_supported_resolutions(void *data, struct obs_service_resolution **resolutions,
size_t *count)
{
struct rtmp_common *service = data;
if (service->supported_resolutions_count) {
*count = service->supported_resolutions_count;
*resolutions =
bmemdup(service->supported_resolutions,
*count * sizeof(struct obs_service_resolution));
*resolutions = bmemdup(service->supported_resolutions, *count * sizeof(struct obs_service_resolution));
} else {
*count = 0;
*resolutions = NULL;
@@ -999,16 +948,14 @@ static int get_bitrate_matrix_max(json_t *array)
if (c != 2)
continue;
if ((int)ovi.output_width == cx &&
(int)ovi.output_height == cy && cur_fps <= fps)
if ((int)ovi.output_width == cx && (int)ovi.output_height == cy && cur_fps <= fps)
return bitrate;
}
return 0;
}
static void rtmp_common_get_max_bitrate(void *data, int *video_bitrate,
int *audio_bitrate)
static void rtmp_common_get_max_bitrate(void *data, int *video_bitrate, int *audio_bitrate)
{
struct rtmp_common *service = data;
json_t *root = open_services_file();
@@ -1040,8 +987,7 @@ static void rtmp_common_get_max_bitrate(void *data, int *video_bitrate,
bitrate = get_bitrate_matrix_max(item);
}
if (!bitrate) {
item = json_object_get(recommended,
"max video bitrate");
item = json_object_get(recommended, "max video bitrate");
if (json_is_integer(item))
bitrate = (int)json_integer_value(item);
}
@@ -1070,8 +1016,7 @@ static const char **rtmp_common_get_supported_video_codecs(void *data)
goto fail;
}
json_t *json_video_codecs =
json_object_get(json_service, "supported video codecs");
json_t *json_video_codecs = json_object_get(json_service, "supported video codecs");
if (!json_is_array(json_video_codecs)) {
goto fail;
}
@@ -1113,8 +1058,7 @@ static const char **rtmp_common_get_supported_audio_codecs(void *data)
goto fail;
}
json_t *json_audio_codecs =
json_object_get(json_service, "supported audio codecs");
json_t *json_audio_codecs = json_object_get(json_service, "supported audio codecs");
if (!json_is_array(json_audio_codecs)) {
goto fail;
}
@@ -1210,8 +1154,7 @@ static bool rtmp_common_can_try_to_connect(void *data)
const char *url = rtmp_common_url(data);
return (url != NULL && url[0] != '\0') &&
(key != NULL && key[0] != '\0');
return (url != NULL && url[0] != '\0') && (key != NULL && key[0] != '\0');
}
struct obs_service_info rtmp_common_service = {
+6 -12
View File
@@ -49,8 +49,7 @@ static void *rtmp_custom_create(obs_data_t *settings, obs_service_t *service)
return data;
}
static bool use_auth_modified(obs_properties_t *ppts, obs_property_t *p,
obs_data_t *settings)
static bool use_auth_modified(obs_properties_t *ppts, obs_property_t *p, obs_data_t *settings)
{
bool use_auth = obs_data_get_bool(settings, "use_auth");
p = obs_properties_get(ppts, "username");
@@ -69,15 +68,11 @@ static obs_properties_t *rtmp_custom_properties(void *unused)
obs_properties_add_text(ppts, "server", "URL", OBS_TEXT_DEFAULT);
obs_properties_add_text(ppts, "key", obs_module_text("StreamKey"),
OBS_TEXT_PASSWORD);
obs_properties_add_text(ppts, "key", obs_module_text("StreamKey"), OBS_TEXT_PASSWORD);
p = obs_properties_add_bool(ppts, "use_auth",
obs_module_text("UseAuth"));
obs_properties_add_text(ppts, "username", obs_module_text("Username"),
OBS_TEXT_DEFAULT);
obs_properties_add_text(ppts, "password", obs_module_text("Password"),
OBS_TEXT_PASSWORD);
p = obs_properties_add_bool(ppts, "use_auth", obs_module_text("UseAuth"));
obs_properties_add_text(ppts, "username", obs_module_text("Username"), OBS_TEXT_DEFAULT);
obs_properties_add_text(ppts, "password", obs_module_text("Password"), OBS_TEXT_PASSWORD);
obs_property_set_modified_callback(p, use_auth_modified);
return ppts;
}
@@ -130,8 +125,7 @@ static const char *rtmp_custom_get_protocol(void *data)
return "RTMP";
}
static void rtmp_custom_apply_settings(void *data, obs_data_t *video_settings,
obs_data_t *audio_settings)
static void rtmp_custom_apply_settings(void *data, obs_data_t *video_settings, obs_data_t *audio_settings)
{
struct rtmp_custom *service = data;
const char *protocol = rtmp_custom_get_protocol(service);
+5 -10
View File
@@ -101,23 +101,18 @@ bool obs_module_load(void)
dstr_cat(&module_name, ")");
proc_handler_t *ph = obs_get_proc_handler();
proc_handler_add(ph, "void twitch_ingests_refresh(int seconds)",
refresh_callback, NULL);
proc_handler_add(ph, "void amazon_ivs_ingests_refresh(int seconds)",
amazon_ivs_refresh_callback, NULL);
proc_handler_add(ph, "void twitch_ingests_refresh(int seconds)", refresh_callback, NULL);
proc_handler_add(ph, "void amazon_ivs_ingests_refresh(int seconds)", amazon_ivs_refresh_callback, NULL);
#if defined(ENABLE_SERVICE_UPDATES)
char *local_dir = obs_module_file("");
char *cache_dir = obs_module_config_path("");
char update_url[128];
snprintf(update_url, sizeof(update_url), "%s/v%d", RTMP_SERVICES_URL,
RTMP_SERVICES_FORMAT_VERSION);
snprintf(update_url, sizeof(update_url), "%s/v%d", RTMP_SERVICES_URL, RTMP_SERVICES_FORMAT_VERSION);
if (cache_dir) {
update_info = update_info_create(RTMP_SERVICES_LOG_STR,
module_name.array, update_url,
local_dir, cache_dir,
confirm_service_file, NULL);
update_info = update_info_create(RTMP_SERVICES_LOG_STR, module_name.array, update_url, local_dir,
cache_dir, confirm_service_file, NULL);
}
load_twitch_data();
@@ -1,15 +1,14 @@
#include "service-ingest.h"
#include "amazon-ivs.h"
static struct service_ingests amazon_ivs = {
.update_info = NULL,
.mutex = PTHREAD_MUTEX_INITIALIZER,
.ingests_refreshed = false,
.ingests_refreshing = false,
.ingests_loaded = false,
.cur_ingests = {0},
.cache_old_filename = "amazon_ivs_ingests.json",
.cache_new_filename = "amazon_ivs_ingests.new.json"};
static struct service_ingests amazon_ivs = {.update_info = NULL,
.mutex = PTHREAD_MUTEX_INITIALIZER,
.ingests_refreshed = false,
.ingests_refreshing = false,
.ingests_loaded = false,
.cur_ingests = {0},
.cache_old_filename = "amazon_ivs_ingests.json",
.cache_new_filename = "amazon_ivs_ingests.new.json"};
void init_amazon_ivs_data(void)
{
@@ -18,10 +17,8 @@ void init_amazon_ivs_data(void)
void load_amazon_ivs_data(void)
{
struct ingest def = {
.name = bstrdup("Default"),
.url = bstrdup(
"rtmps://ingest.global-contribute.live-video.net:443/app/")};
struct ingest def = {.name = bstrdup("Default"),
.url = bstrdup("rtmps://ingest.global-contribute.live-video.net:443/app/")};
load_service_data(&amazon_ivs, "amazon_ivs_ingests.json", &def);
}
@@ -32,9 +29,8 @@ void unload_amazon_ivs_data(void)
void amazon_ivs_ingests_refresh(int seconds)
{
service_ingests_refresh(
&amazon_ivs, seconds, "[amazon ivs ingest update] ",
"https://ingest.contribute.live-video.net/ingests");
service_ingests_refresh(&amazon_ivs, seconds, "[amazon ivs ingest update] ",
"https://ingest.contribute.live-video.net/ingests");
}
void amazon_ivs_ingests_lock(void)
@@ -20,8 +20,7 @@ struct dacast_ingest_info {
struct dacast_ingest ingest;
};
struct dacast_ingest dacast_invalid_ingest = {"rtmp://dacast", "", "",
"fake_key"};
struct dacast_ingest dacast_invalid_ingest = {"rtmp://dacast", "", "", "fake_key"};
static DARRAY(struct dacast_ingest_info) cur_ingests;
@@ -110,8 +109,7 @@ static bool dacast_ingest_update(void *param, struct file_download_data *data)
bool success;
pthread_mutex_lock(&mutex);
success = load_ingests((const char *)data->buffer.array,
(const char *)param);
success = load_ingests((const char *)data->buffer.array, (const char *)param);
pthread_mutex_unlock(&mutex);
if (success) {
@@ -153,9 +151,8 @@ void dacast_ingests_load_data(const char *server, const char *key)
dacast_update_info = NULL;
}
dacast_update_info = update_info_create_single(
"[dacast ingest load data] ", get_module_name(), uri.array,
dacast_ingest_update, (void *)key);
dacast_update_info = update_info_create_single("[dacast ingest load data] ", get_module_name(), uri.array,
dacast_ingest_update, (void *)key);
if (!os_atomic_load_bool(&ingests_loaded)) {
for (int i = 0; i < TIMEOUT_SEC * 100; i++) {
@@ -14,8 +14,7 @@ struct nimotv_mem_struct {
static char *current_ingest = NULL;
static time_t last_time = -1;
static size_t nimotv_write_cb(void *contents, size_t size, size_t nmemb,
void *userp)
static size_t nimotv_write_cb(void *contents, size_t size, size_t nmemb, void *userp)
{
size_t realsize = size * nmemb;
struct nimotv_mem_struct *mem = (struct nimotv_mem_struct *)userp;
@@ -63,9 +62,7 @@ const char *nimotv_get_ingest(const char *key)
time_t now = time(NULL);
double diff = difftime(now, last_time);
if (diff < 2) {
blog(LOG_INFO,
"nimotv_get_ingest: returning ingest from cache: %s",
current_ingest);
blog(LOG_INFO, "nimotv_get_ingest: returning ingest from cache: %s", current_ingest);
return current_ingest;
}
}
@@ -98,9 +95,7 @@ const char *nimotv_get_ingest(const char *key)
dstr_free(&uri);
if (res != CURLE_OK) {
blog(LOG_WARNING,
"nimotv_get_ingest: curl_easy_perform() failed: %s",
curl_easy_strerror(res));
blog(LOG_WARNING, "nimotv_get_ingest: curl_easy_perform() failed: %s", curl_easy_strerror(res));
curl_easy_cleanup(curl_handle);
free(chunk.memory);
return NULL;
@@ -108,9 +103,7 @@ const char *nimotv_get_ingest(const char *key)
curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &response_code);
if (response_code != 200) {
blog(LOG_WARNING,
"nimotv_get_ingest: curl_easy_perform() returned code: %ld",
response_code);
blog(LOG_WARNING, "nimotv_get_ingest: curl_easy_perform() returned code: %ld", response_code);
curl_easy_cleanup(curl_handle);
free(chunk.memory);
return NULL;
@@ -119,8 +112,7 @@ const char *nimotv_get_ingest(const char *key)
curl_easy_cleanup(curl_handle);
if (chunk.size == 0) {
blog(LOG_WARNING,
"nimotv_get_ingest: curl_easy_perform() returned empty response");
blog(LOG_WARNING, "nimotv_get_ingest: curl_easy_perform() returned empty response");
free(chunk.memory);
return NULL;
}
@@ -133,8 +125,7 @@ const char *nimotv_get_ingest(const char *key)
last_time = time(NULL);
free(chunk.memory);
blog(LOG_INFO, "nimotv_get_ingest: returning ingest: %s",
current_ingest);
blog(LOG_INFO, "nimotv_get_ingest: returning ingest: %s", current_ingest);
return current_ingest;
}
@@ -24,8 +24,7 @@ static void free_ingests(struct service_ingests *si)
da_free(si->cur_ingests);
}
static bool load_ingests(struct service_ingests *si, const char *json,
bool write_file)
static bool load_ingests(struct service_ingests *si, const char *json, bool write_file)
{
json_t *root;
json_t *ingests;
@@ -52,8 +51,7 @@ static bool load_ingests(struct service_ingests *si, const char *json,
json_t *item = json_array_get(ingests, i);
json_t *item_name = json_object_get(item, "name");
json_t *item_url = json_object_get(item, "url_template");
json_t *item_rtmps_url =
json_object_get(item, "url_template_secure");
json_t *item_rtmps_url = json_object_get(item, "url_template_secure");
struct ingest ingest = {0};
struct dstr url = {0};
struct dstr rtmps_url = {0};
@@ -67,8 +65,7 @@ static bool load_ingests(struct service_ingests *si, const char *json,
/* At the moment they currently mis-spell "deprecated",
* but that may change in the future, so blacklist both */
if (strstr(name_str, "deprecated") != NULL ||
strstr(name_str, "depracated") != NULL)
if (strstr(name_str, "deprecated") != NULL || strstr(name_str, "depracated") != NULL)
continue;
dstr_copy(&url, url_str);
@@ -124,8 +121,7 @@ static bool ingest_update(void *param, struct file_download_data *data)
return true;
}
void service_ingests_refresh(struct service_ingests *si, int seconds,
const char *log_prefix, const char *file_url)
void service_ingests_refresh(struct service_ingests *si, int seconds, const char *log_prefix, const char *file_url)
{
if (os_atomic_load_bool(&si->ingests_refreshed))
return;
@@ -133,9 +129,7 @@ void service_ingests_refresh(struct service_ingests *si, int seconds,
if (!os_atomic_load_bool(&si->ingests_refreshing)) {
os_atomic_set_bool(&si->ingests_refreshing, true);
si->update_info =
update_info_create_single(log_prefix, get_module_name(),
file_url, ingest_update, si);
si->update_info = update_info_create_single(log_prefix, get_module_name(), file_url, ingest_update, si);
}
/* wait five seconds max when loading ingests for the first time */
@@ -149,8 +143,7 @@ void service_ingests_refresh(struct service_ingests *si, int seconds,
}
}
void load_service_data(struct service_ingests *si, const char *cache_filename,
struct ingest *def)
void load_service_data(struct service_ingests *si, const char *cache_filename, struct ingest *def)
{
char *service_cache = obs_module_config_path(cache_filename);
@@ -24,9 +24,7 @@ struct service_ingests {
};
void init_service_data(struct service_ingests *si);
void service_ingests_refresh(struct service_ingests *si, int seconds,
const char *log_prefix, const char *file_url);
void load_service_data(struct service_ingests *si, const char *cache_filename,
struct ingest *def);
void service_ingests_refresh(struct service_ingests *si, int seconds, const char *log_prefix, const char *file_url);
void load_service_data(struct service_ingests *si, const char *cache_filename, struct ingest *def);
void unload_service_data(struct service_ingests *si);
struct ingest get_ingest(struct service_ingests *si, size_t idx);
@@ -32,8 +32,7 @@ void free_showroom_data(void)
da_free(cur_ingests);
}
static size_t showroom_write_cb(void *data, size_t size, size_t nmemb,
void *user_pointer)
static size_t showroom_write_cb(void *data, size_t size, size_t nmemb, void *user_pointer)
{
struct dstr *json = user_pointer;
size_t realsize = size * nmemb;
@@ -59,8 +58,7 @@ static struct showroom_ingest_info *find_ingest(const char *access_key)
#define SEC_TO_NSEC 1000000000ULL
#endif
static struct showroom_ingest_info *get_ingest_from_json(char *str,
const char *access_key)
static struct showroom_ingest_info *get_ingest_from_json(char *str, const char *access_key)
{
json_error_t error;
json_t *root;
@@ -69,10 +67,8 @@ static struct showroom_ingest_info *get_ingest_from_json(char *str,
return NULL;
}
const char *url_str =
json_string_value(json_object_get(root, "streaming_url_rtmp"));
const char *key_str =
json_string_value(json_object_get(root, "streaming_key"));
const char *url_str = json_string_value(json_object_get(root, "streaming_url_rtmp"));
const char *key_str = json_string_value(json_object_get(root, "streaming_key"));
struct showroom_ingest_info *info = find_ingest(access_key);
if (!info) {
@@ -90,8 +86,7 @@ static struct showroom_ingest_info *get_ingest_from_json(char *str,
return info;
}
struct showroom_ingest *showroom_get_ingest(const char *server,
const char *access_key)
struct showroom_ingest *showroom_get_ingest(const char *server, const char *access_key)
{
struct showroom_ingest_info *info = find_ingest(access_key);
CURL *curl_handle;
@@ -128,9 +123,7 @@ struct showroom_ingest *showroom_get_ingest(const char *server,
res = curl_easy_perform(curl_handle);
dstr_free(&uri);
if (res != CURLE_OK) {
blog(LOG_WARNING,
"showroom_get_ingest: curl_easy_perform() failed: %s",
curl_easy_strerror(res));
blog(LOG_WARNING, "showroom_get_ingest: curl_easy_perform() failed: %s", curl_easy_strerror(res));
goto cleanup;
}
@@ -144,9 +137,8 @@ struct showroom_ingest *showroom_get_ingest(const char *server,
}
if (json.len == 0) {
blog(LOG_WARNING,
"showroom_get_ingest: curl_easy_perform() returned "
"empty response");
blog(LOG_WARNING, "showroom_get_ingest: curl_easy_perform() returned "
"empty response");
goto cleanup;
}
@@ -5,7 +5,6 @@ struct showroom_ingest {
const char *key;
};
extern struct showroom_ingest *showroom_get_ingest(const char *server,
const char *access_key);
extern struct showroom_ingest *showroom_get_ingest(const char *server, const char *access_key);
extern void free_showroom_data();
+10 -13
View File
@@ -1,15 +1,14 @@
#include "service-ingest.h"
#include "twitch.h"
static struct service_ingests twitch = {
.update_info = NULL,
.mutex = PTHREAD_MUTEX_INITIALIZER,
.ingests_refreshed = false,
.ingests_refreshing = false,
.ingests_loaded = false,
.cur_ingests = {0},
.cache_old_filename = "twitch_ingests.json",
.cache_new_filename = "twitch_ingests.new.json"};
static struct service_ingests twitch = {.update_info = NULL,
.mutex = PTHREAD_MUTEX_INITIALIZER,
.ingests_refreshed = false,
.ingests_refreshing = false,
.ingests_loaded = false,
.cur_ingests = {0},
.cache_old_filename = "twitch_ingests.json",
.cache_new_filename = "twitch_ingests.new.json"};
void twitch_ingests_lock(void)
{
@@ -38,14 +37,12 @@ void init_twitch_data(void)
void twitch_ingests_refresh(int seconds)
{
service_ingests_refresh(&twitch, seconds, "[twitch ingest update] ",
"https://ingest.twitch.tv/ingests");
service_ingests_refresh(&twitch, seconds, "[twitch ingest update] ", "https://ingest.twitch.tv/ingests");
}
void load_twitch_data(void)
{
struct ingest def = {.name = bstrdup("Default"),
.url = bstrdup("rtmp://live.twitch.tv/app")};
struct ingest def = {.name = bstrdup("Default"), .url = bstrdup("rtmp://live.twitch.tv/app")};
load_service_data(&twitch, "twitch_ingests.json", &def);
}