Skip to content

feat: tell data channel observers when the buffered amount is low - #605

Merged
devopvoid merged 2 commits into
mainfrom
feat/data-channel-buffered-amount-low
Nov 26, 2026
Merged

devopvoid merged 2 commits into
mainfrom
feat/data-channel-buffered-amount-low

Conversation

@devopvoid

Copy link
Copy Markdown
Owner

Description

  • RTCDataChannel.setBufferedAmountLowThreshold(long) sets the threshold, 0 by default.
  • RTCDataChannelObserver.onBufferedAmountLow(), a default method, is called once the buffered amount falls from above the threshold to it or below.

The channel counts the buffered amount itself, raised by every send and lowered by every decrease the observer hears of, as browsers do. The native value, read on the observer's thread, has often fallen further by then and would hide where an event crossed the threshold.

Motivation and Context

A sender of much data can keep the buffer between a low and a high mark and send more as soon as there is room, without polling getBufferedAmount().

Type of Change

  • New feature (feat)

Affected Modules

  • webrtc (Java API)
  • webrtc-jni (native code)
  • docs

Notes for Reviewers

The SCTP transport PR adds a helper at the same place in TestDataChannelPair; whichever merges second keeps both methods.

…ests

Many small sends let the buffer drain meanwhile on fast and slow machines alike, so it crossed the threshold any number of times, or never.
@devopvoid
devopvoid merged commit 1766e4e into main Nov 26, 2026
27 checks passed
@devopvoid
devopvoid deleted the feat/data-channel-buffered-amount-low branch November 26, 2026 16:39
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