From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id BD38B40BFC for ; Sat, 5 Feb 2022 10:00:05 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 11A4468B369; Sat, 5 Feb 2022 12:00:04 +0200 (EET) Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DE6EA68B25B for ; Sat, 5 Feb 2022 11:59:57 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id D3161E64E2 for ; Sat, 5 Feb 2022 10:59:57 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Lawz_d96sv4L for ; Sat, 5 Feb 2022 10:59:55 +0100 (CET) Received: from iq (iq [217.27.212.140]) by iq.passwd.hu (Postfix) with ESMTPS id A1A4EE628A for ; Sat, 5 Feb 2022 10:59:55 +0100 (CET) Date: Sat, 5 Feb 2022 10:59:55 +0100 (CET) From: Marton Balint To: FFmpeg development discussions and patches In-Reply-To: <1644038899-15433-2-git-send-email-lance.lmwang@gmail.com> Message-ID: References: <1643260580-25792-1-git-send-email-lance.lmwang@gmail.com> <1644038899-15433-1-git-send-email-lance.lmwang@gmail.com> <1644038899-15433-2-git-send-email-lance.lmwang@gmail.com> MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH v2 2/3] avformat/udp: Fix IP_MULTICAST_TTL for BSD compatibility X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Sat, 5 Feb 2022, lance.lmwang@gmail.com wrote: > From: Limin Wang > > Suggested by zhilizhao, vlc project has solved the compatibility by > the same way, so I borrowed the comments from vlc project. > > Fix #ticket9449 > > Signed-off-by: Limin Wang > --- > libavformat/udp.c | 15 +++++++++++++-- > 1 file changed, 13 insertions(+), 2 deletions(-) > > diff --git a/libavformat/udp.c b/libavformat/udp.c > index 3dc79eb..34488d6 100644 > --- a/libavformat/udp.c > +++ b/libavformat/udp.c > @@ -164,6 +164,10 @@ static int udp_set_multicast_ttl(int sockfd, int mcastTTL, > { > int protocol, cmd; > > + /* There is some confusion in the world whether IP_MULTICAST_TTL > + * takes a byte or an int as an argument. > + * BSD seems to indicate byte so we are going with that and use > + * int as a fallback to be safe */ The code does the opposite. Tries int and falls back to byte. Either change code or change comment. Regards, Marton > switch (addr->sa_family) { > #ifdef IP_MULTICAST_TTL > case AF_INET: > @@ -183,8 +187,15 @@ static int udp_set_multicast_ttl(int sockfd, int mcastTTL, > } > > if (setsockopt(sockfd, protocol, cmd, &mcastTTL, sizeof(mcastTTL)) < 0) { > - ff_log_net_error(logctx, AV_LOG_ERROR, "setsockopt"); > - return ff_neterrno(); > + /* BSD compatibility */ > + unsigned char ttl; > + > + ff_log_net_error(logctx, AV_LOG_DEBUG, "setsockopt"); > + ttl = (unsigned char)(( mcastTTL > 255 ) ? 255 : mcastTTL); > + if (setsockopt(sockfd, protocol, cmd, &ttl, sizeof(ttl)) < 0) { > + ff_log_net_error(logctx, AV_LOG_ERROR, "setsockopt"); > + return ff_neterrno(); > + } > } > > return 0; > -- > 1.8.3.1 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". > _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".