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 567DE4BCDE for ; Mon, 25 Aug 2025 22:20:59 +0000 (UTC) Authentication-Results: ffbox; dkim=fail (body hash mismatch (got b'f1Dh+S5oy0uM8sMbeqBJkNbvKYkqajXhdZjtnOFnInw=', expected b'ASGTumFXaX0/dXUQQt4B4KltkIWfWuY06vwaxb8wCsY=')) 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=1756160442; 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=f1Dh+S5oy0uM8sMbeqBJkNbvKYkqajXhdZjtnOFnInw=; b=ktCRSb2s1aVgSt6ooO69+rh1bziOlhjFCHeLWxMgp2ruhQd3FI+DJHVpei+uEZTqDw1kn 2NdGeZznSjVgG/ogGvkCW6/XPdRhw8IPwG8Ql/FB0e2C8Kfq/lEGO5OL9U42ybYwfoV+Tk/ Ni66URkjlVirAU6ZjVKR3RqAokdn3ca5izS5y4uwMACZIKktWMYPcxlthbu9WHy6CHwsG90 L1GBVoZaE4haYiMTK0ZxfWMuxUC5Dg5ETMA26ZBkLhx8VfCxF9H2BHtFPfaidURnMwlu+mP +PoBSU5HAFG1Rp9W122NAXsWY2IXr+UkNI/YckloGFy00Qpqd/9Y9ZMhsDxg== Received: from [172.19.0.4] (unknown [172.19.0.4]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id A415868E768; Tue, 26 Aug 2025 01:20:42 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1756160410; h=content-type : mime-version : content-transfer-encoding : from : to : reply-to : subject : from; bh=ASGTumFXaX0/dXUQQt4B4KltkIWfWuY06vwaxb8wCsY=; b=AeuWbb+CSkr7z+wmC17OFmGpuAZ7ASmEbB4zKZZzUxBO37BzeAJZ08pZB9LPiYXwMuzei N/qBjdCMScdYRtWumqZcHH/KHf1HvE++UNqzbPLQ5g+NSqqQvPWtLMXCHUYQCQdbmaLZT1L wqWM2U6WEk/JuCKWkOwtbC2qEpcWKXZCnxbJVjOMfCG5VunMo525RR35ni3EIa6CcIR9PGj t4kiEJ4guXVZ+0ddH0BOGpYahpzSSjT6/QDVxVW6nSMFHKwD8bul0xmYIXQ4jbQ2paW6wHT 0oYw9UBkAn6VhFq2tCNDNCC2ESkUYOEZKEyt8Uv++PlqZg0/k7VO7EadElrg== Received: from 0f4167fb2350 (code.ffmpeg.org [188.245.149.3]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id AD65568011C for ; Tue, 26 Aug 2025 01:20:10 +0300 (EEST) MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Message-ID: <175616041097.23.15169822396419936281@5a0384606a8e> Message-ID-Hash: KIUQM5SRPLY32OP7IMUR4RVNSQJFZFEX X-Message-ID-Hash: KIUQM5SRPLY32OP7IMUR4RVNSQJFZFEX 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: simplify the udp read in whip_write_packet (PR #20339) 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 #20339 opened by Jack Lau (JackLau) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20339 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20339.patch Reduce nested if statements to make the code structure clearer Signed-off-by: Jack Lau >>From 74004772075c5cf4856d05a7dc6560d343525f81 Mon Sep 17 00:00:00 2001 From: Jack Lau Date: Tue, 26 Aug 2025 06:08:36 +0800 Subject: [PATCH] avformat/whip: simplify the udp read in whip_write_packet Reduce nested if statements to make the code structure clearer Signed-off-by: Jack Lau --- libavformat/whip.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/libavformat/whip.c b/libavformat/whip.c index 69f1010ee8..fd34e83f71 100644 --- a/libavformat/whip.c +++ b/libavformat/whip.c @@ -1761,18 +1761,20 @@ static int whip_write_packet(AVFormatContext *s, AVPacket *pkt) * and RTCP like PLI requests, then respond to them. */ ret = ffurl_read(whip->udp, whip->buf, sizeof(whip->buf)); - if (ret > 0) { - if (is_dtls_packet(whip->buf, ret)) { - if ((ret = ffurl_write(whip->dtls_uc, whip->buf, ret)) < 0) { - av_log(whip, AV_LOG_ERROR, "Failed to handle DTLS message\n"); - goto end; - } - } - } else if (ret != AVERROR(EAGAIN)) { - av_log(whip, AV_LOG_ERROR, "Failed to read from UDP socket\n"); + if (ret < 0) { + if (ret == AVERROR(EAGAIN)) + goto write_packet; goto end; } - + if (!ret) + goto end; + if (is_dtls_packet(whip->buf, ret)) { + if ((ret = ffurl_write(whip->dtls_uc, whip->buf, ret)) < 0) { + av_log(whip, AV_LOG_ERROR, "Failed to handle DTLS message\n"); + goto end; + } + } +write_packet: if (whip->h264_annexb_insert_sps_pps && st->codecpar->codec_id == AV_CODEC_ID_H264) { if ((ret = h264_annexb_insert_sps_pps(s, pkt)) < 0) { av_log(whip, AV_LOG_ERROR, "Failed to insert SPS/PPS before IDR\n"); -- 2.49.1 _______________________________________________ ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org