The branch, master has been updated
via 3c7315c3456c4a55caf368594ee5f923b223bf8d (commit)
from 785a4e0d6c80f475f7891d33dfa2927faa51da21 (commit)
- Log -----------------------------------------------------------------
commit 3c7315c3456c4a55caf368594ee5f923b223bf8d
Author: Jack Lau <[email protected]>
AuthorDate: Tue Aug 26 06:08:36 2025 +0800
Commit: stevenliu <[email protected]>
CommitDate: Fri Sep 5 04:29:39 2025 +0000
avformat/whip: simplify the udp read in whip_write_packet
Reduce nested if statements to make the code structure clearer
Add logic to check if EOF is received from UDP socket.
Signed-off-by: Jack Lau <[email protected]>
diff --git a/libavformat/whip.c b/libavformat/whip.c
index 00e9e674da..20db03a239 100644
--- a/libavformat/whip.c
+++ b/libavformat/whip.c
@@ -1793,18 +1793,23 @@ 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)) {
+ if (ret < 0) {
+ if (ret == AVERROR(EAGAIN))
+ goto write_packet;
av_log(whip, AV_LOG_ERROR, "Failed to read from UDP socket\n");
goto end;
}
-
+ if (!ret) {
+ av_log(whip, AV_LOG_ERROR, "Receive EOF from UDP socket\n");
+ 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");
-----------------------------------------------------------------------
Summary of changes:
libavformat/whip.c | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
hooks/post-receive
--
_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]