@@ -63,10 +63,10 @@ index 62619b3..dab19e8 100644
63
63
64
64
*got_picture_ptr = finish_frame(avctx, pict);
65
65
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
66
- index ddd63db..8b5b087 100644
66
+ index 63aa862..acba3cc 100644
67
67
--- a/libavcodec/utils.c
68
68
+++ b/libavcodec/utils.c
69
- @@ -1986 ,6 +1986 ,8 @@ void avcodec_flush_buffers(AVCodecContext *avctx)
69
+ @@ -2040 ,6 +2040 ,8 @@ void avcodec_flush_buffers(AVCodecContext *avctx)
70
70
static void video_free_buffers(AVCodecContext *s)
71
71
{
72
72
AVCodecInternal *avci = s->internal;
@@ -76,18 +76,18 @@ index ddd63db..8b5b087 100644
76
76
77
77
if (!avci->buffer)
78
78
diff --git a/libavformat/Makefile b/libavformat/Makefile
79
- index 54b26c1..b542d43 100644
79
+ index 45ae6ea..4387ff1 100644
80
80
--- a/libavformat/Makefile
81
81
+++ b/libavformat/Makefile
82
- @@ -371,6 +371,7 @@ OBJS-$(CONFIG_CACHE_PROTOCOL) += cache.o
83
- OBJS-$(CONFIG_CONCAT_PROTOCOL) += concat.o
82
+ @@ -375,6 +375,7 @@ OBJS-$(CONFIG_CONCAT_PROTOCOL) += concat.o
84
83
OBJS-$(CONFIG_CRYPTO_PROTOCOL) += crypto.o
84
+ OBJS-$(CONFIG_FFRTMPHTTP_PROTOCOL) += rtmphttp.o
85
85
OBJS-$(CONFIG_FILE_PROTOCOL) += file.o
86
86
+ OBJS-$(CONFIG_FD_PROTOCOL) += fd.o
87
87
OBJS-$(CONFIG_GOPHER_PROTOCOL) += gopher.o
88
88
OBJS-$(CONFIG_HLS_PROTOCOL) += hlsproto.o
89
89
OBJS-$(CONFIG_HTTP_PROTOCOL) += http.o httpauth.o
90
- @@ -378 ,6 +379 ,7 @@ OBJS-$(CONFIG_HTTPPROXY_PROTOCOL) += http.o httpauth.o
90
+ @@ -382 ,6 +383 ,7 @@ OBJS-$(CONFIG_HTTPPROXY_PROTOCOL) += http.o httpauth.o
91
91
OBJS-$(CONFIG_HTTPS_PROTOCOL) += http.o httpauth.o
92
92
OBJS-$(CONFIG_MMSH_PROTOCOL) += mmsh.o mms.o asf.o
93
93
OBJS-$(CONFIG_MMST_PROTOCOL) += mmst.o mms.o asf.o
@@ -96,25 +96,38 @@ index 54b26c1..b542d43 100644
96
96
OBJS-$(CONFIG_PIPE_PROTOCOL) += file.o
97
97
OBJS-$(CONFIG_RTMP_PROTOCOL) += rtmpproto.o rtmppkt.o
98
98
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
99
- index 7ea4ebb..b0ccebf 100644
99
+ index 94dc347..68e5525 100644
100
100
--- a/libavformat/allformats.c
101
101
+++ b/libavformat/allformats.c
102
- @@ -273,6 +273,7 @@ void av_register_all(void)
103
- REGISTER_PROTOCOL (CONCAT, concat);
102
+ @@ -274,6 +274,7 @@ void av_register_all(void)
104
103
REGISTER_PROTOCOL (CRYPTO, crypto);
104
+ REGISTER_PROTOCOL (FFRTMPHTTP, ffrtmphttp);
105
105
REGISTER_PROTOCOL (FILE, file);
106
106
+ REGISTER_PROTOCOL (FD, fd);
107
107
REGISTER_PROTOCOL (GOPHER, gopher);
108
108
REGISTER_PROTOCOL (HLS, hls);
109
109
REGISTER_PROTOCOL (HTTP, http);
110
- @@ -280 ,6 +281 ,7 @@ void av_register_all(void)
110
+ @@ -281 ,6 +282 ,7 @@ void av_register_all(void)
111
111
REGISTER_PROTOCOL (HTTPS, https);
112
112
REGISTER_PROTOCOL (MMSH, mmsh);
113
113
REGISTER_PROTOCOL (MMST, mmst);
114
114
+ REGISTER_PROTOCOL (MMSU, mmsu);
115
115
REGISTER_PROTOCOL (MD5, md5);
116
116
REGISTER_PROTOCOL (PIPE, pipe);
117
117
REGISTER_PROTOCOL (RTMP, rtmp);
118
+ diff --git a/libavformat/avformat.h b/libavformat/avformat.h
119
+ index 3bbc683..327edbc 100644
120
+ --- a/libavformat/avformat.h
121
+ +++ b/libavformat/avformat.h
122
+ @@ -912,7 +912,7 @@ typedef struct AVFormatContext {
123
+ unsigned int nb_streams;
124
+ AVStream **streams;
125
+
126
+ - char filename[1024]; /**< input or output filename */
127
+ + char filename[10240]; /**< input or output filename */
128
+
129
+ /**
130
+ * Decoding: position of the first frame of the component, in
118
131
diff --git a/libavformat/fd.c b/libavformat/fd.c
119
132
new file mode 100644
120
133
index 0000000..d8d2e41
@@ -299,7 +312,7 @@ index a51a616..bf4c7f5 100644
299
312
}
300
313
return AVERROR_EOF;
301
314
diff --git a/libavformat/http.c b/libavformat/http.c
302
- index 5355bdc..366b814 100644
315
+ index 5355bdc..0472cf3 100644
303
316
--- a/libavformat/http.c
304
317
+++ b/libavformat/http.c
305
318
@@ -1,6 +1,7 @@
@@ -310,25 +323,90 @@ index 5355bdc..366b814 100644
310
323
*
311
324
* This file is part of FFmpeg.
312
325
*
313
- @@ -36,6 +37,8 @@
314
- #define BUFFER_SIZE 1024
326
+ @@ -33,9 +34,11 @@
327
+ only a subset of it. */
328
+
329
+ /* used for protocol handling */
330
+ - #define BUFFER_SIZE 1024
331
+ + #define BUFFER_SIZE 10240
315
332
#define MAX_REDIRECTS 8
316
333
317
334
+ #define DEFAULT_UA "Mozilla/5.0 (iPad; U; CPU OS 4_2_1 like Mac OS X; zh-cn) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148 Safari/6533.18.5"
318
335
+
319
336
typedef struct {
320
337
const AVClass *class;
321
338
URLContext *hd;
322
- @@ -404,14 +407,15 @@ static int http_connect(URLContext *h, const char *path, const char *local_path,
323
- local_path, method);
339
+ @@ -99,11 +102,11 @@ void ff_http_init_auth_state(URLContext *dest, const URLContext *src)
340
+ static int http_open_cnx(URLContext *h)
341
+ {
342
+ const char *path, *proxy_path, *lower_proto = "tcp", *local_path;
343
+ - char hostname[1024], hoststr[1024], proto[10];
344
+ - char auth[1024], proxyauth[1024] = "";
345
+ - char path1[1024];
346
+ - char buf[1024], urlbuf[1024];
347
+ - int port, use_proxy, err, location_changed = 0, redirects = 0, attempts = 0;
348
+ + char hostname[10240], hoststr[10240], proto[10];
349
+ + char auth[10240], proxyauth[10240] = "";
350
+ + char path1[10240];
351
+ + char buf[10240], urlbuf[10240];
352
+ + int port, use_proxy, err, location_changed = 0, redirects = 0, attempts = 0, change_ua = 0;
353
+ HTTPAuthType cur_auth_type, cur_proxy_auth_type;
354
+ HTTPContext *s = h->priv_data;
324
355
325
- /* set default headers if needed */
326
- + av_log(h, AV_LOG_VERBOSE, "HTTP host %s %s\n", hoststr, strstr(hoststr, "youku.com"));
327
- if (!has_header(s->headers, "\r\nUser-Agent: "))
328
- len += av_strlcatf(headers + len, sizeof(headers) - len,
329
- "User-Agent: %s\r\n",
330
- - s->user_agent ? s->user_agent : LIBAVFORMAT_IDENT);
331
- + s->user_agent ? s->user_agent : DEFAULT_UA);
356
+ @@ -165,6 +168,15 @@ static int http_open_cnx(URLContext *h)
357
+ } else
358
+ goto fail;
359
+ }
360
+ + if (s->http_code == 403 && !change_ua) {
361
+ + av_opt_set(s, "user-agent", DEFAULT_UA, 0);
362
+ + ffurl_closep(&s->hd);
363
+ + memset(&s->auth_state, 0, sizeof(s->auth_state));
364
+ + attempts = 0;
365
+ + location_changed = 0;
366
+ + change_ua = 1;
367
+ + goto redo;
368
+ + }
369
+ if (s->http_code == 407) {
370
+ if ((cur_proxy_auth_type == HTTP_AUTH_NONE || s->proxy_auth_state.stale) &&
371
+ s->proxy_auth_state.auth_type != HTTP_AUTH_NONE && attempts < 4) {
372
+ @@ -285,9 +297,9 @@ static int process_line(URLContext *h, char *line, int line_count,
373
+
374
+ /* error codes are 4xx and 5xx, but regard 401 as a success, so we
375
+ * don't abort until all headers have been parsed. */
376
+ - if (s->http_code >= 400 && s->http_code < 600 && (s->http_code != 401
377
+ - || s->auth_state.auth_type != HTTP_AUTH_NONE) &&
378
+ - (s->http_code != 407 || s->proxy_auth_state.auth_type != HTTP_AUTH_NONE)) {
379
+ + if (s->http_code >= 400 && s->http_code < 600 && s->http_code != 403
380
+ + && (s->http_code != 401 || s->auth_state.auth_type != HTTP_AUTH_NONE)
381
+ + && (s->http_code != 407 || s->proxy_auth_state.auth_type != HTTP_AUTH_NONE)) {
382
+ end += strspn(end, SPACE_CHARS);
383
+ av_log(h, AV_LOG_WARNING, "HTTP error %d %s\n",
384
+ s->http_code, end);
385
+ @@ -352,7 +364,7 @@ static inline int has_header(const char *str, const char *header)
386
+ static int http_read_header(URLContext *h, int *new_location)
387
+ {
388
+ HTTPContext *s = h->priv_data;
389
+ - char line[1024];
390
+ + char line[10240];
391
+ int err = 0;
392
+
393
+ s->chunksize = -1;
394
+ @@ -380,13 +392,12 @@ static int http_connect(URLContext *h, const char *path, const char *local_path,
395
+ {
396
+ HTTPContext *s = h->priv_data;
397
+ int post, err;
398
+ - char headers[1024] = "";
399
+ + char headers[10240] = "";
400
+ char *authstr = NULL, *proxyauthstr = NULL;
401
+ int64_t off = s->off;
402
+ int len = 0;
403
+ const char *method;
404
+
405
+ -
406
+ /* send http header */
407
+ post = h->flags & AVIO_FLAG_WRITE;
408
+
409
+ @@ -411,7 +422,7 @@ static int http_connect(URLContext *h, const char *path, const char *local_path,
332
410
if (!has_header(s->headers, "\r\nAccept: "))
333
411
len += av_strlcpy(headers + len, "Accept: */*\r\n",
334
412
sizeof(headers) - len);
@@ -337,17 +415,37 @@ index 5355bdc..366b814 100644
337
415
len += av_strlcatf(headers + len, sizeof(headers) - len,
338
416
"Range: bytes=%"PRId64"-\r\n", s->off);
339
417
340
- @@ -450,6 +454 ,8 @@ static int http_connect(URLContext *h, const char *path, const char *local_path,
418
+ @@ -450,6 +461 ,8 @@ static int http_connect(URLContext *h, const char *path, const char *local_path,
341
419
authstr ? authstr : "",
342
420
proxyauthstr ? "Proxy-" : "", proxyauthstr ? proxyauthstr : "");
343
421
344
422
+
345
- + av_log(h, AV_LOG_VERBOSE , "HTTP HEADERS: \n%s\n", s->buffer);
423
+ + av_dlog(h , "HTTP HEADERS: \n%s\n", s->buffer);
346
424
av_freep(&authstr);
347
425
av_freep(&proxyauthstr);
348
426
if ((err = ffurl_write(s->hd, s->buffer, strlen(s->buffer))) < 0)
427
+ @@ -479,7 +492,7 @@ static int http_connect(URLContext *h, const char *path, const char *local_path,
428
+ /* wait for header */
429
+ err = http_read_header(h, new_location);
430
+ if (err < 0)
431
+ - return err;
432
+ + return err;
433
+
434
+ return (off == s->off) ? 0 : -1;
435
+ }
436
+ @@ -691,8 +704,8 @@ static int http_proxy_close(URLContext *h)
437
+ static int http_proxy_open(URLContext *h, const char *uri, int flags)
438
+ {
439
+ HTTPContext *s = h->priv_data;
440
+ - char hostname[1024], hoststr[1024];
441
+ - char auth[1024], pathbuf[1024], *path;
442
+ + char hostname[10240], hoststr[10240];
443
+ + char auth[10240], pathbuf[10240], *path;
444
+ char lower_url[100];
445
+ int port, ret = 0, attempts = 0;
446
+ HTTPAuthType cur_auth_type;
349
447
diff --git a/libavformat/isom.h b/libavformat/isom.h
350
- index 5f7f189..202b66a 100644
448
+ index f1cbe8c..9f6645a 100644
351
449
--- a/libavformat/isom.h
352
450
+++ b/libavformat/isom.h
353
451
@@ -3,6 +3,7 @@
@@ -358,7 +456,7 @@ index 5f7f189..202b66a 100644
358
456
*
359
457
* This file is part of FFmpeg.
360
458
*
361
- @@ -154 ,6 +155 ,8 @@ typedef struct MOVContext {
459
+ @@ -155 ,6 +156 ,8 @@ typedef struct MOVContext {
362
460
int chapter_track;
363
461
int use_absolute_path;
364
462
int64_t next_root_atom; ///< offset of the next root atom
@@ -522,7 +620,7 @@ index 0000000..33e96e6
522
620
+ .url_close = mmsu_close,
523
621
+ };
524
622
diff --git a/libavformat/mov.c b/libavformat/mov.c
525
- index becfeec..4d90933 100644
623
+ index b4295f8..f53bddb 100644
526
624
--- a/libavformat/mov.c
527
625
+++ b/libavformat/mov.c
528
626
@@ -2,6 +2,7 @@
0 commit comments