int lower_transport, const char *real_challenge)
{
RTSPState *rt = s->priv_data;
- int rtx = 0, 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];
/* XXX: we assume the same server is used for the control of each
* RTSP stream */
- for (j = rt->rtp_port_min, i = 0; i < rt->nb_rtsp_streams; ++i) {
+ /* Choose a random starting offset within the first half of the
+ * port range, to allow for a number of ports to try even if the offset
+ * happens to be at the end of the random range. */
+ port_off = av_get_random_seed() % ((rt->rtp_port_max - rt->rtp_port_min)/2);
+ /* even random offset */
+ port_off -= port_off & 0x01;
+
+ for (j = rt->rtp_port_min + port_off, i = 0; i < rt->nb_rtsp_streams; ++i) {
char transport[2048];
/*