-
Notifications
You must be signed in to change notification settings - Fork 196
fix x-google-start-bitrate for vp8 and other codex and make it adaptive to network #1226
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
Changes from all commits
d0413db
8c27abf
038f0f7
0790556
501a6b7
a1c6b4f
aa8e8c2
6d5d9c9
50cd4aa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| --- | ||
| "livekit": patch | ||
| --- | ||
|
|
||
| Simplify x-google-start-bitrate logic and update degradation preference defaults | ||
|
|
||
| - Start bitrate: use min(90% of target, 1 Mbps) instead of adaptive network hints | ||
| - Remove slow connection detection and network quality hints on reconnect | ||
| - Default degradation preference by track source: | ||
| - Camera: MaintainFramerate (smoother video) | ||
| - Screenshare: MaintainResolution (clarity for text/UI) | ||
| - Other: Balanced |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -142,12 +142,14 @@ pub struct TrackPublishOptions { | |
| /// Controls how the encoder trades off between resolution and framerate | ||
| /// when bandwidth is constrained. | ||
| /// | ||
| /// - `MaintainResolution`: Prioritizes resolution, drops frames if needed | ||
| /// - `MaintainFramerate`: Prioritizes framerate, reduces resolution if needed | ||
| /// - `MaintainResolution`: Prioritizes resolution, drops frames if needed | ||
| /// - `Balanced`: Balances between both | ||
| /// | ||
| /// If not set, the SDK will use a smart default based on the track source | ||
| /// and resolution (MaintainResolution for screenshare or video >= 540p). | ||
| /// If not set, the SDK uses defaults based on track source: | ||
| /// - Camera: `MaintainFramerate` (smoother video for real-time communication) | ||
| /// - Screen share: `MaintainResolution` (clarity is critical for text/UI) | ||
| /// - Other/unknown: `Balanced` | ||
| pub degradation_preference: Option<DegradationPreference>, | ||
| } | ||
|
|
||
|
|
@@ -175,14 +177,10 @@ impl Default for TrackPublishOptions { | |
| /// Returns the appropriate degradation preference for a video track. | ||
| /// | ||
| /// If the user explicitly set a preference in `TrackPublishOptions`, that is returned. | ||
| /// Otherwise, defaults to `MaintainResolution` for all video tracks. | ||
| /// | ||
| /// `MaintainResolution` ensures video clarity is preserved during bandwidth constraints | ||
| /// by dropping frames rather than reducing resolution. This prevents the "blurry video" | ||
| /// issue that users commonly report during initial connection or network fluctuations. | ||
| /// | ||
| /// Users who prefer smoother video over clarity can explicitly set `Balanced` or | ||
| /// `MaintainFramerate` in their `TrackPublishOptions`. | ||
| /// Otherwise, defaults based on track source: | ||
| /// - `MaintainFramerate` for camera tracks (smoother video for real-time communication) | ||
| /// - `MaintainResolution` for screen share (clarity is critical for reading text/UI) | ||
| /// - `Balanced` for other/unknown sources | ||
| pub fn get_default_degradation_preference( | ||
| options: &TrackPublishOptions, | ||
| _height: u32, | ||
|
|
@@ -192,9 +190,12 @@ pub fn get_default_degradation_preference( | |
| return pref; | ||
| } | ||
|
|
||
| // Default to MaintainResolution for all video tracks to prevent blurry video | ||
| // during bandwidth ramp-up or network constraints | ||
| DegradationPreference::MaintainResolution | ||
| // Default based on track source | ||
| match options.source { | ||
| TrackSource::Camera => DegradationPreference::MaintainFramerate, | ||
| TrackSource::Screenshare => DegradationPreference::MaintainResolution, | ||
| _ => DegradationPreference::Balanced, | ||
| } | ||
|
Comment on lines
+193
to
+198
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔍 Degradation preference default change is a significant behavioral shift for camera tracks The default degradation preference for camera tracks changed from Was this helpful? React with 👍 or 👎 to provide feedback. |
||
| } | ||
|
|
||
| impl VideoPreset { | ||
|
|
@@ -571,29 +572,28 @@ mod tests { | |
| } | ||
|
|
||
| #[test] | ||
| fn degradation_preference_defaults_to_maintain_resolution() { | ||
| // All sources should default to MaintainResolution | ||
| fn degradation_preference_defaults_by_source() { | ||
| // Camera defaults to MaintainFramerate (smoother video) | ||
| let camera_options = | ||
| TrackPublishOptions { source: TrackSource::Camera, ..Default::default() }; | ||
| let screenshare_options = | ||
| TrackPublishOptions { source: TrackSource::Screenshare, ..Default::default() }; | ||
| let default_options = TrackPublishOptions::default(); | ||
|
|
||
| assert_eq!( | ||
| get_default_degradation_preference(&camera_options, 1080), | ||
| DegradationPreference::MaintainResolution | ||
| DegradationPreference::MaintainFramerate | ||
| ); | ||
|
|
||
| // Screenshare defaults to MaintainResolution (clarity for text/UI) | ||
| let screenshare_options = | ||
| TrackPublishOptions { source: TrackSource::Screenshare, ..Default::default() }; | ||
| assert_eq!( | ||
| get_default_degradation_preference(&screenshare_options, 1080), | ||
| DegradationPreference::MaintainResolution | ||
| ); | ||
|
|
||
| // Unknown/default source defaults to Balanced | ||
| let default_options = TrackPublishOptions::default(); | ||
| assert_eq!( | ||
| get_default_degradation_preference(&default_options, 720), | ||
| DegradationPreference::MaintainResolution | ||
| ); | ||
| assert_eq!( | ||
| get_default_degradation_preference(&default_options, 360), | ||
| DegradationPreference::MaintainResolution | ||
| DegradationPreference::Balanced | ||
| ); | ||
| } | ||
|
|
||
|
|
||
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.
🔍 Matching on Err(WsError::Io(ref io_err)) may not match wrapped TLS errors
The pattern
Err(WsError::Io(ref io_err)) if io_err.kind() == UnexpectedEofatlivekit-api/src/signal_client/signal_stream.rs:413-419assumes the TLS close-without-close_notify surfaces as a directio::ErrorwithUnexpectedEofkind. Depending on the tungstenite version and TLS backend (native-tls vs rustls), TLS errors may be wrapped differently — e.g., asWsError::Tls(...)rather thanWsError::Io(...). If the TLS error doesn't surface asWsError::Io, this handler won't match and the error will fall through to the catch-all_ =>branch (which still breaks, just with an error log). Not a correctness bug, but the handler may be less effective than intended.Was this helpful? React with 👍 or 👎 to provide feedback.