-
Notifications
You must be signed in to change notification settings - Fork 459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Transport Wide Congestion Control support (TWCC) reports and some bug fixes #1331
base: master
Are you sure you want to change the base?
Conversation
RTC updates
use wyze camera name from url
Add timeout to ice gathering Add prefer H264 flag for compatible formats
Add sanity check for ICE Gathering timeout
Add sanity check for ICE Gathering timeout Fix bug in g722 codec
Fix bug where duplicate durations were being added to local track timestamp in SendAudioFrame Ignore H264 formats that use unsupported packetization modes Clean up logic in AreMatch
Fix SDP parsing of audio m fields with ports Return null if stream not matched (was causing issues with RTP processing) Use PrimaryStream to unprotect incoming RTP packets Fix logic bug in SendRtpRaw Prevent some buffer over-reads var videoExtensions = new Dictionary<int, RTPHeaderExtension>(); videoExtensions.Add(extensionId, RTPHeaderExtension.GetRTPHeaderExtension(extensionId++, TransportWideCCExtension.RTP_HEADER_EXTENSION_URI, SDPMediaTypesEnum.video)); MediaStreamTrack videoTrack = new MediaStreamTrack(SDPMediaTypesEnum.video, false, formats.Select(x => new SDPAudioVideoMediaFormat(x)).ToList(), MediaStreamStatusEnum.SendOnly, null, videoExtensions ); in OnReceiveReport access rr.TWCCFeedback
Co-authored-by: Paulo Morgado <470455+paulomorgado@users.noreply.github.com>
Co-authored-by: Paulo Morgado <470455+paulomorgado@users.noreply.github.com>
uint ssrc = BitConverter.IsLittleEndian ? NetConvert.DoReverseEndian(rawSsrc) : rawSsrc; | ||
|
||
|
||
var secureContext = PrimaryStream.GetSecurityContext(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this being changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because for some reason i couldn't resolve GetMediaStream(ssrc) could never find the media stream from the ssrc and as they all use the same unprotect method anyway I figured might as well just use the security context from the primary stream to unprotect the packet and that also saves a convoluted lookup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments added for some requested changes.
I've actioned the requested changes |
Add Transport Wide Congestion Control support (TWCC).
I've only tested this in receiving reports. Seems to work ok.
Return null if stream not matched (was causing issues with RTP processing)
Use PrimaryStream to unprotect incoming RTP packets
Fix logic bug in SendRtpRaw :
if ( (ext.Id < 1) && (ext.Id > 14) ) is never satisfied
Prevent some buffer over-reads
To hook up TWCC reports example:
in
OnReceiveReport access rr.TWCCFeedback
You can hook up these reports to adjust bit_rate limits on your encoder for example:
[TWCCBitrateController] RollingAvgDelay: 4015µs, RollingLossRate: 5.9 %, NewBitrate: 205732bps
[TWCCBitrateController] RollingAvgDelay: 3656µs, RollingLossRate: 5.3 %, NewBitrate: 174872bps
[TWCCBitrateController] RollingAvgDelay: 3653µs, RollingLossRate: 4.8 %, NewBitrate: 184872bps
[TWCCBitrateController] RollingAvgDelay: 3529µs, RollingLossRate: 4.3 %, NewBitrate: 194872bps
[TWCCBitrateController] RollingAvgDelay: 3337µs, RollingLossRate: 3.9 %, NewBitrate: 204872bps
[TWCCBitrateController] RollingAvgDelay: 3387µs, RollingLossRate: 3.5 %, NewBitrate: 214872bps
[TWCCBitrateController] RollingAvgDelay: 3642µs, RollingLossRate: 3.1 %, NewBitrate: 224872bps
[TWCCBitrateController] RollingAvgDelay: 3359µs, RollingLossRate: 2.8 %, NewBitrate: 234872bps
[TWCCBitrateController] RollingAvgDelay: 3312µs, RollingLossRate: 2.5 %, NewBitrate: 244872bps
[TWCCBitrateController] RollingAvgDelay: 3299µs, RollingLossRate: 2.3 %, NewBitrate: 254872bps
[TWCCBitrateController] RollingAvgDelay: 3174µs, RollingLossRate: 2.1 %, NewBitrate: 264872bps
[TWCCBitrateController] RollingAvgDelay: 2936µs, RollingLossRate: 3.2 %, NewBitrate: 274872bps
[TWCCBitrateController] RollingAvgDelay: 2642µs, RollingLossRate: 12.2 %, NewBitrate: 233641bps
[TWCCBitrateController] RollingAvgDelay: 2557µs, RollingLossRate: 11.0 %, NewBitrate: 198595bps
[TWCCBitrateController] RollingAvgDelay: 2301µs, RollingLossRate: 17.4 %, NewBitrate: 168806bps
[TWCCBitrateController] RollingAvgDelay: 2363µs, RollingLossRate: 15.6 %, NewBitrate: 143485bps
[TWCCBitrateController] RollingAvgDelay: 2240µs, RollingLossRate: 14.1 %, NewBitrate: 121962bps
[TWCCBitrateController] RollingAvgDelay: 2115µs, RollingLossRate: 12.7 %, NewBitrate: 103668bps
[TWCCBitrateController] RollingAvgDelay: 2035µs, RollingLossRate: 11.4 %, NewBitrate: 88118bps
[TWCCBitrateController] RollingAvgDelay: 2252µs, RollingLossRate: 10.3 %, NewBitrate: 74900bps
[TWCCBitrateController] RollingAvgDelay: 2042µs, RollingLossRate: 9.2 %, NewBitrate: 63665bps