Skip to content

feat: add RTCRtpSendParameters.fecProtection and bump libwebrtc to 150.7871.09 - #123

Draft
cloudwebrtc wants to merge 1 commit into
masterfrom
duan/fec-protection
Draft

cloudwebrtc wants to merge 1 commit into
masterfrom
duan/fec-protection

Conversation

@cloudwebrtc

Copy link
Copy Markdown

What changed

  • Bump the native libwebrtc dependencies from 150.7871.04 to 150.7871.09:
    • Android (android/build.gradle): io.github.webrtc-sdk:android-prefixed
    • iOS (livekit-react-native-webrtc.podspec): LiveKitWebRTC, published to livekit/podspecs (not on CocoaPods trunk)
  • Add a non-standard fecProtection field to RTCRtpSendParameters, with exported RTCRtpFecProtection and RTCFecProtectionMode types:
    • mode: 'adaptive' | 'fixed' | 'minimum' | 'disabled'
    • protectionFactor, plus optional keyFrameProtectionFactor and maxFecFrames
  • Serialize the field in both directions on Android (SerializeUtils) and iOS (LKRNSerializeUtils, updateParametersWithOptions), next to degradationPreference.
const params = sender.getParameters();
params.fecProtection = { mode: 'fixed', protectionFactor: 0.25 };
await sender.setParameters(params);

Why

150.7871.09 includes the sender-wide RtpFecProtection policy from livekit/libwebrtc#329 and the simulcast stats crash fix from livekit/libwebrtc#351. The policy controls how much FlexFEC a video sender produces, which client-sdk-js needs for its FlexFEC publish option in React Native. Browsers have no equivalent field and drop it.

Notes for review

  • Unlike degradationPreference, toJSON() always sends fecProtection, as null when unset. Native code then sets or clears the policy, so assigning null and calling setParameters restores the adaptive default.
  • Out-of-range values (a factor above 1.0, maxFecFrames above 6) or a policy on an audio sender make native setParameters return false. As with the other fields, that result is ignored today: the promise resolves with the unchanged parameters.
  • The policy only matters once FEC is negotiated. Turning on FlexFEC (the WebRTC-FlexFEC-03 and WebRTC-FlexFEC-03-Advertised field trials) is left to client-sdk-react-native, which already sets field trials in its native setup().

Testing

  • npm run lint (eslint, tsc --noEmit, native prefix check)
  • GumTestApp Android assembleDebug against 150.7871.09
  • GumTestApp iOS simulator build of the livekit-react-native-webrtc pod against 150.7871.09. With the current Xcode this needed IPHONEOS_DEPLOYMENT_TARGET=15.0 and -Wno-deprecated-literal-operator for RN 0.71's Yoga headers; neither is part of this change.
  • Not yet tested on a device: set/get round trip, and fecPacketsSent growing at fixed 0.25 against a FlexFEC-enabled server.

Bump io.github.webrtc-sdk:android-prefixed and LiveKitWebRTC to
150.7871.09, which adds the sender-wide RtpFecProtection policy
(livekit/libwebrtc#329) and the simulcast stats crash fix
(livekit/libwebrtc#351).

Expose the policy as a non-standard fecProtection field on
RTCRtpSendParameters, serialized on Android and iOS next to
degradationPreference. JS always sends the field, so assigning null
and calling setParameters clears a previously set policy.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant