comparison rtsp.c @ 5869:754103ee76de libavformat

Reconstruct the RTSP URL, in order to remove the auth part from the URL sent to the server Don't modify the user-specified s->filename at all, keep all modifications locally and in rt->control_uri.
author mstorsjo
date Tue, 23 Mar 2010 07:55:15 +0000
parents 80c95562a705
children b17b16b532ca
comparison
equal deleted inserted replaced
5868:92daebc423f4 5869:754103ee76de
1449 port = RTSP_DEFAULT_PORT; 1449 port = RTSP_DEFAULT_PORT;
1450 1450
1451 /* search for options */ 1451 /* search for options */
1452 option_list = strchr(path, '?'); 1452 option_list = strchr(path, '?');
1453 if (option_list) { 1453 if (option_list) {
1454 filename = strchr(s->filename, '?'); 1454 /* Strip out the RTSP specific options, write out the rest of
1455 * the options back into the same string. */
1456 filename = option_list;
1455 while (option_list) { 1457 while (option_list) {
1456 /* move the option pointer */ 1458 /* move the option pointer */
1457 option = ++option_list; 1459 option = ++option_list;
1458 option_list = strchr(option_list, '&'); 1460 option_list = strchr(option_list, '&');
1459 if (option_list) 1461 if (option_list)
1465 } else if (!strcmp(option, "multicast")) { 1467 } else if (!strcmp(option, "multicast")) {
1466 lower_transport_mask = (1<< RTSP_LOWER_TRANSPORT_UDP_MULTICAST); 1468 lower_transport_mask = (1<< RTSP_LOWER_TRANSPORT_UDP_MULTICAST);
1467 } else if (!strcmp(option, "tcp")) { 1469 } else if (!strcmp(option, "tcp")) {
1468 lower_transport_mask = (1<< RTSP_LOWER_TRANSPORT_TCP); 1470 lower_transport_mask = (1<< RTSP_LOWER_TRANSPORT_TCP);
1469 } else { 1471 } else {
1470 strcpy(++filename, option); 1472 /* Write options back into the buffer, using memmove instead
1471 filename += strlen(option); 1473 * of strcpy since the strings may overlap. */
1474 int len = strlen(option);
1475 memmove(++filename, option, len);
1476 filename += len;
1472 if (option_list) *filename = '&'; 1477 if (option_list) *filename = '&';
1473 } 1478 }
1474 } 1479 }
1475 *filename = 0; 1480 *filename = 0;
1476 } 1481 }
1503 if (!getpeername(tcp_fd, (struct sockaddr*) &peer, &peer_len)) { 1508 if (!getpeername(tcp_fd, (struct sockaddr*) &peer, &peer_len)) {
1504 getnameinfo((struct sockaddr*) &peer, peer_len, host, sizeof(host), 1509 getnameinfo((struct sockaddr*) &peer, peer_len, host, sizeof(host),
1505 NULL, 0, NI_NUMERICHOST); 1510 NULL, 0, NI_NUMERICHOST);
1506 } 1511 }
1507 1512
1513 /* Construct the URI used in request; this is similar to s->filename,
1514 * but with authentication credentials removed and RTSP specific options
1515 * stripped out. */
1516 ff_url_join(rt->control_uri, sizeof(rt->control_uri), "rtsp", NULL,
1517 host, port, "%s", path);
1508 /* request options supported by the server; this also detects server 1518 /* request options supported by the server; this also detects server
1509 * type */ 1519 * type */
1510 av_strlcpy(rt->control_uri, s->filename,
1511 sizeof(rt->control_uri));
1512 for (rt->server_type = RTSP_SERVER_RTP;;) { 1520 for (rt->server_type = RTSP_SERVER_RTP;;) {
1513 snprintf(cmd, sizeof(cmd), 1521 snprintf(cmd, sizeof(cmd),
1514 "OPTIONS %s RTSP/1.0\r\n", rt->control_uri); 1522 "OPTIONS %s RTSP/1.0\r\n", rt->control_uri);
1515 if (rt->server_type == RTSP_SERVER_REAL) 1523 if (rt->server_type == RTSP_SERVER_REAL)
1516 av_strlcat(cmd, 1524 av_strlcat(cmd,