Still hardcoded to use Basic auth, without parsing the reply headers
Originally committed as revision 22676 to svn://svn.ffmpeg.org/ffmpeg/trunk
... | ... |
@@ -215,8 +215,8 @@ OBJS-$(CONFIG_RTP_MUXER) += rtp.o \ |
215 | 215 |
rtpenc.o \ |
216 | 216 |
rtpenc_h264.o \ |
217 | 217 |
avc.o |
218 |
-OBJS-$(CONFIG_RTSP_DEMUXER) += rtsp.o |
|
219 |
-OBJS-$(CONFIG_RTSP_MUXER) += rtsp.o rtspenc.o |
|
218 |
+OBJS-$(CONFIG_RTSP_DEMUXER) += rtsp.o httpauth.o |
|
219 |
+OBJS-$(CONFIG_RTSP_MUXER) += rtsp.o rtspenc.o httpauth.o |
|
220 | 220 |
OBJS-$(CONFIG_SDP_DEMUXER) += rtsp.o \ |
221 | 221 |
rdt.o \ |
222 | 222 |
rtp.o \ |
... | ... |
@@ -612,7 +612,6 @@ void ff_rtsp_close_streams(AVFormatContext *s) |
612 | 612 |
av_close_input_stream (rt->asf_ctx); |
613 | 613 |
rt->asf_ctx = NULL; |
614 | 614 |
} |
615 |
- av_freep(&rt->auth_b64); |
|
616 | 615 |
} |
617 | 616 |
|
618 | 617 |
static void *rtsp_rtp_mux_open(AVFormatContext *s, AVStream *st, |
... | ... |
@@ -1013,10 +1012,13 @@ void ff_rtsp_send_cmd_with_content_async(AVFormatContext *s, |
1013 | 1013 |
snprintf(buf1, sizeof(buf1), "Session: %s\r\n", rt->session_id); |
1014 | 1014 |
av_strlcat(buf, buf1, sizeof(buf)); |
1015 | 1015 |
} |
1016 |
- if (rt->auth_b64) |
|
1017 |
- av_strlcatf(buf, sizeof(buf), |
|
1018 |
- "Authorization: Basic %s\r\n", |
|
1019 |
- rt->auth_b64); |
|
1016 |
+ if (rt->auth[0]) { |
|
1017 |
+ char *str = ff_http_auth_create_response(&rt->auth_state, |
|
1018 |
+ rt->auth, url, method); |
|
1019 |
+ if (str) |
|
1020 |
+ av_strlcat(buf, str, sizeof(buf)); |
|
1021 |
+ av_free(str); |
|
1022 |
+ } |
|
1020 | 1023 |
if (send_content_length > 0 && send_content) |
1021 | 1024 |
av_strlcatf(buf, sizeof(buf), "Content-Length: %d\r\n", send_content_length); |
1022 | 1025 |
av_strlcat(buf, "\r\n", sizeof(buf)); |
... | ... |
@@ -1437,14 +1439,8 @@ redirect: |
1437 | 1437 |
ff_url_split(NULL, 0, auth, sizeof(auth), |
1438 | 1438 |
host, sizeof(host), &port, path, sizeof(path), s->filename); |
1439 | 1439 |
if (*auth) { |
1440 |
- int auth_len = strlen(auth), b64_len = ((auth_len + 2) / 3) * 4 + 1; |
|
1441 |
- |
|
1442 |
- if (!(rt->auth_b64 = av_malloc(b64_len))) |
|
1443 |
- return AVERROR(ENOMEM); |
|
1444 |
- if (!av_base64_encode(rt->auth_b64, b64_len, auth, auth_len)) { |
|
1445 |
- err = AVERROR(EINVAL); |
|
1446 |
- goto fail; |
|
1447 |
- } |
|
1440 |
+ av_strlcpy(rt->auth, auth, sizeof(rt->auth)); |
|
1441 |
+ rt->auth_state.auth_type = HTTP_AUTH_BASIC; |
|
1448 | 1442 |
} |
1449 | 1443 |
if (port < 0) |
1450 | 1444 |
port = RTSP_DEFAULT_PORT; |
... | ... |
@@ -26,6 +26,7 @@ |
26 | 26 |
#include "rtspcodes.h" |
27 | 27 |
#include "rtpdec.h" |
28 | 28 |
#include "network.h" |
29 |
+#include "httpauth.h" |
|
29 | 30 |
|
30 | 31 |
/** |
31 | 32 |
* Network layer over which RTP/etc packet data will be transported. |
... | ... |
@@ -232,8 +233,11 @@ typedef struct RTSPState { |
232 | 232 |
* of RTSPMessageHeader->real_challenge */ |
233 | 233 |
enum RTSPServerType server_type; |
234 | 234 |
|
235 |
- /** base64-encoded authorization lines (username:password) */ |
|
236 |
- char *auth_b64; |
|
235 |
+ /** plaintext authorization line (username:password) */ |
|
236 |
+ char auth[128]; |
|
237 |
+ |
|
238 |
+ /** authentication state */ |
|
239 |
+ HTTPAuthState auth_state; |
|
237 | 240 |
|
238 | 241 |
/** The last reply of the server to a RTSP command */ |
239 | 242 |
char last_reply[2048]; /* XXX: allocate ? */ |