summaryrefslogtreecommitdiffstats
path: root/stream
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-12-22 13:11:22 +0100
committerwm4 <wm4@nowhere>2013-12-22 13:11:22 +0100
commit3a637d411f603fd82ee0bf8a181ea20d60e7c88f (patch)
treec6b8d073151f0952ddb3aa804eaec6546d49cf44 /stream
parent38be9d5fed172ab8ee24c8c2cb0c94fb41d02e37 (diff)
downloadmpv-3a637d411f603fd82ee0bf8a181ea20d60e7c88f.tar.bz2
mpv-3a637d411f603fd82ee0bf8a181ea20d60e7c88f.tar.xz
options: move network related options to MPOpts
Diffstat (limited to 'stream')
-rw-r--r--stream/cookies.c10
-rw-r--r--stream/cookies.h2
-rw-r--r--stream/stream_lavf.c27
3 files changed, 20 insertions, 19 deletions
diff --git a/stream/cookies.c b/stream/cookies.c
index f29db88b57..50f515f911 100644
--- a/stream/cookies.c
+++ b/stream/cookies.c
@@ -39,8 +39,6 @@
#define MAX_COOKIES 20
-char *cookies_file = NULL;
-
typedef struct cookie_list_type {
char *name;
char *value;
@@ -173,13 +171,13 @@ static struct cookie_list_type *load_cookies_from(struct mp_log *log,
// Return a cookies string as expected by lavf (libavformat/http.c). The format
// is like a Set-Cookie header (http://curl.haxx.se/rfc/cookie_spec.html),
// separated by newlines.
-char *cookies_lavf(struct mp_log *log)
+char *cookies_lavf(void *talloc_ctx, struct mp_log *log, char *file)
{
- if (!cookie_list && cookies_file)
- cookie_list = load_cookies_from(log, cookies_file, NULL);
+ if (!cookie_list && file && file[0])
+ cookie_list = load_cookies_from(log, file, NULL);
struct cookie_list_type *list = cookie_list;
- char *res = talloc_strdup(NULL, "");
+ char *res = talloc_strdup(talloc_ctx, "");
while (list) {
res = talloc_asprintf_append_buffer(res,
diff --git a/stream/cookies.h b/stream/cookies.h
index 86c1e3bce9..b2a31d066a 100644
--- a/stream/cookies.h
+++ b/stream/cookies.h
@@ -24,6 +24,6 @@
#ifndef MPLAYER_COOKIES_H
#define MPLAYER_COOKIES_H
-char *cookies_lavf(struct mp_log *log);
+char *cookies_lavf(void *talloc_ctx, struct mp_log *log, char *file);
#endif /* MPLAYER_COOKIES_H */
diff --git a/stream/stream_lavf.c b/stream/stream_lavf.c
index a161c19cf9..645fcb5c6c 100644
--- a/stream/stream_lavf.c
+++ b/stream/stream_lavf.c
@@ -131,6 +131,7 @@ static const char * const prefix[] = { "lavf://", "ffmpeg://" };
static int open_f(stream_t *stream, int mode)
{
+ struct MPOpts *opts = stream->opts;
int flags = 0;
AVIOContext *avio = NULL;
int res = STREAM_ERROR;
@@ -179,22 +180,24 @@ static int open_f(stream_t *stream, int mode)
}
// HTTP specific options (other protocols ignore them)
- if (network_useragent)
- av_dict_set(&dict, "user-agent", network_useragent, 0);
- if (network_cookies_enabled)
- av_dict_set(&dict, "cookies", talloc_steal(temp, cookies_lavf(stream->log)), 0);
- av_dict_set(&dict, "tls_verify", network_tls_verify ? "1" : "0", 0);
- if (network_tls_ca_file)
- av_dict_set(&dict, "ca_file", network_tls_ca_file, 0);
+ if (opts->network_useragent)
+ av_dict_set(&dict, "user-agent", opts->network_useragent, 0);
+ if (opts->network_cookies_enabled) {
+ char *file = opts->network_cookies_file;
+ av_dict_set(&dict, "cookies", cookies_lavf(temp, stream->log, file), 0);
+ }
+ av_dict_set(&dict, "tls_verify", opts->network_tls_verify ? "1" : "0", 0);
+ if (opts->network_tls_ca_file)
+ av_dict_set(&dict, "ca_file", opts->network_tls_ca_file, 0);
char *cust_headers = talloc_strdup(temp, "");
- if (network_referrer) {
+ if (opts->network_referrer) {
cust_headers = talloc_asprintf_append(cust_headers, "Referer: %s\r\n",
- network_referrer);
+ opts->network_referrer);
}
- if (network_http_header_fields) {
- for (int n = 0; network_http_header_fields[n]; n++) {
+ if (opts->network_http_header_fields) {
+ for (int n = 0; opts->network_http_header_fields[n]; n++) {
cust_headers = talloc_asprintf_append(cust_headers, "%s\r\n",
- network_http_header_fields[n]);
+ opts->network_http_header_fields[n]);
}
}
if (strlen(cust_headers))