[FFmpeg-cvslog] fix rtp 916 issue

Dmitry Volyntsev git at videolan.org
Wed Jan 18 16:39:34 CET 2012


ffmpeg | branch: master | Dmitry Volyntsev <xeioexception at gmail.com> | Wed Jan 18 13:46:37 2012 +0400| [b29ec002bbec913ffdaad3f8dc482b36525a3de3] | committer: Michael Niedermayer

fix rtp 916 issue

Reviewed-by: Luca Abeni <lucabe72 at email.it>
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b29ec002bbec913ffdaad3f8dc482b36525a3de3
---

 libavformat/rtsp.c |    8 +++++---
 libavformat/rtsp.h |    2 +-
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index d32f49e..ff1f857 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -1103,7 +1103,7 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port,
                               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];
@@ -1120,8 +1120,11 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port,
     /* 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];
 
         /*
@@ -1169,7 +1172,6 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port,
                         goto rtp_opened;
                 }
             }
-
             av_log(s, AV_LOG_ERROR, "Unable to open an input RTP port\n");
             err = AVERROR(EIO);
             goto fail;
diff --git a/libavformat/rtsp.h b/libavformat/rtsp.h
index 36de7e5..e11dec9 100644
--- a/libavformat/rtsp.h
+++ b/libavformat/rtsp.h
@@ -70,7 +70,7 @@ enum RTSPControlTransport {
 #define RTSP_DEFAULT_NB_AUDIO_CHANNELS 1
 #define RTSP_DEFAULT_AUDIO_SAMPLERATE 44100
 #define RTSP_RTP_PORT_MIN 5000
-#define RTSP_RTP_PORT_MAX 10000
+#define RTSP_RTP_PORT_MAX 65000
 
 /**
  * This describes a single item in the "Transport:" line of one stream as



More information about the ffmpeg-cvslog mailing list