From c0f9f7b9a91d8aedcc0cd81157cfa375893bf58f Mon Sep 17 00:00:00 2001 From: radius Date: Wed, 26 Sep 2018 21:40:57 -0500 Subject: [PATCH] [recording] update streaming url at startup and whenever the stream keys are updated --- configuration.c | 1 + menu/menu_setting.c | 51 +++--------------------------------------- record/record_driver.c | 49 ++++++++++++++++++++++++++++++++++++++++ record/record_driver.h | 2 ++ 4 files changed, 55 insertions(+), 48 deletions(-) diff --git a/configuration.c b/configuration.c index 661573c666..8674a06240 100644 --- a/configuration.c +++ b/configuration.c @@ -3041,6 +3041,7 @@ static bool config_load_file(const char *path, bool set_defaults, } frontend_driver_set_sustained_performance_mode(settings->bools.sustained_performance_mode); + recording_driver_update_streaming_url(); ret = true; diff --git a/menu/menu_setting.c b/menu/menu_setting.c index cf6a253cfc..6557d98bf6 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -2956,53 +2956,8 @@ static void achievement_hardcore_mode_write_handler(rarch_setting_t *setting) #ifdef HAVE_FFMPEG static void update_streaming_url_write_handler(rarch_setting_t *setting) { - settings_t *settings = config_get_ptr(); - const char* youtube_url = "rtmp://a.rtmp.youtube.com/live2/"; - const char* twitch_url = "rtmp://live.twitch.tv/app/"; - - if (!setting) - return; - - switch (settings->uints.streaming_mode) - { - case STREAMING_MODE_TWITCH: - { - if (!string_is_empty(settings->arrays.twitch_stream_key)) - snprintf(settings->paths.path_stream_url, sizeof(settings->paths.path_stream_url), - "%s%s", twitch_url, settings->arrays.twitch_stream_key); - else - { - /* To-Do: Show input box for twitch_stream_key*/ - RARCH_LOG("[recording] twitch streaming key empty"); - } - break; - } - case STREAMING_MODE_YOUTUBE: - { - if (!string_is_empty(settings->arrays.youtube_stream_key)) - { - snprintf(settings->paths.path_stream_url, sizeof(settings->paths.path_stream_url), - "%s%s", youtube_url, settings->arrays.youtube_stream_key); - } - else - { - /* To-Do: Show input box for youtube_stream_key*/ - RARCH_LOG("[recording] youtube streaming key empty"); - } - break; - } - case STREAMING_MODE_LOCAL: - /* To-Do: figure out default interface and bind to that instead */ - snprintf(settings->paths.path_stream_url, sizeof(settings->paths.path_stream_url), - "udp://%s:%u", "127.0.0.1", settings->uints.video_stream_port); - break; - case STREAMING_MODE_CUSTOM: - default: - /* Do nothing, let the user input the URL */ - break; - } + recording_driver_update_streaming_url(); } - #endif #ifdef HAVE_LAKKA @@ -9702,7 +9657,7 @@ static bool setting_append_list( &group_info, &subgroup_info, parent_group, - general_write_handler, + update_streaming_url_write_handler, general_read_handler); settings_data_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_INPUT); @@ -9728,7 +9683,7 @@ static bool setting_append_list( &group_info, &subgroup_info, parent_group, - general_write_handler, + update_streaming_url_write_handler, general_read_handler); settings_data_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_INPUT); diff --git a/record/record_driver.c b/record/record_driver.c index aca643ab44..32896df950 100644 --- a/record/record_driver.c +++ b/record/record_driver.c @@ -520,6 +520,55 @@ unsigned *recording_driver_get_height(void) return &recording_height; } +void recording_driver_update_streaming_url() +{ + settings_t *settings = config_get_ptr(); + const char* youtube_url = "rtmp://a.rtmp.youtube.com/live2/"; + const char* twitch_url = "rtmp://live.twitch.tv/app/"; + + if (!settings) + return; + + switch (settings->uints.streaming_mode) + { + case STREAMING_MODE_TWITCH: + { + if (!string_is_empty(settings->arrays.twitch_stream_key)) + snprintf(settings->paths.path_stream_url, sizeof(settings->paths.path_stream_url), + "%s%s", twitch_url, settings->arrays.twitch_stream_key); + else + { + /* To-Do: Show input box for twitch_stream_key*/ + RARCH_LOG("[recording] twitch streaming key empty"); + } + break; + } + case STREAMING_MODE_YOUTUBE: + { + if (!string_is_empty(settings->arrays.youtube_stream_key)) + { + snprintf(settings->paths.path_stream_url, sizeof(settings->paths.path_stream_url), + "%s%s", youtube_url, settings->arrays.youtube_stream_key); + } + else + { + /* To-Do: Show input box for youtube_stream_key*/ + RARCH_LOG("[recording] youtube streaming key empty"); + } + break; + } + case STREAMING_MODE_LOCAL: + /* To-Do: figure out default interface and bind to that instead */ + snprintf(settings->paths.path_stream_url, sizeof(settings->paths.path_stream_url), + "udp://%s:%u", "127.0.0.1", settings->uints.video_stream_port); + break; + case STREAMING_MODE_CUSTOM: + default: + /* Do nothing, let the user input the URL */ + break; + } +} + void recording_driver_free_state(void) { recording_gpu_width = 0; diff --git a/record/record_driver.h b/record/record_driver.h index 5e959ee08c..539cb50698 100644 --- a/record/record_driver.h +++ b/record/record_driver.h @@ -208,6 +208,8 @@ bool recording_is_enabled(void); bool streaming_is_enabled(void); +void recording_driver_update_streaming_url(); + extern void *recording_data; RETRO_END_DECLS