Revision 57b5555c libavformat/rtsp.c

View differences:

libavformat/rtsp.c
1090 1090
            /* first try in specified port range */
1091 1091
            if (RTSP_RTP_PORT_MIN != 0) {
1092 1092
                while (j <= RTSP_RTP_PORT_MAX) {
1093
                    snprintf(buf, sizeof(buf), "rtp://%s?localport=%d",
1094
                             host, j);
1093
                    ff_url_join(buf, sizeof(buf), "rtp", NULL, host, -1,
1094
                                "?localport=%d", j);
1095 1095
                    /* we will use two ports per rtp stream (rtp and rtcp) */
1096 1096
                    j += 2;
1097 1097
                    if (url_open(&rtsp_st->rtp_handle, buf, URL_RDWR) == 0)
......
1201 1201
            char url[1024];
1202 1202

  
1203 1203
            /* XXX: also use address if specified */
1204
            snprintf(url, sizeof(url), "rtp://%s:%d",
1205
                     host, reply->transports[0].server_port_min);
1204
            ff_url_join(url, sizeof(url), "rtp", NULL, host,
1205
                        reply->transports[0].server_port_min, NULL);
1206 1206
            if (!(rt->server_type == RTSP_SERVER_WMS && i > 1) &&
1207 1207
                rtp_set_remote_url(rtsp_st->rtp_handle, url) < 0) {
1208 1208
                err = AVERROR_INVALIDDATA;
......
1230 1230
                port      = rtsp_st->sdp_port;
1231 1231
                ttl       = rtsp_st->sdp_ttl;
1232 1232
            }
1233
            snprintf(url, sizeof(url), "rtp://%s:%d?ttl=%d",
1234
                     inet_ntoa(in), port, ttl);
1233
            ff_url_join(url, sizeof(url), "rtp", NULL, inet_ntoa(in),
1234
                        port, "?ttl=%d", ttl);
1235 1235
            if (url_open(&rtsp_st->rtp_handle, url, URL_RDWR) < 0) {
1236 1236
                err = AVERROR_INVALIDDATA;
1237 1237
                goto fail;
......
1388 1388
    RTSPMessageHeader reply1, *reply = &reply1;
1389 1389
    int lower_transport_mask = 0;
1390 1390
    char real_challenge[64];
1391

  
1392
    if (!ff_network_init())
1393
        return AVERROR(EIO);
1391 1394
redirect:
1392 1395
    /* extract hostname and port */
1393 1396
    url_split(NULL, 0, auth, sizeof(auth),
......
1447 1450
    }
1448 1451

  
1449 1452
    /* open the tcp connexion */
1450
    snprintf(tcpname, sizeof(tcpname), "tcp://%s:%d", host, port);
1453
    ff_url_join(tcpname, sizeof(tcpname), "tcp", NULL, host, port, NULL);
1451 1454
    if (url_open(&rtsp_hd, tcpname, URL_RDWR) < 0) {
1452 1455
        err = AVERROR(EIO);
1453 1456
        goto fail;
......
1531 1534
               s->filename);
1532 1535
        goto redirect;
1533 1536
    }
1537
    ff_network_close();
1534 1538
    return err;
1535 1539
}
1536 1540
#endif
......
1886 1890

  
1887 1891
    ff_rtsp_close_streams(s);
1888 1892
    url_close(rt->rtsp_hd);
1893
    ff_network_close();
1889 1894
    return 0;
1890 1895
}
1891 1896

  
......
1933 1938
    char *content;
1934 1939
    char url[1024];
1935 1940

  
1941
    if (!ff_network_init())
1942
        return AVERROR(EIO);
1943

  
1936 1944
    /* read the whole sdp file */
1937 1945
    /* XXX: better loading */
1938 1946
    content = av_malloc(SDP_MAX_SIZE);
......
1950 1958
    for (i = 0; i < rt->nb_rtsp_streams; i++) {
1951 1959
        rtsp_st = rt->rtsp_streams[i];
1952 1960

  
1953
        snprintf(url, sizeof(url), "rtp://%s:%d?localport=%d&ttl=%d",
1954
                 inet_ntoa(rtsp_st->sdp_ip),
1955
                 rtsp_st->sdp_port,
1956
                 rtsp_st->sdp_port,
1957
                 rtsp_st->sdp_ttl);
1961
        ff_url_join(url, sizeof(url), "rtp", NULL,
1962
                    inet_ntoa(rtsp_st->sdp_ip), rtsp_st->sdp_port,
1963
                    "?localport=%d&ttl=%d", rtsp_st->sdp_port,
1964
                    rtsp_st->sdp_ttl);
1958 1965
        if (url_open(&rtsp_st->rtp_handle, url, URL_RDWR) < 0) {
1959 1966
            err = AVERROR_INVALIDDATA;
1960 1967
            goto fail;
......
1965 1972
    return 0;
1966 1973
fail:
1967 1974
    ff_rtsp_close_streams(s);
1975
    ff_network_close();
1968 1976
    return err;
1969 1977
}
1970 1978

  
1971 1979
static int sdp_read_close(AVFormatContext *s)
1972 1980
{
1973 1981
    ff_rtsp_close_streams(s);
1982
    ff_network_close();
1974 1983
    return 0;
1975 1984
}
1976 1985

  

Also available in: Unified diff