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 86C8F4BF1B for ; Wed, 3 Sep 2025 03:04:59 +0000 (UTC) Authentication-Results: ffbox; dkim=fail (body hash mismatch (got b'0dMl5ocJFugMWsFNHr2uhqZ6Fm3i0X5dPocSxqZUkUQ=', expected b'8ChihTMAF39y5ZM7xOvT1jxs2UfX0UCm+u/L3EAmAuk=')) header.d=ffmpeg.org header.i=@ffmpeg.org header.a=rsa-sha256 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1756868674; h=mime-version : to : message-id : reply-to : subject : list-id : list-archive : list-archive : list-help : list-owner : list-post : list-subscribe : list-unsubscribe : from : cc : content-type : content-transfer-encoding : from; bh=0dMl5ocJFugMWsFNHr2uhqZ6Fm3i0X5dPocSxqZUkUQ=; b=ugCQ8T8o5GwB12yZXrmcUEsQfiH0sUsLK6IK2n88DIjH1pAsUMn6kjz4DlG9pu5LE257v t3Frl4wu3XVv6qZiH6lS17SeUcEC5YgDGUROwD9QfhJKJjJnftHxH+f+0Lqo0A2UuL7dSSH 5NBm4e6VhN+Vd0sm9ZaoH1XNtEcUUz0ez967Uw+If/y8TrjxzQNrv5WEH5wTPvb8YVdxqZp 2Utyv/XnLhBc8vM56nCk/Y9QReJ/+uw3CnU2DguAct4NwN2cP4BFubPMYh79EWJSk82Wx8v 6XB/Dqv12yiLjpo+di5gUicCh+Fvtd7Lf/NfrUCugiFjfDgCfo8ts1ZsrCxg== Received: from [172.19.0.4] (unknown [172.19.0.4]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 30DE168E7AB; Wed, 3 Sep 2025 06:04:34 +0300 (EEST) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=ffmpeg.org; s=arc; t=1756868661; b=Zj4ZeNtYElyHcS4yAA9SBiX0aMwdjNIdgDpIx/6vo5GiXusxePMHuhynrOGcS4eHxvn1H 7cYkqWx0lw9Neoigq2d67IX5ibTL/xA2BFs00X6EwnR4ixmuEM/22rXHZCNRCy2UlQNCW9o xLXbnSh1hNdq6Vwro9tLf0OtQiT0KeyhOQuMoy0AA3FTymDEmjpUuMDvEoMZiDrImhhASra 3+4go3YWols9Z/0y3bah7Nhel08LDfzudqt+CWLTldjFHoYiyzxbhnsCKJIcigU0XVgfuai XY5Ncto2oSerqRjuaLnqW56Z0dHneUO/YZPkxbVDhyPShbyKiPKBM/emPa3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=ffmpeg.org; s=arc; t=1756868661; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=mTihRDGWfJKOp65/ATiea2K36Uh/isap+YYpeReJgq0=; b=ElO3MTYKSRHfx3XYKui7mAPjMk5AWmjWr1ynhugowFYKyNqAlQxPAXTBeNn/G5IvReqpk DMoDLp1V47prlrmXEcDowW/PukzBiJ7AQrvuC2reu+J1Vw1rWf8UweTedD/EWZCQIQffVAX zMU2FPEpFlTCmfWDAsumrc0MHV12Na75CxPfPQpc/oNc+9APUszSP1oSbHNNQ0ZD/5pge1j 1fCPtz+Canxy9zaoJBGL7rgZt8W1vCSzVvvFXk/se5k9SQ67fsIcpvL8rcsmWDDQap9G0B4 PhzMeFO1J9IVmTTqsR3t9Oh2f7mYvUqS5EilA/igYaJPDd3bG1lfUyv+vdwQ== ARC-Authentication-Results: i=1; ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none; dmarc=none Authentication-Results: ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none (Message is not ARC signed); dmarc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1756868650; h=content-type : mime-version : content-transfer-encoding : from : to : reply-to : subject : from; bh=8ChihTMAF39y5ZM7xOvT1jxs2UfX0UCm+u/L3EAmAuk=; b=rhPgaKRYR5VSvgQZ3ER+vFyhSsu9kNKaYdHWHcNgGiSeomkThoFKGCm0fAFAxZlAdqzxU vRU5WY88PNIoLoUwmRupXb8t7+VY+XLs1Set93opytSDeMoNWhNUKOTYsqGLKeDaH37Otr6 CFUKN4wDRtCZljmo9jqcUKTXyEkUsPJwaO2auV8+UiBKzEGn6Y1AinAgqUPFgR7HTkMNooq bwCyQnKsphIFNWoKYw4810xNzzfNzErO7YA001jyTcWF5S3thWgsbc2sovWxu6eXV6X2HPY vdirRfV8079SEBASLk0Mblh2WaD+tKWav+ffeedI/gZBCI7mDLdXUqObXp4w== Received: from 5d8f51c41678 (code.ffmpeg.org [188.245.149.3]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id D9E1B680105 for ; Wed, 3 Sep 2025 06:04:10 +0300 (EEST) MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Message-ID: <175686865106.25.5023031714405931937@463a07221176> Message-ID-Hash: PF7WXBFV5BLYZPHLRDSIV6ARMOCPE73F X-Message-ID-Hash: PF7WXBFV5BLYZPHLRDSIV6ARMOCPE73F X-MailFrom: code@ffmpeg.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-ffmpeg-devel.ffmpeg.org-0; header-match-ffmpeg-devel.ffmpeg.org-1; header-match-ffmpeg-devel.ffmpeg.org-2; header-match-ffmpeg-devel.ffmpeg.org-3; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list Reply-To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] [PATCH] avformat/whip: add PRIORITY and ICE_CONTROLLING for STUN binding request (PR #20405) List-Id: FFmpeg development discussions and patches Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Jack Lau via ffmpeg-devel Cc: Jack Lau Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Archived-At: List-Archive: List-Post: PR #20405 opened by Jack Lau (JackLau) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20405 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20405.patch fix issue 20402 See RFC 8445 7.1, The PRIORITY and ICE-CONTROLLED or ICE-CONTROLLING must be included in a Binding request. FFmpeg is always ICE Controlling role so we use ICE-CONTROLLING attr. Co-author-by: Jack Lau Signed-off-by: Sergio Garcia Murillo >>From d2fb437542816460905afd92fc4fad577b9ce9c3 Mon Sep 17 00:00:00 2001 From: Sergio Garcia Murillo Date: Wed, 3 Sep 2025 10:43:36 +0800 Subject: [PATCH] avformat/whip: add PRIORITY and ICE_CONTROLLING for STUN binding request fix issue 20402 See RFC 8445 7.1, The PRIORITY and ICE-CONTROLLED or ICE-CONTROLLING must be included in a Binding request. FFmpeg is always ICE Controlling role so we use ICE-CONTROLLING attr. Co-author-by: Jack Lau Signed-off-by: Sergio Garcia Murillo --- libavformat/whip.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/libavformat/whip.c b/libavformat/whip.c index 1fcf19aaa3..4ea9cefa89 100644 --- a/libavformat/whip.c +++ b/libavformat/whip.c @@ -80,6 +80,13 @@ /* The magic cookie for Session Traversal Utilities for NAT (STUN) messages. */ #define STUN_MAGIC_COOKIE 0x2112A442 +/** + * See RFC 8445 5.1.2 + * priority = (2^24)*(type preference) + (2^8)*(local preference) + (2^0)*(256 - component ID) + * host candidate priority is 126 << 24 | 65535 << 8 | 255 + */ +#define STUN_HOST_CANDIDATE_PRIORITY 126 << 24 | 65535 << 8 | 255 + /** * The DTLS content type. * See https://tools.ietf.org/html/rfc2246#section-6.2.1 @@ -156,9 +163,11 @@ /* STUN Attribute, comprehension-required range (0x0000-0x7FFF) */ enum STUNAttr { STUN_ATTR_USERNAME = 0x0006, /// shared secret response/bind request + STUN_ATTR_PRIORITY = 0x0024, /// must be included in a Binding request STUN_ATTR_USE_CANDIDATE = 0x0025, /// bind request STUN_ATTR_MESSAGE_INTEGRITY = 0x0008, /// bind request/response STUN_ATTR_FINGERPRINT = 0x8028, /// rfc5389 + STUN_ATTR_ICE_CONTROLLING = 0x802A, /// ICE controlling role }; enum WHIPState { @@ -231,6 +240,7 @@ typedef struct WHIPContext { */ char *sdp_offer; + uint64_t ice_tie_breaker; // random 64 bit, for ICE-CONTROLLING /* The ICE username and pwd from remote server. */ char *ice_ufrag_remote; char *ice_pwd_remote; @@ -382,6 +392,9 @@ static av_cold int initialize(AVFormatContext *s) seed = av_get_random_seed(); av_lfg_init(&whip->rnd, seed); + /* 64 bit tie breaker for ICE-CONTROLLING (RFC 8445 16.1) */ + whip->ice_tie_breaker = ((uint64_t)av_lfg_get(&whip->rnd) << 32) | (uint64_t)av_lfg_get(&whip->rnd); + whip->audio_first_seq = av_lfg_get(&whip->rnd) & 0x0fff; whip->video_first_seq = whip->audio_first_seq + 1; @@ -912,8 +925,8 @@ end: * Creates and marshals an ICE binding request packet. * * This function creates and marshals an ICE binding request packet. The function only - * generates the username attribute and does not include goog-network-info, ice-controlling, - * use-candidate, and priority. However, some of these attributes may be added in the future. + * generates the username attribute and does not include goog-network-info, + * use-candidate. However, some of these attributes may be added in the future. * * @param s Pointer to the AVFormatContext * @param buf Pointer to memory buffer to store the request packet @@ -966,6 +979,14 @@ static int ice_create_request(AVFormatContext *s, uint8_t *buf, int buf_size, in avio_wb16(pb, STUN_ATTR_USE_CANDIDATE); /* attribute type use-candidate */ avio_wb16(pb, 0); /* size of use-candidate */ + avio_wb16(pb, STUN_ATTR_PRIORITY); + avio_wb16(pb, 4); + avio_wb32(pb, STUN_HOST_CANDIDATE_PRIORITY); + + avio_wb16(pb, STUN_ATTR_ICE_CONTROLLING); + avio_wb16(pb, 8); + avio_wb64(pb, whip->ice_tie_breaker); + /* Build and update message integrity */ avio_wb16(pb, STUN_ATTR_MESSAGE_INTEGRITY); /* attribute type message integrity */ avio_wb16(pb, 20); /* size of message integrity */ -- 2.49.1 _______________________________________________ ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org