interceptor icon indicating copy to clipboard operation
interceptor copied to clipboard

The Jitter buffer iterceptor doesn't handle packet loss

Open braams opened this issue 1 year ago • 1 comments

Your environment.

  • Version: 72c0be86db35deb9b0a7361063314923a3d9a68c

What did you do?

I'm trying to use jitter buffer interceptor.

What did you expect?

I expect to get an error on read if the current packet was lost. And I expect to get the next packet on the next read.

What happened?

If even one packet was lost, all subsequent reads will return an error.

The reason

The interceptor does not handle the situation with the absence of the next packet and does not shift the expected packet number https://github.com/pion/interceptor/blob/142f17f90b527434b62ce2fd92676e6e262cd807/pkg/jitterbuffer/receiver_interceptor.go#L73 It looks like we should add something like this:

if errors.Is(err, ErrNotFound) {
	i.buffer.SetPlayoutHead(i.buffer.PlayoutHead() + 1)
}

braams avatar Jun 05 '24 14:06 braams

@braams My intent here was that the user of the jitter buffer is in the best position to decide the next step. If a packet is lost and it's appropriate to retransmit then all of that has to be done outside the jitter buffer context. If you wish to skip the dropped packet then call SetPlayoutHead to skip the unrecoverable packets. I'm definitely open to suggestions or improvements here, and if adding an option to skip missed packets is helpful we can discuss what that might look like!

thatsnotright avatar Aug 30 '24 16:08 thatsnotright