Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] avformat/whip: set the first sequence number for video and audio (PR #20332)
@ 2025-08-24 22:00 Jack Lau via ffmpeg-devel
  0 siblings, 0 replies; only message in thread
From: Jack Lau via ffmpeg-devel @ 2025-08-24 22:00 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Jack Lau

PR #20332 opened by Jack Lau (JackLau)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20332
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20332.patch

this patch will make whip be able to get the first
rtp seq easily and compute something sequence-based
(e.g. NACK and RTX handling)

Signed-off-by: Jack Lau <jacklau1222@qq.com>


From 3109374df9e00e1c8c5e199809ffc2a95c4a9b6e Mon Sep 17 00:00:00 2001
From: Jack Lau <jacklau1222@qq.com>
Date: Mon, 25 Aug 2025 05:52:34 +0800
Subject: [PATCH] avformat/whip: set the first sequence number for video and
 audio

this patch will make whip be able to get the first
rtp seq easily and compute something sequence-based
(e.g. NACK and RTX handling)

Signed-off-by: Jack Lau <jacklau1222@qq.com>
---
 libavformat/whip.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/libavformat/whip.c b/libavformat/whip.c
index 69f1010ee8..ae0e98052b 100644
--- a/libavformat/whip.c
+++ b/libavformat/whip.c
@@ -219,6 +219,9 @@ typedef struct WHIPContext {
     /* The SSRC of the audio and video stream, generated by the muxer. */
     uint32_t audio_ssrc;
     uint32_t video_ssrc;
+
+    uint16_t audio_first_seq;
+    uint16_t video_first_seq;
     /* The PT(Payload Type) of stream, generated by the muxer. */
     uint8_t audio_payload_type;
     uint8_t video_payload_type;
@@ -379,6 +382,9 @@ static av_cold int initialize(AVFormatContext *s)
     seed = av_get_random_seed();
     av_lfg_init(&whip->rnd, seed);
 
+    whip->audio_first_seq = av_lfg_get(&whip->rnd) & 0x0fff;
+    whip->video_first_seq = av_lfg_get(&whip->rnd) & 0x0fff;
+
     if (whip->pkt_size < ideal_pkt_size)
         av_log(whip, AV_LOG_WARNING, "pkt_size=%d(<%d) is too small, may cause packet loss\n",
                whip->pkt_size, ideal_pkt_size);
@@ -1536,6 +1542,7 @@ static int create_rtp_muxer(AVFormatContext *s)
         av_dict_set(&opts, "payload_type", buf, 0);
         snprintf(buf, sizeof(buf), "%d", is_video? whip->video_ssrc : whip->audio_ssrc);
         av_dict_set(&opts, "ssrc", buf, 0);
+        av_dict_set_int(&opts, "seq", is_video ? whip->video_first_seq : whip->audio_first_seq, 0);
 
         ret = avformat_write_header(rtp_ctx, &opts);
         if (ret < 0) {
-- 
2.49.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".

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-08-24 22:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-24 22:00 [FFmpeg-devel] [PATCH] avformat/whip: set the first sequence number for video and audio (PR #20332) Jack Lau via ffmpeg-devel

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git