int lower_transport, const char *real_challenge)
{
RTSPState *rt = s->priv_data;
- int rtx, j, i, err, interleave = 0;
+ int rtx = 0, j, i, err, interleave = 0, port_off;
RTSPStream *rtsp_st;
RTSPMessageHeader reply1, *reply = &reply1;
char cmd[2048];
/* for each stream, make the setup request */
/* XXX: we assume the same server is used for the control of each
* RTSP stream */
+ port_off = av_get_random_seed() % (RTSP_RTP_PORT_MAX - RTSP_RTP_PORT_MIN);
+ /* even random offset */
+ port_off -= port_off & 0x01;
- for (j = RTSP_RTP_PORT_MIN, i = 0; i < rt->nb_rtsp_streams; ++i) {
+ for (j = RTSP_RTP_PORT_MIN + port_off, i = 0; i < rt->nb_rtsp_streams; ++i) {
char transport[2048];
/*
}
/* first try in specified port range */
- if (RTSP_RTP_PORT_MIN != 0) {
- while (j <= RTSP_RTP_PORT_MAX) {
- 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 (ffurl_open(&rtsp_st->rtp_handle, buf, AVIO_FLAG_READ_WRITE,
- &s->interrupt_callback, NULL) == 0)
- goto rtp_opened;
- }
+ while (j <= RTSP_RTP_PORT_MAX) {
+ 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 (!ffurl_open(&rtsp_st->rtp_handle, buf, AVIO_FLAG_READ_WRITE,
+ &s->interrupt_callback, NULL))
+ goto rtp_opened;
}
-
av_log(s, AV_LOG_ERROR, "Unable to open an input RTP port\n");
err = AVERROR(EIO);
goto fail;