-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
max_seq_nr not initialized properly #2920
Comments
Thanks @pimenas ! Can you please check if this patch solves the issue? diff --git a/src/rtcp.c b/src/rtcp.c
index f5e7990c..f2ba99eb 100644
--- a/src/rtcp.c
+++ b/src/rtcp.c
@@ -828,13 +828,16 @@ int janus_rtcp_process_incoming_rtp(janus_rtcp_context *ctx, char *packet, int l
ctx->tb = clock_rate;
/* Now parse this RTP packet header and update the rtcp_context instance */
uint16_t seq_number = ntohs(rtp->seq_number);
- if(ctx->base_seq == 0 && ctx->seq_cycle == 0)
+ gboolean first_pkt = FALSE;
+ if(ctx->base_seq == 0 && ctx->seq_cycle == 0) {
ctx->base_seq = seq_number;
+ first_pkt = TRUE;
+ }
int64_t now = janus_get_monotonic_time();
if (!rfc4588_pkt) {
/* Non-RTX packet */
- if ((int16_t)(seq_number - ctx->max_seq_nr) > 0) {
+ if ((int16_t)(seq_number - ctx->max_seq_nr) > 0 || first_pkt) {
/* In-order packet */
ctx->received++; |
Hi @atoppi Yes your patch seems to work fine! |
atoppi
added a commit
that referenced
this issue
Mar 9, 2022
Thanks for confirming @pimenas ! |
vincentfretin
pushed a commit
to vincentfretin/janus-gateway
that referenced
this issue
Mar 17, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Long story short, I was using pion webrtc to connect to janus, and I noticed that in_link_quality and in_media_quality took a very long time to take values > 0, which led me to do some investigation.
I traced it down and found it's happening because pion sometimes starts with a sequence number > 32765, which leads to condition in line
janus-gateway/src/rtcp.c
Line 837 in 84142eb
Here's the relevant code:
So
max_seq_nr
is only initialized if(int16_t)(seq_number - ctx->max_seq_nr) > 0
but if initial seq_number is above 32765, it overflows and returns false until the sequence resets.A simple fix I did locally and seemed to work, was to initialize max_seq_nr when base_seq is also initialized like this:
My initial tests show that it works as expected, and it is in accordance to rfc3550 A.1 where the pseudocode also initializes
max_seq
roughly the same way.I hope that I'm not missing something here, and that this improves Janus a little bit more!
The text was updated successfully, but these errors were encountered: