Skip to content
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

Buffer RT(C)P packets that arrive pre-DTLS handshake completion #160

Merged
merged 2 commits into from
Aug 23, 2024

Conversation

sgfn
Copy link
Member

@sgfn sgfn commented Aug 22, 2024

This is exceedingly rare but can happen in extremely poor network conditions due to jitter -- and when it happens, it results in dropping the initial keyframe

@sgfn sgfn requested a review from LVala August 22, 2024 13:46
Copy link

codecov bot commented Aug 22, 2024

Codecov Report

Attention: Patch coverage is 57.14286% with 3 lines in your changes missing coverage. Please review.

Project coverage is 88.44%. Comparing base (6d67f23) to head (1db1043).
Report is 1 commits behind head on master.

Files Patch % Lines
lib/ex_webrtc/dtls_transport.ex 57.14% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #160      +/-   ##
==========================================
- Coverage   88.51%   88.44%   -0.07%     
==========================================
  Files          38       38              
  Lines        1916     1922       +6     
==========================================
+ Hits         1696     1700       +4     
- Misses        220      222       +2     
Files Coverage Δ
lib/ex_webrtc/dtls_transport.ex 84.25% <57.14%> (-0.88%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6d67f23...1db1043. Read the comment docs.

Copy link
Member

@LVala LVala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now it's probably fine, but we should also consider buffering DTLS packets that came out of order during the handshake (I assume that ExDTLS does not take care of that, so we would need to do something in {:error, reason} clause in the big case ExDTLS.handle_data(state.dtls, data) do statement.

Another thing I was thinking of is buffering packets send by us, because as of now we just throw a log and discard the packets.

If you don't want to take care of these and split attention between this and jitter buffer, just add a comment, especially about the DTLS packets, and I'll take care of that next week.

lib/ex_webrtc/dtls_transport.ex Outdated Show resolved Hide resolved
lib/ex_webrtc/dtls_transport.ex Outdated Show resolved Hide resolved
@@ -108,6 +108,7 @@ defmodule ExWebRTC.DTLSTransport do
ice_connected: false,
buffered_local_packets: nil,
buffered_remote_packets: nil,
buffered_remote_rtp_packets: [],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We aren't sure if these are RTP packets, it might as well be RTCP (or even SCTP data if we account for it, see other comment), so the name is a bit misleading.

I was thinking of reusing the buffered_remote_packets, as it's used for packets before negotiation, then is flushed (affair), so it could be used for that, although this might make the code a bit more cryptic.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I was wary of reusing the same buffer because of that. If you have suggestions for alternative names, I'm all ears

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now leave it, I'll think about it when taking care of buffering DTLS data.

@sgfn
Copy link
Member Author

sgfn commented Aug 23, 2024

@LVala added a TODO comment in the place you mentioned

@sgfn sgfn merged commit c0f5eec into master Aug 23, 2024
3 checks passed
@sgfn sgfn deleted the fix/dtls-transport-prehandshake-buffer branch August 23, 2024 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants