webrtc icon indicating copy to clipboard operation
webrtc copied to clipboard

Bandwidth Estimation with twcc

Open nemosupremo opened this issue 2 years ago • 10 comments

I may have missed something but I can't seem to find a way to retrieve the estimated available bandwidth when using configure_twcc. Is this something provided by webrtc-rs or is it something I have to build myself?

nemosupremo avatar Sep 22 '22 05:09 nemosupremo

I'm not super familiar with TWCC, but isn't the primary purpose of it to produce feedback reports and send those to the remote peer? This is what our implementation does.

One way to get the data is to use an interceptor and intercept the RTCP feedback packets as they are written. I guess there's no reason we couldn't expose the underlying data though, feel free to contribute something that enables that

k0nserv avatar Sep 22 '22 08:09 k0nserv

Relevant talk: https://www.youtube.com/watch?v=zQsJeHUc2TQ

You have the TWCC RTCP feedback packets available to do your own send side estimation. But as @k0nserv said you need to feed it to your app through a interceptor.

xnorpx avatar Sep 22 '22 15:09 xnorpx

If I read the draft correctly, just the RTCP packets won't be enough - the departure time of the packet and the transport sequence number set by SenderStream are also needed.

I think the TransportCcExtension set over there can be squeezed out from the current implementation with a custom RTPWriter (if the Interceptor's are run sequentially via the order of adding to the Registry). Or if that won't work, I suppose you could just create a wrapper type around interceptor::twcc::sender::Sender and directly capture the SenderStream returned by its bind_local_stream.

JRF63 avatar Sep 25 '22 06:09 JRF63

https://github.com/signalapp/Signal-Calling-Service/blob/main/src/googcc.rs https://github.com/signalapp/Signal-Calling-Service/blob/main/src/transportcc.rs

sarumjanuch avatar Sep 25 '22 10:09 sarumjanuch

https://github.com/signalapp/Signal-Calling-Service/blob/main/src/googcc.rs https://github.com/signalapp/Signal-Calling-Service/blob/main/src/transportcc.rs

That's AGPLv3. Not exactly legal to just plop the code over here.

JRF63 avatar Sep 25 '22 13:09 JRF63

I'd suggest looking at Pion if anyone is interested in improving this. I believe there has been fairly significant work on interceptors like this since the port(webrtc-rs was ported from Pion)

k0nserv avatar Sep 25 '22 13:09 k0nserv

Relevant Pion code https://github.com/pion/interceptor/tree/master/pkg/gcc

k0nserv avatar Oct 10 '22 16:10 k0nserv

Made a clean room implementation of TWCC way back in November. I've been using it in this desktop streaming app, it works but that's hardly a substitute for a proper test. I think I'd prefer Pion's rather than mine just for consistency's sake.

JRF63 avatar Jan 13 '23 14:01 JRF63

There seems to be twcc code here now webrtc/interceptor/src/twcc. However there are no examples I can find on how to use it. Can the bandwidth-estimation-from-disk from pion be ported yet or is there more work to do?

warvstar avatar Dec 22 '23 18:12 warvstar

There seems to be twcc code here now webrtc/interceptor/src/twcc. However there are no examples I can find on how to use it. Can the bandwidth-estimation-from-disk from pion be ported yet or is there more work to do?

I think that's just for the sending/receiving of RTCPs and not the TWCC algorithm itself. Code on 0.10.0 looks to be the same as on 0.8.1 back when I made mine last year.

JRF63 avatar Dec 25 '23 16:12 JRF63