comparison rtsp.c @ 6164:72ea866c62fd libavformat

Make the http protocol open the connection immediately in http_open again Also make the RTSP protocol use url_alloc and url_connect instead of relying on the delay open behaviour.
author mstorsjo
date Tue, 22 Jun 2010 14:15:00 +0000
parents f403b7c0e51b
children 0e737c9247fd
comparison
equal deleted inserted replaced
6163:2e0ee73855cd 6164:72ea866c62fd
1576 ff_url_join(httpname, sizeof(httpname), "http", auth, host, port, "%s", path); 1576 ff_url_join(httpname, sizeof(httpname), "http", auth, host, port, "%s", path);
1577 snprintf(sessioncookie, sizeof(sessioncookie), "%08x%08x", 1577 snprintf(sessioncookie, sizeof(sessioncookie), "%08x%08x",
1578 av_get_random_seed(), av_get_random_seed()); 1578 av_get_random_seed(), av_get_random_seed());
1579 1579
1580 /* GET requests */ 1580 /* GET requests */
1581 if (url_open(&rt->rtsp_hd, httpname, URL_RDONLY) < 0) { 1581 if (url_alloc(&rt->rtsp_hd, httpname, URL_RDONLY) < 0) {
1582 err = AVERROR(EIO); 1582 err = AVERROR(EIO);
1583 goto fail; 1583 goto fail;
1584 } 1584 }
1585 1585
1586 /* generate GET headers */ 1586 /* generate GET headers */
1591 "Cache-Control: no-cache\r\n", 1591 "Cache-Control: no-cache\r\n",
1592 sessioncookie); 1592 sessioncookie);
1593 ff_http_set_headers(rt->rtsp_hd, headers); 1593 ff_http_set_headers(rt->rtsp_hd, headers);
1594 1594
1595 /* complete the connection */ 1595 /* complete the connection */
1596 if (url_read(rt->rtsp_hd, NULL, 0)) { 1596 if (url_connect(rt->rtsp_hd)) {
1597 err = AVERROR(EIO); 1597 err = AVERROR(EIO);
1598 goto fail; 1598 goto fail;
1599 } 1599 }
1600 1600
1601 /* POST requests */ 1601 /* POST requests */
1602 if (url_open(&rt->rtsp_hd_out, httpname, URL_WRONLY) < 0 ) { 1602 if (url_alloc(&rt->rtsp_hd_out, httpname, URL_WRONLY) < 0 ) {
1603 err = AVERROR(EIO); 1603 err = AVERROR(EIO);
1604 goto fail; 1604 goto fail;
1605 } 1605 }
1606 1606
1607 /* generate POST headers */ 1607 /* generate POST headers */
1632 * count variable between the two sessions, if we'd do more requests 1632 * count variable between the two sessions, if we'd do more requests
1633 * with the original session, though.) 1633 * with the original session, though.)
1634 */ 1634 */
1635 ff_http_init_auth_state(rt->rtsp_hd_out, rt->rtsp_hd); 1635 ff_http_init_auth_state(rt->rtsp_hd_out, rt->rtsp_hd);
1636 1636
1637 /* complete the connection */
1638 if (url_connect(rt->rtsp_hd_out)) {
1639 err = AVERROR(EIO);
1640 goto fail;
1641 }
1637 } else { 1642 } else {
1638 /* open the tcp connection */ 1643 /* open the tcp connection */
1639 ff_url_join(tcpname, sizeof(tcpname), "tcp", NULL, host, port, NULL); 1644 ff_url_join(tcpname, sizeof(tcpname), "tcp", NULL, host, port, NULL);
1640 if (url_open(&rt->rtsp_hd, tcpname, URL_RDWR) < 0) { 1645 if (url_open(&rt->rtsp_hd, tcpname, URL_RDWR) < 0) {
1641 err = AVERROR(EIO); 1646 err = AVERROR(EIO);