[FFmpeg-devel] [PATCH] RTP local udp port issue fix (ticket 916)
Dmitry Volyntsev
xeioexception at gmail.com
Wed Jan 18 11:04:52 CET 2012
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)
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
>
--
Be happy,
Best regards,
Dmitry Volyntsev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-fix-rtp-916-issue.patch
Type: text/x-patch
Size: 2230 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120118/188037de/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-fix-rtp-916-issue-patch-2.patch
Type: text/x-patch
Size: 1747 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120118/188037de/attachment-0001.bin>
More information about the ffmpeg-devel
mailing list