-
Notifications
You must be signed in to change notification settings - Fork 46
fix(llc): minor code fixes #1051
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
Conversation
WalkthroughConditionalizes androidAudioConfiguration usage in Android WebRTC initialization to avoid null dereference. Revises SVC encodings generation to select the highest available base layer among f, h, q and emit a single encoding mapped to rid 'q' with copied parameters. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant App
participant StreamVideo
participant WebRTC
App->>StreamVideo: new StreamVideo(options)
alt Platform == Android
alt options.androidAudioConfiguration != null
StreamVideo->>WebRTC: initialize({ androidAudioConfiguration })
else androidAudioConfiguration is null
StreamVideo->>WebRTC: initialize({})
end
else Platform == iOS
StreamVideo->>WebRTC: initialize(iOS options)
end
sequenceDiagram
autonumber
participant Caller
participant RtcManager
participant LayerHelper as findLayerByRid()
Caller->>RtcManager: toSvcEncodings(layers)
RtcManager->>LayerHelper: find 'f'
alt 'f' not found
RtcManager->>LayerHelper: find 'h'
alt 'h' not found
RtcManager->>LayerHelper: find 'q'
alt none found
RtcManager-->>Caller: []
else 'q' found
RtcManager-->>Caller: [encoding rid 'q' from 'q']
end
else 'h' found
RtcManager-->>Caller: [encoding rid 'q' from 'h']
end
else 'f' found
RtcManager-->>Caller: [encoding rid 'q' from 'f']
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/stream_video/lib/src/webrtc/rtc_manager.dart (1)
761-784: SVC encoding: add fallback for rid-less inputs and simplify lookupCurrent logic assumes rids among {'f','h','q'}. If upstream returns encodings without rids (or different labels),
toSvcEncodingsreturns an empty list, delegating defaults to the engine. Consider a small robustness bump:
- Use
firstWhereOrNullto simplifyfindByRid.- Fall back to
layers.firstOrNullif none of f/h/q are present to still honor upstream bitrate/framerate/scalabilityMode decisions.Proposed diff:
List<rtc.RTCRtpEncoding> toSvcEncodings(List<rtc.RTCRtpEncoding> layers) { - rtc.RTCRtpEncoding? findByRid(String rid) { - for (final layer in layers) { - if (layer.rid == rid) return layer; - } - return null; - } - - final highestLayer = findByRid('f') ?? findByRid('h') ?? findByRid('q'); - if (highestLayer == null) return []; + rtc.RTCRtpEncoding? findByRid(String rid) => + layers.firstWhereOrNull((e) => e.rid == rid); + + // Prefer full > half > quarter; if no known rid present, use the first layer as a best-effort fallback. + final highestLayer = + findByRid('f') ?? findByRid('h') ?? findByRid('q') ?? layers.firstOrNull; + if (highestLayer == null) return []; return [ rtc.RTCRtpEncoding( rid: 'q', active: highestLayer.active, maxBitrate: highestLayer.maxBitrate, maxFramerate: highestLayer.maxFramerate, minBitrate: highestLayer.minBitrate, numTemporalLayers: highestLayer.numTemporalLayers, scaleResolutionDownBy: highestLayer.scaleResolutionDownBy, ssrc: highestLayer.ssrc, scalabilityMode: highestLayer.scalabilityMode, ) ]; }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
packages/stream_video/lib/src/stream_video.dart(1 hunks)packages/stream_video/lib/src/webrtc/rtc_manager.dart(1 hunks)
🔇 Additional comments (2)
packages/stream_video/lib/src/stream_video.dart (1)
183-187: Null-safe Android audio config injection looks correctConditionalizing
androidAudioConfigurationon both Android platform and non-null value avoids the previous null dereference while keeping iOS/other platforms unaffected. Good defensive fix.packages/stream_video/lib/src/webrtc/rtc_manager.dart (1)
761-784: Fallback logic validated
Verified thatfindOptimalVideoLayersonly ever emitsridvalues from ['f', 'h', 'q'], so thefindByRid('f') ?? findByRid('h') ?? findByRid('q')fallback always covers the highest available layer. No changes needed.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1051 +/- ##
========================================
- Coverage 4.83% 4.83% -0.01%
========================================
Files 577 577
Lines 38826 38830 +4
========================================
Hits 1877 1877
- Misses 36949 36953 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary by CodeRabbit