[Mplayerxp-cvslog] SF.net SVN: mplayerxp:[521] mplayerxp
Brought to you by:
olov
From: <nic...@us...> - 2012-12-08 08:35:45
|
Revision: 521 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=521&view=rev Author: nickols_k Date: 2012-12-08 08:35:38 +0000 (Sat, 08 Dec 2012) Log Message: ----------- combine various configurable network_* variables into structure Modified Paths: -------------- mplayerxp/cfg-mplayerxp.h mplayerxp/libmpstream/cookies.cpp mplayerxp/libmpstream/network.cpp mplayerxp/libmpstream/network.h mplayerxp/libmpstream/s_rtsp.cpp mplayerxp/libmpstream/s_udp.cpp mplayerxp/libmpstream/stream.h Modified: mplayerxp/cfg-mplayerxp.h =================================================================== --- mplayerxp/cfg-mplayerxp.h 2012-12-08 08:15:09 UTC (rev 520) +++ mplayerxp/cfg-mplayerxp.h 2012-12-08 08:35:38 UTC (rev 521) @@ -11,15 +11,6 @@ //extern char *sdl_adriver; #endif -extern int network_prefer_ipv4; -extern char *network_username; -extern char *network_password; -extern int network_bandwidth; -extern char *network_useragent; -extern int network_ipv4_only_proxy; -extern int network_cookies_enabled; -extern char *cookies_file; - extern af_cfg_t af_cfg; // Configuration for audio filters extern vf_cfg_t vf_cfg; // Configuration for audio filters @@ -42,19 +33,19 @@ #ifdef HAVE_STREAMING static const config_t net_config[]={ - {"ipv4", &network_prefer_ipv4, CONF_TYPE_FLAG, 0, 0, 1, "forces mplayerxp to use IPv4 protocol over network"}, + {"ipv4", &net_conf.prefer_ipv4, CONF_TYPE_FLAG, 0, 0, 1, "forces mplayerxp to use IPv4 protocol over network"}, #ifdef HAVE_AF_INET6 - {"ipv6", &network_prefer_ipv4, CONF_TYPE_FLAG, 0, 1, 0, "forces mplayerxp to use IPv6 protocol over network"}, + {"ipv6", &net_conf.prefer_ipv4, CONF_TYPE_FLAG, 0, 1, 0, "forces mplayerxp to use IPv6 protocol over network"}, #else {"ipv6", "MPlayerXP was compiled without IPv6 support.\n", CONF_TYPE_PRINT, 0, 0, 0, NULL}, #endif /* HAVE_AF_INET6 */ - {"ipv4-only-proxy", &network_ipv4_only_proxy, CONF_TYPE_FLAG, 0, 0, 1, "skip the proxy for IPv6 addresses"}, - {"user", &network_username, CONF_TYPE_STRING, 0, 0, 0, "specifies username for HTTP authentication"}, - {"passwd", &network_password, CONF_TYPE_STRING, 0, 0, 0, "specifies password for HTTP authentication"}, - {"bandwidth", &network_bandwidth, CONF_TYPE_INT, CONF_MIN, 0, 0, "specifies the maximum bandwidth for network streaming"}, - {"user-agent", &network_useragent, CONF_TYPE_STRING, 0, 0, 0, "specifies string as user agent for HTTP streaming"}, - {"cookies", &network_cookies_enabled, CONF_TYPE_FLAG, 0, 0, 1, "send cookies when making HTTP requests"}, - {"cookies-file", &cookies_file, CONF_TYPE_STRING, 0, 0, 0, "Read HTTP cookies from file"}, + {"ipv4-only-proxy", &net_conf.ipv4_only_proxy, CONF_TYPE_FLAG, 0, 0, 1, "skip the proxy for IPv6 addresses"}, + {"user", &net_conf.username, CONF_TYPE_STRING, 0, 0, 0, "specifies username for HTTP authentication"}, + {"passwd", &net_conf.password, CONF_TYPE_STRING, 0, 0, 0, "specifies password for HTTP authentication"}, + {"bandwidth", &net_conf.bandwidth, CONF_TYPE_INT, CONF_MIN, 0, 0, "specifies the maximum bandwidth for network streaming"}, + {"user-agent", &net_conf.useragent, CONF_TYPE_STRING, 0, 0, 0, "specifies string as user agent for HTTP streaming"}, + {"cookies", &net_conf.cookies_enabled, CONF_TYPE_FLAG, 0, 0, 1, "send cookies when making HTTP requests"}, + {"cookies-file", &net_conf.cookies_file, CONF_TYPE_STRING, 0, 0, 0, "Read HTTP cookies from file"}, {NULL, NULL, 0, 0, 0, 0, NULL}, }; #endif Modified: mplayerxp/libmpstream/cookies.cpp =================================================================== --- mplayerxp/libmpstream/cookies.cpp 2012-12-08 08:15:09 UTC (rev 520) +++ mplayerxp/libmpstream/cookies.cpp 2012-12-08 08:35:38 UTC (rev 521) @@ -21,12 +21,11 @@ #include "cookies.h" #include "http.h" +#include "network.h" #include "stream_msg.h" #define MAX_COOKIES 20 -char *cookies_file = NULL; - typedef struct cookie_list_type { char *name; char *value; @@ -184,8 +183,8 @@ char *homedir; - if (cookies_file) - return load_cookies_from(cookies_file, list); + if (net_conf.cookies_file) + return load_cookies_from(net_conf.cookies_file, list); homedir = getenv("HOME"); if (!homedir) Modified: mplayerxp/libmpstream/network.cpp =================================================================== --- mplayerxp/libmpstream/network.cpp 2012-12-08 08:15:09 UTC (rev 520) +++ mplayerxp/libmpstream/network.cpp 2012-12-08 08:35:38 UTC (rev 521) @@ -49,16 +49,20 @@ #include "stream_msg.h" /* Variables for the command line option -user, -passwd & -bandwidth */ -char* network_username=NULL; -char* network_password=NULL; -int network_bandwidth=0; -int network_cookies_enabled = 0; -char* network_useragent=NULL; +net_config_t::net_config_t() + :username(NULL), + password(NULL), + bandwidth(0), + cookies_enabled(0), + cookies_file(NULL), + useragent(NULL), + prefer_ipv4(1), + ipv4_only_proxy(0) +{ +} +net_config_t::~net_config_t() {} +net_config_t net_conf; -/* IPv6 options */ -int network_prefer_ipv4 = 1; -int network_ipv4_only_proxy = 0; - static const struct { const char *mime_type; int demuxer_type; @@ -138,7 +142,7 @@ } #ifdef HAVE_AF_INET6 - if (network_ipv4_only_proxy && (gethostbyname(url->hostname)==NULL)) { + if (net_conf.ipv4_only_proxy && (gethostbyname(url->hostname)==NULL)) { MSG_WARN( "Could not find resolve remote hostname for AF_INET. Trying without proxy.\n"); return url_out; @@ -188,9 +192,9 @@ else snprintf(str, 256, "Host: %s", server_url->hostname ); http_set_field( http_hdr, str); - if (network_useragent) + if (net_conf.useragent) { - snprintf(str, 256, "User-Agent: %s", network_useragent); + snprintf(str, 256, "User-Agent: %s", net_conf.useragent); http_set_field(http_hdr, str); } else @@ -204,7 +208,7 @@ http_set_field(http_hdr, str); } - if (network_cookies_enabled) cookies_set( http_hdr, server_url->hostname, server_url->url ); + if (net_conf.cookies_enabled) cookies_set( http_hdr, server_url->hostname, server_url->url ); http_set_field( http_hdr, "Connection: closed"); http_add_basic_authentication( http_hdr, url->username, url->password ); @@ -298,8 +302,8 @@ } else { MSG_INFO("Authentication required\n"); } - if( network_username ) { - url->username = mp_strdup(network_username); + if( net_conf.username ) { + url->username = mp_strdup(net_conf.username); if( url->username==NULL ) { MSG_FATAL(MSGTR_OutOfMemory); return -1; @@ -308,8 +312,8 @@ MSG_ERR(MSGTR_ConnAuthFailed); return -1; } - if( network_password ) { - url->password = mp_strdup(network_password); + if( net_conf.password ) { + url->password = mp_strdup(net_conf.password); if( url->password==NULL ) { MSG_FATAL(MSGTR_OutOfMemory); return -1; @@ -696,7 +700,7 @@ sprintf(mrl,"rtsp://%s:%i/%s",networking->url->hostname,port,file); rtsp = rtsp_session_start(tcp,&mrl, file, networking->url->hostname, port, &redirected, - network_bandwidth,networking->url->username, + net_conf.bandwidth,networking->url->username, networking->url->password); if ( redirected == 1 ) { @@ -761,7 +765,7 @@ rc = MPXP_False; // Get the bandwidth available - networking->bandwidth = network_bandwidth; + networking->bandwidth = net_conf.bandwidth; // For RTP streams, we usually don't know the stream type until we open it. if( !strcasecmp( networking->url->protocol, "rtp")) { Modified: mplayerxp/libmpstream/network.h =================================================================== --- mplayerxp/libmpstream/network.h 2012-12-08 08:15:09 UTC (rev 520) +++ mplayerxp/libmpstream/network.h 2012-12-08 08:35:38 UTC (rev 521) @@ -30,6 +30,24 @@ struct libinput_t; class Tcp; } + +struct net_config_t { + public: + net_config_t(); + virtual ~net_config_t(); + + char* username; + char* password; + int bandwidth; + int cookies_enabled; + char* cookies_file; + char* useragent; +/* IPv6 options */ + int prefer_ipv4; + int ipv4_only_proxy; +}; +extern net_config_t net_conf; + enum networking_status { networking_stopped_e, networking_playing_e Modified: mplayerxp/libmpstream/s_rtsp.cpp =================================================================== --- mplayerxp/libmpstream/s_rtsp.cpp 2012-12-08 08:15:09 UTC (rev 520) +++ mplayerxp/libmpstream/s_rtsp.cpp 2012-12-08 08:35:38 UTC (rev 521) @@ -137,7 +137,6 @@ return MPXP_Ok; } -extern int network_bandwidth; extern int index_mode; MPXP_Rc Rtsp_Stream_Interface::open(const char *filename,unsigned flags) { @@ -149,7 +148,7 @@ networking = new_networking(); if (!networking) return MPXP_False; - networking->bandwidth = network_bandwidth; + networking->bandwidth = net_conf.bandwidth; url = url_new (filename); networking->url = check4proxies (url); Modified: mplayerxp/libmpstream/s_udp.cpp =================================================================== --- mplayerxp/libmpstream/s_udp.cpp 2012-12-08 08:15:09 UTC (rev 520) +++ mplayerxp/libmpstream/s_udp.cpp 2012-12-08 08:35:38 UTC (rev 521) @@ -91,7 +91,6 @@ return MPXP_Ok; } -extern int network_bandwidth; MPXP_Rc Udp_Stream_Interface::open(const char *filename,unsigned flags) { URL_t *url; @@ -100,7 +99,7 @@ networking = new_networking(); if (!networking) return MPXP_False; - networking->bandwidth = network_bandwidth; + networking->bandwidth = net_conf.bandwidth; url = url_new (filename); networking->url = check4proxies (url); if (url->port == 0) { Modified: mplayerxp/libmpstream/stream.h =================================================================== --- mplayerxp/libmpstream/stream.h 2012-12-08 08:15:09 UTC (rev 520) +++ mplayerxp/libmpstream/stream.h 2012-12-08 08:35:38 UTC (rev 521) @@ -13,6 +13,7 @@ #include "network.h" #endif +struct networking_t; namespace mpxp { struct libinput_t; enum { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |