* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-/* needed by inet_aton() */
-#define _SVID_SOURCE
-
#include "libavutil/base64.h"
#include "libavutil/avstring.h"
#include "libavutil/intreadwrite.h"
#include "rtpdec.h"
#include "rdt.h"
-#include "rtp_asf.h"
-#include "rtp_vorbis.h"
+#include "rtpdec_asf.h"
+#include "rtpdec_vorbis.h"
//#define DEBUG
//#define DEBUG_RTP_TCP
if (strcmp(buf1, "IP4") != 0)
return;
get_word_sep(buf1, sizeof(buf1), "/", &p);
- if (inet_aton(buf1, &sdp_ip) == 0)
+ if (ff_inet_aton(buf1, &sdp_ip) == 0)
return;
ttl = 16;
if (*p == '/') {
if (*p == '=') {
p++;
get_word_sep(buf, sizeof(buf), ";,", &p);
- if (inet_aton(buf, &ipaddr))
+ if (ff_inet_aton(buf, &ipaddr))
th->destination = ntohl(ipaddr.s_addr);
}
}
/* first try in specified port range */
if (RTSP_RTP_PORT_MIN != 0) {
while (j <= RTSP_RTP_PORT_MAX) {
- snprintf(buf, sizeof(buf), "rtp://%s?localport=%d",
- host, j);
+ ff_url_join(buf, sizeof(buf), "rtp", NULL, host, -1,
+ "?localport=%d", j);
/* we will use two ports per rtp stream (rtp and rtcp) */
j += 2;
if (url_open(&rtsp_st->rtp_handle, buf, URL_RDWR) == 0)
char url[1024];
/* XXX: also use address if specified */
- snprintf(url, sizeof(url), "rtp://%s:%d",
- host, reply->transports[0].server_port_min);
+ ff_url_join(url, sizeof(url), "rtp", NULL, host,
+ reply->transports[0].server_port_min, NULL);
if (!(rt->server_type == RTSP_SERVER_WMS && i > 1) &&
rtp_set_remote_url(rtsp_st->rtp_handle, url) < 0) {
err = AVERROR_INVALIDDATA;
port = rtsp_st->sdp_port;
ttl = rtsp_st->sdp_ttl;
}
- snprintf(url, sizeof(url), "rtp://%s:%d?ttl=%d",
- inet_ntoa(in), port, ttl);
+ ff_url_join(url, sizeof(url), "rtp", NULL, inet_ntoa(in),
+ port, "?ttl=%d", ttl);
if (url_open(&rtsp_st->rtp_handle, url, URL_RDWR) < 0) {
err = AVERROR_INVALIDDATA;
goto fail;
RTSPMessageHeader reply1, *reply = &reply1;
int lower_transport_mask = 0;
char real_challenge[64];
+
+ if (!ff_network_init())
+ return AVERROR(EIO);
redirect:
/* extract hostname and port */
url_split(NULL, 0, auth, sizeof(auth),
}
/* open the tcp connexion */
- snprintf(tcpname, sizeof(tcpname), "tcp://%s:%d", host, port);
+ ff_url_join(tcpname, sizeof(tcpname), "tcp", NULL, host, port, NULL);
if (url_open(&rtsp_hd, tcpname, URL_RDWR) < 0) {
err = AVERROR(EIO);
goto fail;
s->filename);
goto redirect;
}
+ ff_network_close();
return err;
}
#endif
ff_rtsp_close_streams(s);
url_close(rt->rtsp_hd);
+ ff_network_close();
return 0;
}
char *content;
char url[1024];
+ if (!ff_network_init())
+ return AVERROR(EIO);
+
/* read the whole sdp file */
/* XXX: better loading */
content = av_malloc(SDP_MAX_SIZE);
for (i = 0; i < rt->nb_rtsp_streams; i++) {
rtsp_st = rt->rtsp_streams[i];
- snprintf(url, sizeof(url), "rtp://%s:%d?localport=%d&ttl=%d",
- inet_ntoa(rtsp_st->sdp_ip),
- rtsp_st->sdp_port,
- rtsp_st->sdp_port,
- rtsp_st->sdp_ttl);
+ ff_url_join(url, sizeof(url), "rtp", NULL,
+ inet_ntoa(rtsp_st->sdp_ip), rtsp_st->sdp_port,
+ "?localport=%d&ttl=%d", rtsp_st->sdp_port,
+ rtsp_st->sdp_ttl);
if (url_open(&rtsp_st->rtp_handle, url, URL_RDWR) < 0) {
err = AVERROR_INVALIDDATA;
goto fail;
return 0;
fail:
ff_rtsp_close_streams(s);
+ ff_network_close();
return err;
}
static int sdp_read_close(AVFormatContext *s)
{
ff_rtsp_close_streams(s);
+ ff_network_close();
return 0;
}