webrtc-java
webrtc-java copied to clipboard
How to solve the problem of bufferedAmount being full
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();