webrtc-rs / webrtc

A pure Rust implementation of WebRTC
https://webrtc.rs
Apache License 2.0
4.14k stars 368 forks source link

Bandwidth Estimation with twcc #298

Open nemosupremo opened 2 years ago

nemosupremo commented 2 years ago

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?

k0nserv commented 2 years ago

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

xnorpx commented 2 years ago

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.

JRF63 commented 2 years ago

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.

sarumjanuch commented 2 years ago

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

JRF63 commented 2 years ago

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.

k0nserv commented 2 years ago

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 commented 2 years ago

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

JRF63 commented 1 year ago

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.

warvstar commented 10 months ago

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?

JRF63 commented 10 months ago

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.