[FFmpeg-devel] [PATCH] RTP local udp port issue fix (ticket 916)

Luca Abeni lucabe72 at email.it
Wed Jan 18 13:04:42 CET 2012


On 01/18/2012 11:04 AM, Dmitry Volyntsev wrote:
> Ok. Here are two patches in attach.
>
> First patch: fixes the 916 issue
> Second patch: related to "if(RTSP_RTP_PORT_MIN != 0) issue"
>
> Patches were verified: wireshark log
> https://ffmpeg.org/trac/ffmpeg/attachment/ticket/916/ffmpeg_916_issue_fix.tcap
> (look on RTSP: SETUP packet, local_ports - starts from random even
> offset)
Look good to me


			Luca

>
> 2012/1/18 Luca Abeni<lucabe72 at email.it>:
>> On Wed, 2012-01-18 at 01:10 +0400, Dmitry Volyntsev wrote:
>>> Could you, please, clarify, should I separate the patch to 1)
>>> patch1:fix of the issue without modification of RTSP_RTP_PORT_MAX and
>>> if(RTSP_RTP_PORT_MIN != 0) thing + patch2: RTSP_RTP_PORT_MAX
>>> modification and if(RTSP_RTP_PORT_MIN != 0) thing OR 2) patch1: fix of
>>> the issue with modification of RTSP_RTP_PORT_MAX  +
>>> patch2:if(RTSP_RTP_PORT_MIN != 0) thing ?
>> Note that I do not think this detail (the patch split) is very important
>> (your modifications look ok to me), and you should follow the opinion of
>> official ffmpeg developers... Anyway, I think that the patch should be
>> split similarly to this:
>> Patch 1 @@ -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];
>>
>>          /*
>> (plus maybe the rtsp.h modifications)
>>
>> Patch 2 @@ -1158,16 +1161,15 @@ int
>> ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int
>> port,
>>              }
>>
>>              /* 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,
>> +            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)
>> +                /* 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;
>> -                }
>>              }
>>
>>
>>
>>                                 Luca
>>
>
>
>



More information about the ffmpeg-devel mailing list