options: add --network-timeout

Not quite sure if this actually works as intended.

Fixes #1566.
This commit is contained in:
wm4 2015-02-06 17:01:35 +01:00
parent ffe894ec0a
commit f3ae845fd2
4 changed files with 11 additions and 0 deletions

View File

@ -3135,6 +3135,11 @@ Network
``--referrer=<string>``
Specify a referrer path or URL for HTTP requests.
``--network-timeout=<seconds>``
Specify the network timeout in seconds. This affects at least HTTP. The
special value 0 (default) uses the FFmpeg/Libav defaults. If a protocol
is used which does not support timeouts, this option is silently ignored.
``--rtsp-transport=<lavf|udp|tcp|http>``
Select RTSP transport method (default: tcp). This selects the underlying
network transport when playing ``rtsp://...`` URLs. The value ``lavf``

View File

@ -173,6 +173,7 @@ const m_option_t mp_opts[] = {
{"http", 3})),
OPT_FLAG("tls-verify", network_tls_verify, 0),
OPT_STRING("tls-ca-file", network_tls_ca_file, M_OPT_FILE),
OPT_DOUBLE("network-timeout", network_timeout, M_OPT_MIN, .min = 0),
// ------------------------- demuxer options --------------------
@ -730,6 +731,7 @@ const struct MPOpts mp_default_opts = {
.demuxer_min_bytes = 0,
.demuxer_min_secs = 0.2,
.network_rtsp_transport = 2,
.network_timeout = 0.0,
.hls_bitrate = 2,
.demuxer_min_secs_cache = 2,
.cache_pausing = 1,

View File

@ -274,6 +274,7 @@ typedef struct MPOpts {
char **network_http_header_fields;
int network_tls_verify;
char *network_tls_ca_file;
double network_timeout;
struct tv_params *tv_params;
struct pvr_params *stream_pvr_opts;

View File

@ -181,6 +181,9 @@ void mp_setup_av_network_options(AVDictionary **dict, struct mpv_global *global,
if (strlen(cust_headers))
av_dict_set(dict, "headers", cust_headers, 0);
av_dict_set(dict, "icy", "1", 0);
// So far, every known protocol uses microseconds for this
if (opts->network_timeout > 0)
av_dict_set_int(dict, "timeout", opts->network_timeout * 1e6, 0);
mp_set_avdict(dict, opts->stream_lavf_opts->avopts);