mirror of https://git.ffmpeg.org/ffmpeg.git
Make the http protocol open the connection immediately in http_open again
Also make the RTSP protocol use url_alloc and url_connect instead of relying on the delay open behaviour. Originally committed as revision 23710 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
4167ba0bc8
commit
9290f15d00
|
@ -48,7 +48,6 @@ typedef struct {
|
|||
int64_t off, filesize;
|
||||
char location[URL_SIZE];
|
||||
HTTPAuthState auth_state;
|
||||
int init;
|
||||
unsigned char headers[BUFFER_SIZE];
|
||||
} HTTPContext;
|
||||
|
||||
|
@ -99,7 +98,6 @@ static int http_open_cnx(URLContext *h)
|
|||
HTTPContext *s = h->priv_data;
|
||||
URLContext *hd = NULL;
|
||||
|
||||
s->init = 1;
|
||||
proxy_path = getenv("http_proxy");
|
||||
use_proxy = (proxy_path != NULL) && !getenv("no_proxy") &&
|
||||
av_strstart(proxy_path, "http://", NULL);
|
||||
|
@ -165,7 +163,7 @@ static int http_open(URLContext *h, const char *uri, int flags)
|
|||
s->filesize = -1;
|
||||
av_strlcpy(s->location, uri, URL_SIZE);
|
||||
|
||||
return 0;
|
||||
return http_open_cnx(h);
|
||||
}
|
||||
static int http_getc(HTTPContext *s)
|
||||
{
|
||||
|
@ -368,19 +366,6 @@ static int http_read(URLContext *h, uint8_t *buf, int size)
|
|||
HTTPContext *s = h->priv_data;
|
||||
int len;
|
||||
|
||||
if (!s->init) {
|
||||
int ret = http_open_cnx(h);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
}
|
||||
if (!s->hd)
|
||||
return AVERROR(EIO);
|
||||
|
||||
/* A size of zero can be used to force
|
||||
* initializaton of the connection. */
|
||||
if (!size)
|
||||
return 0;
|
||||
|
||||
if (s->chunksize >= 0) {
|
||||
if (!s->chunksize) {
|
||||
char line[32];
|
||||
|
@ -428,14 +413,6 @@ static int http_write(URLContext *h, const uint8_t *buf, int size)
|
|||
char crlf[] = "\r\n";
|
||||
HTTPContext *s = h->priv_data;
|
||||
|
||||
if (!s->init) {
|
||||
int ret = http_open_cnx(h);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
}
|
||||
if (!s->hd)
|
||||
return AVERROR(EIO);
|
||||
|
||||
if (s->chunksize == -1) {
|
||||
/* non-chunked data is sent without any special encoding */
|
||||
return url_write(s->hd, buf, size);
|
||||
|
@ -480,14 +457,6 @@ static int64_t http_seek(URLContext *h, int64_t off, int whence)
|
|||
uint8_t old_buf[BUFFER_SIZE];
|
||||
int old_buf_size;
|
||||
|
||||
if (!s->init) {
|
||||
int ret = http_open_cnx(h);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
}
|
||||
if (!s->hd)
|
||||
return AVERROR(EIO);
|
||||
|
||||
if (whence == AVSEEK_SIZE)
|
||||
return s->filesize;
|
||||
else if ((s->filesize == -1 && whence == SEEK_END) || h->is_streamed)
|
||||
|
|
|
@ -1578,7 +1578,7 @@ redirect:
|
|||
av_get_random_seed(), av_get_random_seed());
|
||||
|
||||
/* GET requests */
|
||||
if (url_open(&rt->rtsp_hd, httpname, URL_RDONLY) < 0) {
|
||||
if (url_alloc(&rt->rtsp_hd, httpname, URL_RDONLY) < 0) {
|
||||
err = AVERROR(EIO);
|
||||
goto fail;
|
||||
}
|
||||
|
@ -1593,13 +1593,13 @@ redirect:
|
|||
ff_http_set_headers(rt->rtsp_hd, headers);
|
||||
|
||||
/* complete the connection */
|
||||
if (url_read(rt->rtsp_hd, NULL, 0)) {
|
||||
if (url_connect(rt->rtsp_hd)) {
|
||||
err = AVERROR(EIO);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* POST requests */
|
||||
if (url_open(&rt->rtsp_hd_out, httpname, URL_WRONLY) < 0 ) {
|
||||
if (url_alloc(&rt->rtsp_hd_out, httpname, URL_WRONLY) < 0 ) {
|
||||
err = AVERROR(EIO);
|
||||
goto fail;
|
||||
}
|
||||
|
@ -1634,6 +1634,11 @@ redirect:
|
|||
*/
|
||||
ff_http_init_auth_state(rt->rtsp_hd_out, rt->rtsp_hd);
|
||||
|
||||
/* complete the connection */
|
||||
if (url_connect(rt->rtsp_hd_out)) {
|
||||
err = AVERROR(EIO);
|
||||
goto fail;
|
||||
}
|
||||
} else {
|
||||
/* open the tcp connection */
|
||||
ff_url_join(tcpname, sizeof(tcpname), "tcp", NULL, host, port, NULL);
|
||||
|
|
Loading…
Reference in New Issue