devopvoid / webrtc-java

WebRTC for desktop platforms running Java
Apache License 2.0
248 stars 60 forks source link

How to solve the problem of bufferedAmount being full #143

Open kingtonlee opened 1 month ago

kingtonlee commented 1 month ago

How to implement the following code using Java. When the bufferedAmount changes, onBufferedAmountChange is not executed, and the bufferedAmount cannot be reduced. It always remains at the critical value of 16M.

const send = () => { while (buffer.byteLength) { if (dataChannel.bufferedAmount > dataChannel.bufferedAmountLowThreshold) { dataChannel.onbufferedamountlow = () => { dataChannel.onbufferedamountlow = null; send(); }; return; } const chunk = buffer.slice(0, chunkSize); buffer = buffer.slice(chunkSize, buffer.byteLength); dataChannel.send(chunk); } }; send();