feat: added audio capture for ios broadcast screensharing mode - #58
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds an Objective-C-exposed iOS screen-audio socket reader that parses framed PCM data into audio buffers. The mixer now accepts PCM input, filters silence, reports missing formats once, and limits buffered latency. The recording audio session also enables mixing with other audio. ChangesScreen audio pipeline
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Stream
participant ScreenAudioCapture
participant ScreenShareAudioMixer
participant AudioRingBuffer
Stream->>ScreenAudioCapture: provide framed PCM bytes
ScreenAudioCapture->>ScreenShareAudioMixer: deliver AVAudioPCMBuffer
ScreenShareAudioMixer->>AudioRingBuffer: enqueue PCM and trim backlog
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@ios/RCTWebRTC/ScreenAudioCapture.swift`:
- Around line 197-212: Update ScreenAudioCapture.stream(_:handle:) so the
.errorOccurred case calls stop() after logging the stream error, ensuring the
audio socket and related resources are torn down consistently with
.endEncountered.
- Around line 91-94: Adjust the overflow guard in readBytes to account for the
complete frame size, including headerSize, so frames with payloadLength up to
maxAccumulatorBytes can finish without being reset. Keep the payload-length
validation in readBytes unchanged and retain the existing reset behavior only
for accumulators exceeding the corrected total bound.
- Around line 54-61: Update start() to close the existing connection before
assigning a new SocketConnection. Preserve the current setup flow, but invoke
close() on the prior connection whenever one is present, then replace it and
open the new connection.
- Around line 141-194: Update makePCMBuffer to handle non-interleaved
multi-channel payloads instead of always copying into bufferList.first. For
isInterleaved == false, calculate frame count using the complete per-frame
payload layout and distribute each channel’s samples across the corresponding
AudioBuffer; preserve the existing single-buffer copy path for interleaved audio
and reject malformed payload sizes safely.
In
`@ios/RCTWebRTC/Utils/AudioDeviceModule/ScreenShare/ScreenShareAudioMixer.swift`:
- Around line 143-147: Update enqueue to downmix all channels in buffer into a
mono sample stream before ringBuffer.write, averaging corresponding samples
across the available channels rather than writing only channelData[0]. Preserve
the existing silence check and frame count, and keep mixFromRingBuffer’s
mono-to-output-channel behavior unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: d6a6bb52-7e6b-4376-928d-4342437a9435
📒 Files selected for processing (3)
ios/RCTWebRTC/ScreenAudioCapture.swiftios/RCTWebRTC/Utils/AudioDeviceModule/ScreenShare/AudioRingBuffer.swiftios/RCTWebRTC/Utils/AudioDeviceModule/ScreenShare/ScreenShareAudioMixer.swift
## [145.2.0](v145.1.1...v145.2.0) (2026-08-04) ### Features * added audio capture for ios broadcast screensharing mode ([#58](#58)) ([aa011d1](aa011d1))
|
🎉 This PR is included in version 145.2.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
### 💡 Overview Added audio capturing for iOS broadcast screen sharing type. Added `.mixWithOthers` default option to all audio session configurations, which prevents audio engine from stopping when other apps start audio session with different configuration. Changed default screen sharing type in dogfood app. ### 📝 Implementation notes Added `AudioUploader` which works similar to `SampleUploader`: it sends bytes data via socket connection. Server is started on webrtc side. Bytes chunks are accumulated and pushed to ring buffer as they are ready. Audio mixing part stays as is (as it was for in-app audio capturing). 🎫 Ticket: https://linear.app/stream/issue/RN-416/ios-broadcast-screen-sharing-audio-capturing 📑 Docs: GetStream/docs-content#1457 Corresponding WebRTC PR: GetStream/react-native-webrtc#58 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added audio streaming for iOS broadcast screen sharing. * Video and broadcast audio now use separate connections. * Broadcast audio is streamed to the app and mixed into the screen-share audio track, including a fallback capture path. * Added bounded retry handling for broadcast audio connections. * **Improvements** * Audio sessions can now mix with other audio sources. * **Documentation** * Updated guidance for the iOS `includeAudio` option. * **Sample App** * Enabled broadcast screen sharing with audio. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Summary by CodeRabbit
New Features
Bug Fixes