comparison rtsp.c @ 5333:715913c5514f libavformat

Support 3xx redirection in rtsp All the error codes 3xx got managed the same way. After setup/early play redirection will not be managed REDIRECT method is yet to be supported (if somebody knows a server implementing it please contact me)
author lu_zero
date Sun, 25 Oct 2009 00:06:31 +0000
parents 4449e753bc78
children cb9ef60a0f06
comparison
equal deleted inserted replaced
5332:ff45ef768724 5333:715913c5514f
702 skip_spaces(&p); 702 skip_spaces(&p);
703 av_strlcpy(reply->server, p, sizeof(reply->server)); 703 av_strlcpy(reply->server, p, sizeof(reply->server));
704 } else if (av_stristart(p, "Notice:", &p) || 704 } else if (av_stristart(p, "Notice:", &p) ||
705 av_stristart(p, "X-Notice:", &p)) { 705 av_stristart(p, "X-Notice:", &p)) {
706 reply->notice = strtol(p, NULL, 10); 706 reply->notice = strtol(p, NULL, 10);
707 } else if (av_stristart(p, "Location:", &p)) {
708 skip_spaces(&p);
709 av_strlcpy(reply->location, p , sizeof(reply->location));
707 } 710 }
708 } 711 }
709 712
710 /* skip a RTP/TCP interleaved packet */ 713 /* skip a RTP/TCP interleaved packet */
711 static void rtsp_skip_packet(AVFormatContext *s) 714 static void rtsp_skip_packet(AVFormatContext *s)
1178 int port, ret, err; 1181 int port, ret, err;
1179 RTSPMessageHeader reply1, *reply = &reply1; 1182 RTSPMessageHeader reply1, *reply = &reply1;
1180 unsigned char *content = NULL; 1183 unsigned char *content = NULL;
1181 int lower_transport_mask = 0; 1184 int lower_transport_mask = 0;
1182 char real_challenge[64]; 1185 char real_challenge[64];
1183 1186 redirect:
1184 /* extract hostname and port */ 1187 /* extract hostname and port */
1185 url_split(NULL, 0, auth, sizeof(auth), 1188 url_split(NULL, 0, auth, sizeof(auth),
1186 host, sizeof(host), &port, path, sizeof(path), s->filename); 1189 host, sizeof(host), &port, path, sizeof(path), s->filename);
1187 if (*auth) { 1190 if (*auth) {
1188 int auth_len = strlen(auth), b64_len = ((auth_len + 2) / 3) * 4 + 1; 1191 int auth_len = strlen(auth), b64_len = ((auth_len + 2) / 3) * 4 + 1;
1336 fail: 1339 fail:
1337 rtsp_close_streams(rt); 1340 rtsp_close_streams(rt);
1338 av_freep(&content); 1341 av_freep(&content);
1339 url_close(rt->rtsp_hd); 1342 url_close(rt->rtsp_hd);
1340 av_freep(&rt->auth_b64); 1343 av_freep(&rt->auth_b64);
1344 if (reply->status_code >=300 && reply->status_code < 400) {
1345 av_strlcpy(s->filename, reply->location, sizeof(s->filename));
1346 av_log(s, AV_LOG_INFO, "Status %d: Redirecting to %s\n",
1347 reply->status_code,
1348 s->filename);
1349 goto redirect;
1350 }
1341 return err; 1351 return err;
1342 } 1352 }
1343 1353
1344 static int tcp_read_packet(AVFormatContext *s, RTSPStream **prtsp_st, 1354 static int tcp_read_packet(AVFormatContext *s, RTSPStream **prtsp_st,
1345 uint8_t *buf, int buf_size) 1355 uint8_t *buf, int buf_size)