mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-05-28 15:39:16 +00:00
avformat: Add the https protocol
Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
parent
558d192d23
commit
183baeadca
6 changed files with 30 additions and 5 deletions
|
@ -92,8 +92,8 @@ void ff_http_init_auth_state(URLContext *dest, const URLContext *src)
|
|||
/* return non zero if error */
|
||||
static int http_open_cnx(URLContext *h)
|
||||
{
|
||||
const char *path, *proxy_path;
|
||||
char hostname[1024], hoststr[1024];
|
||||
const char *path, *proxy_path, *lower_proto = "tcp";
|
||||
char hostname[1024], hoststr[1024], proto[10];
|
||||
char auth[1024];
|
||||
char path1[1024];
|
||||
char buf[1024];
|
||||
|
@ -109,7 +109,8 @@ static int http_open_cnx(URLContext *h)
|
|||
/* fill the dest addr */
|
||||
redo:
|
||||
/* needed in any case to build the host string */
|
||||
av_url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &port,
|
||||
av_url_split(proto, sizeof(proto), auth, sizeof(auth),
|
||||
hostname, sizeof(hostname), &port,
|
||||
path1, sizeof(path1), s->location);
|
||||
ff_url_join(hoststr, sizeof(hoststr), NULL, NULL, hostname, port, NULL);
|
||||
|
||||
|
@ -123,10 +124,15 @@ static int http_open_cnx(URLContext *h)
|
|||
else
|
||||
path = path1;
|
||||
}
|
||||
if (!strcmp(proto, "https")) {
|
||||
lower_proto = "tls";
|
||||
if (port < 0)
|
||||
port = 443;
|
||||
}
|
||||
if (port < 0)
|
||||
port = 80;
|
||||
|
||||
ff_url_join(buf, sizeof(buf), "tcp", NULL, hostname, port, NULL);
|
||||
ff_url_join(buf, sizeof(buf), lower_proto, NULL, hostname, port, NULL);
|
||||
err = ffurl_open(&hd, buf, AVIO_FLAG_READ_WRITE);
|
||||
if (err < 0)
|
||||
goto fail;
|
||||
|
@ -509,6 +515,7 @@ http_get_file_handle(URLContext *h)
|
|||
return ffurl_get_file_handle(s->hd);
|
||||
}
|
||||
|
||||
#if CONFIG_HTTP_PROTOCOL
|
||||
URLProtocol ff_http_protocol = {
|
||||
.name = "http",
|
||||
.url_open = http_open,
|
||||
|
@ -520,3 +527,17 @@ URLProtocol ff_http_protocol = {
|
|||
.priv_data_size = sizeof(HTTPContext),
|
||||
.priv_data_class = &httpcontext_class,
|
||||
};
|
||||
#endif
|
||||
#if CONFIG_HTTPS_PROTOCOL
|
||||
URLProtocol ff_https_protocol = {
|
||||
.name = "https",
|
||||
.url_open = http_open,
|
||||
.url_read = http_read,
|
||||
.url_write = http_write,
|
||||
.url_seek = http_seek,
|
||||
.url_close = http_close,
|
||||
.url_get_file_handle = http_get_file_handle,
|
||||
.priv_data_size = sizeof(HTTPContext),
|
||||
.priv_data_class = &httpcontext_class,
|
||||
};
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue