# HG changeset patch # User ben # Date 1199990708 0 # Node ID 25f6dca4df7406b1152c6dd199f475e862eaeaea # Parent 4344e84f7a9fee6eba791c0213797b17b00cb619 add support for per protocol and per extension playback profile loading diff -r 4344e84f7a9f -r 25f6dca4df74 help/help_mp-en.h --- a/help/help_mp-en.h Thu Jan 10 18:41:21 2008 +0000 +++ b/help/help_mp-en.h Thu Jan 10 18:45:08 2008 +0000 @@ -151,6 +151,8 @@ " DOCS/HTML/en/bugreports.html and follow the instructions there. We can't and\n"\ " won't help unless you provide this information when reporting a possible bug.\n" #define MSGTR_LoadingConfig "Loading config '%s'\n" +#define MSGTR_LoadingProtocolProfile "Loading protocol-related profile '%s'\n" +#define MSGTR_LoadingExtensionProfile "Loading extension-related profile '%s'\n" #define MSGTR_AddedSubtitleFile "SUB: Added subtitle file (%d): %s\n" #define MSGTR_RemovedSubtitleFile "SUB: Removed subtitle file (%d): %s\n" #define MSGTR_ErrorOpeningOutputFile "Error opening file [%s] for writing!\n" diff -r 4344e84f7a9f -r 25f6dca4df74 mplayer.c --- a/mplayer.c Thu Jan 10 18:41:21 2008 +0000 +++ b/mplayer.c Thu Jan 10 18:45:08 2008 +0000 @@ -836,6 +836,52 @@ } } +#define PROFILE_CFG_PROTOCOL "protocol." + +static void load_per_protocol_config (m_config_t* conf, const char *const file) +{ + char *str; + char protocol[strlen (PROFILE_CFG_PROTOCOL) + strlen (file) + 1]; + m_profile_t *p; + + /* does filename actually uses a protocol ? */ + str = strstr (file, "://"); + if (!str) + return; + + sprintf (protocol, "%s%s", PROFILE_CFG_PROTOCOL, file); + protocol[strlen (PROFILE_CFG_PROTOCOL)+strlen(file)-strlen(str)] = '\0'; + p = m_config_get_profile (conf, protocol); + if (p) + { + mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LoadingProtocolProfile, protocol); + m_config_set_profile(conf,p); + } +} + +#define PROFILE_CFG_EXTENSION "extension." + +static void load_per_extension_config (m_config_t* conf, const char *const file) +{ + char *str; + char extension[strlen (PROFILE_CFG_EXTENSION) + 8]; + m_profile_t *p; + + /* does filename actually have an extension ? */ + str = strrchr (filename, '.'); + if (!str) + return; + + sprintf (extension, PROFILE_CFG_EXTENSION); + strncat (extension, ++str, 7); + p = m_config_get_profile (conf, extension); + if (p) + { + mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LoadingExtensionProfile, extension); + m_config_set_profile(conf,p); + } +} + static void load_per_file_config (m_config_t* conf, const char *const file) { char *confpath; @@ -2695,6 +2741,8 @@ mpctx->global_sub_size = 0; { int i; for (i = 0; i < SUB_SOURCES; i++) mpctx->global_sub_indices[i] = -1; } + if (filename) load_per_protocol_config (mconfig, filename); + if (filename) load_per_extension_config (mconfig, filename); if (filename) load_per_file_config (mconfig, filename); // We must enable getch2 here to be able to interrupt network connection