[record] start whipping some sense into this feature

This commit is contained in:
radius 2018-09-15 17:44:46 -05:00
parent 13223c2225
commit 49214de125
9 changed files with 73 additions and 15 deletions

View File

@ -18,7 +18,8 @@
"driver.h": "c", "driver.h": "c",
"iosfwd": "c", "iosfwd": "c",
"xlocbuf": "c", "xlocbuf": "c",
"xmemory0": "c" "xmemory0": "c",
"ios": "c"
}, },
"C_Cpp.dimInactiveRegions": false, "C_Cpp.dimInactiveRegions": false,
} }

View File

@ -2176,9 +2176,12 @@ TODO: Add a setting for these tweaks */
return false; return false;
break; break;
case CMD_EVENT_RECORD_INIT: case CMD_EVENT_RECORD_INIT:
command_event(CMD_EVENT_HISTORY_DEINIT, NULL); {
if (!recording_init()) bool *recording_enabled = recording_is_enabled();
*recording_enabled = true;
if (!recording_init(false))
return false; return false;
}
break; break;
case CMD_EVENT_HISTORY_DEINIT: case CMD_EVENT_HISTORY_DEINIT:
if (g_defaults.content_history) if (g_defaults.content_history)

View File

@ -654,6 +654,10 @@ static const unsigned libretro_log_level = 1;
#define RARCH_DEFAULT_PORT 55435 #define RARCH_DEFAULT_PORT 55435
#endif #endif
#ifndef RARCH_STREAM_DEFAULT_PORT
#define RARCH_STREAM_DEFAULT_PORT 56400
#endif
/* KEYBINDS, JOYPAD */ /* KEYBINDS, JOYPAD */
/* Axis threshold (between 0.0 and 1.0) /* Axis threshold (between 0.0 and 1.0)

View File

@ -1159,6 +1159,14 @@ static struct config_path_setting *populate_settings_path(settings_t *settings,
#ifdef HAVE_OVERLAY #ifdef HAVE_OVERLAY
SETTING_PATH("input_overlay", SETTING_PATH("input_overlay",
settings->paths.path_overlay, false, NULL, true); settings->paths.path_overlay, false, NULL, true);
#endif
#ifdef HAVE_FFMPEG
SETTING_PATH("video_record_config",
settings->paths.path_record_config, false, NULL, true);
SETTING_PATH("video_stream_config",
settings->paths.path_stream_config, false, NULL, true);
SETTING_PATH("video_stream_url",
settings->paths.path_stream_url, false, NULL, true);
#endif #endif
SETTING_PATH("video_font_path", SETTING_PATH("video_font_path",
settings->paths.path_font, false, NULL, true); settings->paths.path_font, false, NULL, true);
@ -1580,6 +1588,7 @@ static struct config_uint_setting *populate_settings_uint(settings_t *settings,
SETTING_UINT("aspect_ratio_index", &settings->uints.video_aspect_ratio_idx, true, aspect_ratio_idx, false); SETTING_UINT("aspect_ratio_index", &settings->uints.video_aspect_ratio_idx, true, aspect_ratio_idx, false);
#ifdef HAVE_NETWORKING #ifdef HAVE_NETWORKING
SETTING_UINT("netplay_ip_port", &settings->uints.netplay_port, true, RARCH_DEFAULT_PORT, false); SETTING_UINT("netplay_ip_port", &settings->uints.netplay_port, true, RARCH_DEFAULT_PORT, false);
SETTING_UINT("video_stream_port", &settings->uints.video_stream_port, true, RARCH_STREAM_DEFAULT_PORT, false);
SETTING_OVERRIDE(RARCH_OVERRIDE_SETTING_NETPLAY_IP_PORT); SETTING_OVERRIDE(RARCH_OVERRIDE_SETTING_NETPLAY_IP_PORT);
SETTING_UINT("netplay_input_latency_frames_min",&settings->uints.netplay_input_latency_frames_min, true, 0, false); SETTING_UINT("netplay_input_latency_frames_min",&settings->uints.netplay_input_latency_frames_min, true, 0, false);
SETTING_UINT("netplay_input_latency_frames_range",&settings->uints.netplay_input_latency_frames_range, true, 0, false); SETTING_UINT("netplay_input_latency_frames_range",&settings->uints.netplay_input_latency_frames_range, true, 0, false);
@ -1921,6 +1930,9 @@ static void config_set_defaults(void)
*settings->paths.path_menu_wallpaper = '\0'; *settings->paths.path_menu_wallpaper = '\0';
*settings->paths.path_content_database = '\0'; *settings->paths.path_content_database = '\0';
*settings->paths.path_overlay = '\0'; *settings->paths.path_overlay = '\0';
*settings->paths.path_record_config = '\0';
*settings->paths.path_stream_config = '\0';
*settings->paths.path_stream_url = '\0';
*settings->paths.path_softfilter_plugin = '\0'; *settings->paths.path_softfilter_plugin = '\0';
*settings->arrays.playlist_names = '\0'; *settings->arrays.playlist_names = '\0';

View File

@ -374,6 +374,7 @@ typedef struct settings
unsigned video_msg_bgcolor_red; unsigned video_msg_bgcolor_red;
unsigned video_msg_bgcolor_green; unsigned video_msg_bgcolor_green;
unsigned video_msg_bgcolor_blue; unsigned video_msg_bgcolor_blue;
unsigned video_stream_port;
unsigned menu_thumbnails; unsigned menu_thumbnails;
unsigned menu_left_thumbnails; unsigned menu_left_thumbnails;
@ -478,6 +479,9 @@ typedef struct settings
char path_cheat_database[PATH_MAX_LENGTH]; char path_cheat_database[PATH_MAX_LENGTH];
char path_content_database[PATH_MAX_LENGTH]; char path_content_database[PATH_MAX_LENGTH];
char path_overlay[PATH_MAX_LENGTH]; char path_overlay[PATH_MAX_LENGTH];
char path_record_config[PATH_MAX_LENGTH];
char path_stream_config[PATH_MAX_LENGTH];
char path_stream_url[PATH_MAX_LENGTH];
char path_menu_wallpaper[PATH_MAX_LENGTH]; char path_menu_wallpaper[PATH_MAX_LENGTH];
char path_audio_dsp_plugin[PATH_MAX_LENGTH]; char path_audio_dsp_plugin[PATH_MAX_LENGTH];
char path_softfilter_plugin[PATH_MAX_LENGTH]; char path_softfilter_plugin[PATH_MAX_LENGTH];
@ -492,7 +496,6 @@ typedef struct settings
char path_shader[PATH_MAX_LENGTH]; char path_shader[PATH_MAX_LENGTH];
char path_font[PATH_MAX_LENGTH]; char path_font[PATH_MAX_LENGTH];
char directory_audio_filter[PATH_MAX_LENGTH]; char directory_audio_filter[PATH_MAX_LENGTH];
char directory_autoconfig[PATH_MAX_LENGTH]; char directory_autoconfig[PATH_MAX_LENGTH];
char directory_video_filter[PATH_MAX_LENGTH]; char directory_video_filter[PATH_MAX_LENGTH];

View File

@ -721,6 +721,15 @@ enum rarch_content_type path_is_media_type(const char *path)
string_to_lower(ext_lower); string_to_lower(ext_lower);
/* hack, to detect livestreams so the ffmpeg core can be started */
if (
strstr(path, "udp://") ||
strstr(path, "tcp://") ||
strstr(path, "rtmp://") ||
strstr(path, "rtp://")
)
return RARCH_CONTENT_MOVIE;
switch (msg_hash_to_file_type(msg_hash_calculate(ext_lower))) switch (msg_hash_to_file_type(msg_hash_calculate(ext_lower)))
{ {
#if defined(HAVE_FFMPEG) || defined(HAVE_MPV) #if defined(HAVE_FFMPEG) || defined(HAVE_MPV)

View File

@ -35,6 +35,7 @@
#include "../verbosity.h" #include "../verbosity.h"
#include "../msg_hash.h" #include "../msg_hash.h"
#include "../list_special.h" #include "../list_special.h"
#include "paths.h"
static const record_driver_t *record_drivers[] = { static const record_driver_t *record_drivers[] = {
@ -309,9 +310,10 @@ void recording_push_audio(const int16_t *data, size_t samples)
* *
* Returns: true (1) if successful, otherwise false (0). * Returns: true (1) if successful, otherwise false (0).
**/ **/
bool recording_init(void) bool recording_init(bool stream)
{ {
char recording_file[PATH_MAX_LENGTH]; char output[PATH_MAX_LENGTH];
char buf[PATH_MAX_LENGTH];
struct ffemu_params params = {0}; struct ffemu_params params = {0};
struct retro_system_av_info *av_info = video_viewport_get_system_av_info(); struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
bool *recording_enabled = recording_is_enabled(); bool *recording_enabled = recording_is_enabled();
@ -321,7 +323,7 @@ bool recording_init(void)
if (!*recording_enabled) if (!*recording_enabled)
return false; return false;
recording_file[0] = '\0'; output[0] = '\0';
if (rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL)) if (rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL))
{ {
@ -343,19 +345,36 @@ bool recording_init(void)
(float)av_info->timing.fps, (float)av_info->timing.fps,
(float)av_info->timing.sample_rate); (float)av_info->timing.sample_rate);
strlcpy(recording_file, global->record.path, sizeof(recording_file)); if (!string_is_empty(global->record.path))
strlcpy(output, global->record.path, sizeof(output));
else
{
if(stream)
if (!string_is_empty(settings->paths.path_stream_url))
strlcpy(output, settings->paths.path_stream_url, sizeof(output));
else
/* to-do determine the local interface, this won't work for connecting over the internet*/
snprintf(output, sizeof(output), "udp://127.0.0.1:%u", settings->uints.video_stream_port);
else
{
const char *game_name = path_basename(path_get(RARCH_PATH_BASENAME));
fill_str_dated_filename(buf, game_name,
"mkv", sizeof(buf));
fill_pathname_join(output, global->record.output_dir, buf, sizeof(output));
}
}
if (recording_use_output_dir) if (recording_use_output_dir)
fill_pathname_join(recording_file, fill_pathname_join(output,
global->record.output_dir, global->record.output_dir,
global->record.path, sizeof(recording_file)); global->record.path, sizeof(output));
params.out_width = av_info->geometry.base_width; params.out_width = av_info->geometry.base_width;
params.out_height = av_info->geometry.base_height; params.out_height = av_info->geometry.base_height;
params.fb_width = av_info->geometry.max_width; params.fb_width = av_info->geometry.max_width;
params.fb_height = av_info->geometry.max_height; params.fb_height = av_info->geometry.max_height;
params.channels = 2; params.channels = 2;
params.filename = recording_file; params.filename = output;
params.fps = av_info->timing.fps; params.fps = av_info->timing.fps;
params.samplerate = av_info->timing.sample_rate; params.samplerate = av_info->timing.sample_rate;
params.pix_fmt = (video_driver_get_pixel_format() == RETRO_PIXEL_FORMAT_XRGB8888) ? params.pix_fmt = (video_driver_get_pixel_format() == RETRO_PIXEL_FORMAT_XRGB8888) ?
@ -364,6 +383,8 @@ bool recording_init(void)
if (!string_is_empty(global->record.config)) if (!string_is_empty(global->record.config))
params.config = global->record.config; params.config = global->record.config;
else if (!string_is_empty(settings->paths.path_record_config))
params.config = settings->paths.path_record_config;
if (video_driver_supports_recording()) if (video_driver_supports_recording())
{ {
@ -443,7 +464,7 @@ bool recording_init(void)
RARCH_LOG("%s %s @ %ux%u. (FB size: %ux%u pix_fmt: %u)\n", RARCH_LOG("%s %s @ %ux%u. (FB size: %ux%u pix_fmt: %u)\n",
msg_hash_to_str(MSG_RECORDING_TO), msg_hash_to_str(MSG_RECORDING_TO),
global->record.path, output,
params.out_width, params.out_height, params.out_width, params.out_height,
params.fb_width, params.fb_height, params.fb_width, params.fb_height,
(unsigned)params.pix_fmt); (unsigned)params.pix_fmt);

View File

@ -158,7 +158,7 @@ void find_record_driver(void);
* *
* Returns: true (1) if successful, otherwise false (0). * Returns: true (1) if successful, otherwise false (0).
**/ **/
bool recording_init(void); bool recording_init(bool stream);
bool *recording_is_enabled(void); bool *recording_is_enabled(void);

View File

@ -1320,6 +1320,7 @@ static void retroarch_main_init_media(void)
bool retroarch_main_init(int argc, char *argv[]) bool retroarch_main_init(int argc, char *argv[])
{ {
bool init_failed = false; bool init_failed = false;
global_t *global = global_get_ptr();
retroarch_init_state(); retroarch_init_state();
@ -1398,6 +1399,7 @@ bool retroarch_main_init(int argc, char *argv[])
command_event(CMD_EVENT_MAPPER_INIT, NULL); command_event(CMD_EVENT_MAPPER_INIT, NULL);
command_event(CMD_EVENT_REWIND_INIT, NULL); command_event(CMD_EVENT_REWIND_INIT, NULL);
command_event(CMD_EVENT_CONTROLLERS_INIT, NULL); command_event(CMD_EVENT_CONTROLLERS_INIT, NULL);
if (!string_is_empty(global->record.path))
command_event(CMD_EVENT_RECORD_INIT, NULL); command_event(CMD_EVENT_RECORD_INIT, NULL);
path_init_savefile(); path_init_savefile();
@ -3191,7 +3193,10 @@ static enum runloop_state runloop_check_state(
current_input, RARCH_MOVIE_RECORD_TOGGLE); current_input, RARCH_MOVIE_RECORD_TOGGLE);
if (pressed && !old_pressed) if (pressed && !old_pressed)
{
command_event(CMD_EVENT_RECORD_INIT, NULL);
bsv_movie_check(); bsv_movie_check();
}
old_pressed = pressed; old_pressed = pressed;
} }