From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 451A14EA52 for ; Fri, 13 Jun 2025 05:05:02 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 3298768C22A; Fri, 13 Jun 2025 08:05:00 +0300 (EEST) To: ffmpeg-devel@ffmpeg.org Date: Fri, 13 Jun 2025 13:03:35 +0800 MIME-Version: 1.0 Message-ID: List-Id: FFmpeg development discussions and patches List-Post: From: Jack Lau via ffmpeg-devel Precedence: list Cc: Jack Lau X-Mailman-Version: 2.1.29 X-BeenThere: ffmpeg-devel@ffmpeg.org List-Subscribe: , List-Unsubscribe: , List-Archive: Reply-To: FFmpeg development discussions and patches List-Help: Subject: [FFmpeg-devel] [PATCH v2 1/2] avformat/whip: add whip_flags ignore_ipv6 to skip IPv6 candidates Content-Type: multipart/mixed; boundary="===============5609450691841381783==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============5609450691841381783== Content-Type: message/rfc822 Content-Disposition: inline Return-Path: X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out162-62-57-49.mail.qq.com (out162-62-57-49.mail.qq.com [162.62.57.49]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 0845668B9CE for ; Fri, 13 Jun 2025 08:04:51 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1749791089; bh=KcrhcFl4HO5D+uKW8KGEJFeGMugo+o252jHeavl9hOA=; h=From:To:Cc:Subject:Date; b=zlHXkqbKl3rS5yKvqEhqVAiWKHJ3AJYXYiNXb9r6RML3KmcM119ptQ2Kb5N7vUsQi iN3muNVpSjkNhAwzXMtwuphdUNgjrRRJ8DuoO8BFYyjlhEzu84rx8nsD3fb2+qqdAH KuSb5gJsh/ZB4fuf9GyikXDocCrHHTqf8nq9mVWs= Received: from localhost.localdomain ([111.33.195.50]) by newxmesmtplogicsvrsza36-0.qq.com (NewEsmtp) with SMTP id E5A8C9B; Fri, 13 Jun 2025 13:03:37 +0800 X-QQ-mid: xmsmtpt1749791017tcwmfbdjm Message-ID: X-QQ-XMAILINFO: Mi9y8J8807RSnq5VS0s4zaPQbKVQQbx0/kb3YglsK0t/rnS6t8M7czrXRuzHPG aYJ2/3/pBSC4K0PrKccQ7tvCwAxLAcW/TysYetZIiACG5O4v3cHu2hUwk8fX8+FfLu5D68m5wUqE RpzctaWl/wzqSKdu2jUAfJllPxB89y4IT8WRtpC3DT6vCMvQXmgzR+zzK3whkxUAOaPYwyAcRxYO bnE3dbRqpdPh0BBOrqD8VxBuRHpIQ0YuC4nlIXEuirSszlNLVAnZqyx5SicXkDpXvjzb2/kx5+xw 30I69WpEyWfVH4/AcWiMlNn6ztL1qe4rFaYox40o3pZS4DWtQO1xuzXD655AHnAOECPPgzzTDdE6 OhzMsZv8hEBBMQLinsLjpiGN4kKHVRtx8WA2wmyxXsSXaweQeA+TZRKJPcOFw4erCXtCV5l3gNXZ Btyg2uvzrxMo5p42FAol/kCMONdGZj1+AQPos1OSLgpBE/gD0TSSti6Uv7OaFpJk8TwrrUY2iIks KGXU0eUW9dGyaWVeUVhuMwUSa7Qs+qwPjfmk3oCtr5NMt5k9kAdwfr1hb3U4dtNkzmZZ8f8IhJ7E gyFmSveaTV0L1DnOendNJfSF3s2vdqfefOieAv3U7ing5Y0tJ5nBZ6ds8+cT5/vGNFZOSRFM1n0R LffLKVyMtofyiQB+wSPVWqzg0Lyx0iQ3gv8kF1MAY70qTgeJVgJgt1eRDqN4/myalyyFFk0jDgiG Wmyowoyx65LPCNs7VPHP5/medjxEj7YSppCtmKBsDWel6aAl5shE5xm4xrjPKB0LrnrzF56j1fPi Lh1Qj2LYmLtJ9f2TgPjEgj8juLIp88T/92elyZq/6axHN4alKDAmdpKuxjbWp8yyDONYp9HLQUCo pGKEC+yeV0ZVP5B1Rsjli5Wm177lO/gTN8ihixRTHhPPA6Facc2PfsEyILcrA3vPbVEZURIyO8on q6X9ApnWhBIwL15Jp1iH2/6JR6MzhTgKcg7SuZbdoyu+iuqZxucC0/aEQo2PKx X-QQ-XMRINFO: NI4Ajvh11aEj8Xl/2s1/T8w= From: Jack Lau To: ffmpeg-devel@ffmpeg.org Cc: Jack Lau Subject: [PATCH v2 1/2] avformat/whip: add whip_flags ignore_ipv6 to skip IPv6 candidates Date: Fri, 13 Jun 2025 13:03:35 +0800 X-OQ-MSGID: <20250613050335.63999-1-jacklau1222@qq.com> X-Mailer: git-send-email 2.49.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Unsent: 1 Content-Transfer-Encoding: 8bit replace AV_OPT_FLAG_DECODING_PARAM to ENCODING mark this ignore_ipv6 flag could ignore any ipv6 ICE candidate, preventing “No route to host” errors on devices without IPv6 connectivity. Signed-off-by: Jack Lau --- libavformat/whip.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/libavformat/whip.c b/libavformat/whip.c index 710f24fc5a..84c2092e5e 100644 --- a/libavformat/whip.c +++ b/libavformat/whip.c @@ -193,9 +193,14 @@ enum WHIPState { WHIP_STATE_FAILED, }; +typedef enum WHIPFlags { + WHIP_FLAG_IGNORE_IPV6 = (1 << 0) // Ignore ipv6 candidate +} WHIPFlags; + typedef struct WHIPContext { AVClass *av_class; + uint32_t flags; // enum WHIPFlags /* The state of the RTC connection. */ enum WHIPState state; /* The callback return value for DTLS. */ @@ -871,6 +876,7 @@ static int parse_answer(AVFormatContext *s) if (ptr && av_stristr(ptr, "host")) { char protocol[17], host[129]; int priority, port; + struct in6_addr addr6; ret = sscanf(ptr, "%16s %d %128s %d typ host", protocol, &priority, host, &port); if (ret != 4) { av_log(whip, AV_LOG_ERROR, "WHIP: Failed %d to parse line %d %s from %s\n", @@ -879,6 +885,11 @@ static int parse_answer(AVFormatContext *s) goto end; } + if (whip->flags & WHIP_FLAG_IGNORE_IPV6 && inet_pton(AF_INET6, host, &addr6) == 1) { + av_log(whip, AV_LOG_DEBUG, "WHIP: Ignore ipv6 %s, line %d %s \n", host, i, line); + continue; + } + if (av_strcasecmp(protocol, "udp")) { av_log(whip, AV_LOG_ERROR, "WHIP: Protocol %s is not supported by RTC, choose udp, line %d %s of %s\n", protocol, i, line, whip->sdp_answer); @@ -1885,13 +1896,15 @@ static int whip_check_bitstream(AVFormatContext *s, AVStream *st, const AVPacket } #define OFFSET(x) offsetof(WHIPContext, x) -#define DEC AV_OPT_FLAG_DECODING_PARAM +#define ENC AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { - { "handshake_timeout", "Timeout in milliseconds for ICE and DTLS handshake.", OFFSET(handshake_timeout), AV_OPT_TYPE_INT, { .i64 = 5000 }, -1, INT_MAX, DEC }, - { "pkt_size", "The maximum size, in bytes, of RTP packets that send out", OFFSET(pkt_size), AV_OPT_TYPE_INT, { .i64 = 1200 }, -1, INT_MAX, DEC }, - { "authorization", "The optional Bearer token for WHIP Authorization", OFFSET(authorization), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, DEC }, - { "cert_file", "The optional certificate file path for DTLS", OFFSET(cert_file), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, DEC }, - { "key_file", "The optional private key file path for DTLS", OFFSET(key_file), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, DEC }, + { "handshake_timeout", "Timeout in milliseconds for ICE and DTLS handshake.", OFFSET(handshake_timeout), AV_OPT_TYPE_INT, { .i64 = 5000 }, -1, INT_MAX, ENC }, + { "pkt_size", "The maximum size, in bytes, of RTP packets that send out", OFFSET(pkt_size), AV_OPT_TYPE_INT, { .i64 = 1200 }, -1, INT_MAX, ENC }, + { "authorization", "The optional Bearer token for WHIP Authorization", OFFSET(authorization), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, ENC }, + { "cert_file", "The optional certificate file path for DTLS", OFFSET(cert_file), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, ENC }, + { "key_file", "The optional private key file path for DTLS", OFFSET(key_file), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, ENC }, + { "whip_flags", "Set flags affecting WHIP connection behavior", OFFSET(flags), AV_OPT_TYPE_FLAGS, { .i64 = 0 }, 0, UINT_MAX, ENC, .unit = "flags" }, + { "ignore_ipv6", "The optional ignore any IPv6 ICE candidate", 0, AV_OPT_TYPE_CONST, { .i64 = WHIP_FLAG_IGNORE_IPV6 }, 0, UINT_MAX, ENC, .unit = "flags" }, { NULL }, }; -- 2.49.0 --===============5609450691841381783== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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". --===============5609450691841381783==--