Skip to content

Add asynchronous data channel sends and bridge the ICE selected candidate pair#3

Open
SendableMetatype wants to merge 2 commits into
Kas-tle:masterfrom
SendableMetatype:sendasync-and-candidate-pair
Open

Add asynchronous data channel sends and bridge the ICE selected candidate pair#3
SendableMetatype wants to merge 2 commits into
Kas-tle:masterfrom
SendableMetatype:sendasync-and-candidate-pair

Conversation

@SendableMetatype

Copy link
Copy Markdown

Two additions from running webrtc-java as the data channel transport of a Geyser based Bedrock proxy in production.

sendAsync on RTCDataChannel. Send is a blocking proxy call that stalls the caller on the native network thread until the send is processed. Under load, with every game packet of every player crossing that call, all senders serialize on one thread. sendAsync posts instead and copies the payload out before returning, so callers can reuse their buffers immediately. For direct buffers only the bytes between position and limit are sent. Queueing failures are logged natively and fatal errors surface through the data channel observer as a state change.

OnIceSelectedCandidatePairChanged bridge. libwebrtc reports the nominated candidate pair before DTLS and SCTP come up, which is the only clean moment to learn a connection's real remote transport address (the getStats route is async and lands after activation). Exposed as a backward compatible default method on PeerConnectionObserver carrying the remote candidate's ip, port, and candidate type. Field access follows the Android SDK bridge (event.selected_candidate_pair.remote_candidate()).

Both are running in production on the linux x86_64 native; all platforms build and the existing test suites pass on my fork's CI.

Send is a blocking proxy call that stalls the caller on the native
network thread until the send is processed. sendAsync posts instead,
copying the payload out before returning so callers can reuse their
buffers immediately. For direct buffers only the bytes between position
and limit are sent. Queueing failures are logged natively and fatal
errors surface through the data channel observer as a state change.
Exposes the remote address of the ICE nominated candidate pair. The
callback fires before DTLS, SCTP, and the data channels open, so
consumers can attach the real remote transport address to a connection
before it becomes active. Backward compatible default method; existing
observers are unaffected.
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.

1 participant