Browse code

avformat: Add the https protocol

Signed-off-by: Martin Storsjö <martin@martin.st>

Martin Storsjö authored on 2011/02/06 07:20:26
Showing 6 changed files
... ...
@@ -57,6 +57,7 @@ easier to use. The changes are:
57 57
 - 4:2:2 H.264 decoding support
58 58
 - Pulseaudio input device
59 59
 - replacement Indeo 3 decoder
60
+- TLS/SSL and HTTPS protocol support
60 61
 
61 62
 
62 63
 version 0.7:
... ...
@@ -1478,6 +1478,7 @@ x11_grab_device_indev_extralibs="-lX11 -lXext -lXfixes"
1478 1478
 gopher_protocol_deps="network"
1479 1479
 http_protocol_deps="network"
1480 1480
 http_protocol_select="tcp_protocol"
1481
+https_protocol_select="tls_protocol"
1481 1482
 mmsh_protocol_select="http_protocol"
1482 1483
 mmst_protocol_deps="network"
1483 1484
 rtmp_protocol_select="tcp_protocol"
... ...
@@ -322,6 +322,7 @@ OBJS-$(CONFIG_CRYPTO_PROTOCOL)           += crypto.o
322 322
 OBJS-$(CONFIG_FILE_PROTOCOL)             += file.o
323 323
 OBJS-$(CONFIG_GOPHER_PROTOCOL)           += gopher.o
324 324
 OBJS-$(CONFIG_HTTP_PROTOCOL)             += http.o httpauth.o
325
+OBJS-$(CONFIG_HTTPS_PROTOCOL)            += http.o httpauth.o
325 326
 OBJS-$(CONFIG_MMSH_PROTOCOL)             += mmsh.o mms.o asf.o
326 327
 OBJS-$(CONFIG_MMST_PROTOCOL)             += mmst.o mms.o asf.o
327 328
 OBJS-$(CONFIG_MD5_PROTOCOL)              += md5proto.o
... ...
@@ -241,6 +241,7 @@ void av_register_all(void)
241 241
     REGISTER_PROTOCOL (FILE, file);
242 242
     REGISTER_PROTOCOL (GOPHER, gopher);
243 243
     REGISTER_PROTOCOL (HTTP, http);
244
+    REGISTER_PROTOCOL (HTTPS, https);
244 245
     REGISTER_PROTOCOL (MMSH, mmsh);
245 246
     REGISTER_PROTOCOL (MMST, mmst);
246 247
     REGISTER_PROTOCOL (MD5,  md5);
... ...
@@ -92,8 +92,8 @@ void ff_http_init_auth_state(URLContext *dest, const URLContext *src)
92 92
 /* return non zero if error */
93 93
 static int http_open_cnx(URLContext *h)
94 94
 {
95
-    const char *path, *proxy_path;
96
-    char hostname[1024], hoststr[1024];
95
+    const char *path, *proxy_path, *lower_proto = "tcp";
96
+    char hostname[1024], hoststr[1024], proto[10];
97 97
     char auth[1024];
98 98
     char path1[1024];
99 99
     char buf[1024];
... ...
@@ -109,7 +109,8 @@ static int http_open_cnx(URLContext *h)
109 109
     /* fill the dest addr */
110 110
  redo:
111 111
     /* needed in any case to build the host string */
112
-    av_url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &port,
112
+    av_url_split(proto, sizeof(proto), auth, sizeof(auth),
113
+                 hostname, sizeof(hostname), &port,
113 114
                  path1, sizeof(path1), s->location);
114 115
     ff_url_join(hoststr, sizeof(hoststr), NULL, NULL, hostname, port, NULL);
115 116
 
... ...
@@ -123,10 +124,15 @@ static int http_open_cnx(URLContext *h)
123 123
         else
124 124
             path = path1;
125 125
     }
126
+    if (!strcmp(proto, "https")) {
127
+        lower_proto = "tls";
128
+        if (port < 0)
129
+            port = 443;
130
+    }
126 131
     if (port < 0)
127 132
         port = 80;
128 133
 
129
-    ff_url_join(buf, sizeof(buf), "tcp", NULL, hostname, port, NULL);
134
+    ff_url_join(buf, sizeof(buf), lower_proto, NULL, hostname, port, NULL);
130 135
     err = ffurl_open(&hd, buf, AVIO_FLAG_READ_WRITE);
131 136
     if (err < 0)
132 137
         goto fail;
... ...
@@ -509,6 +515,7 @@ http_get_file_handle(URLContext *h)
509 509
     return ffurl_get_file_handle(s->hd);
510 510
 }
511 511
 
512
+#if CONFIG_HTTP_PROTOCOL
512 513
 URLProtocol ff_http_protocol = {
513 514
     .name                = "http",
514 515
     .url_open            = http_open,
... ...
@@ -520,3 +527,17 @@ URLProtocol ff_http_protocol = {
520 520
     .priv_data_size      = sizeof(HTTPContext),
521 521
     .priv_data_class     = &httpcontext_class,
522 522
 };
523
+#endif
524
+#if CONFIG_HTTPS_PROTOCOL
525
+URLProtocol ff_https_protocol = {
526
+    .name                = "https",
527
+    .url_open            = http_open,
528
+    .url_read            = http_read,
529
+    .url_write           = http_write,
530
+    .url_seek            = http_seek,
531
+    .url_close           = http_close,
532
+    .url_get_file_handle = http_get_file_handle,
533
+    .priv_data_size      = sizeof(HTTPContext),
534
+    .priv_data_class     = &httpcontext_class,
535
+};
536
+#endif
... ...
@@ -24,7 +24,7 @@
24 24
 #include "libavutil/avutil.h"
25 25
 
26 26
 #define LIBAVFORMAT_VERSION_MAJOR 53
27
-#define LIBAVFORMAT_VERSION_MINOR 11
27
+#define LIBAVFORMAT_VERSION_MINOR 12
28 28
 #define LIBAVFORMAT_VERSION_MICRO  0
29 29
 
30 30
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \