Screen Capturer
LiveKit provides platform-specific screen capture capabilities for iOS and macOS. The implementation varies based on platform capabilities and requirements.macOS Screen Capture
MacOSScreenCapturer
Available on macOS 12.3+,MacOSScreenCapturer uses ScreenCaptureKit for high-performance screen and window capture.
Creating a Screen Share Track
Enumerating Screen Sources
Display Sources
Window Sources
All Sources
Source Types
MacOSDisplay Represents a display/monitor:| Property | Type | Description |
|---|---|---|
displayID | CGDirectDisplayID | Unique display identifier |
width | Int | Display width in pixels |
height | Int | Display height in pixels |
frame | CGRect | Display frame |
| Property | Type | Description |
|---|---|---|
windowID | CGWindowID | Unique window identifier |
frame | CGRect | Window frame |
title | String? | Window title |
windowLayer | Int | Window layer level |
owningApplication | MacOSRunningApplication? | Application that owns the window |
isOnScreen | Bool | Whether window is currently visible |
isCurrentApplication | Bool | Whether window belongs to current app |
Capturing Specific Windows
Excluding Windows
iOS Screen Capture
In-App Screen Capture
For capturing only your app’s content (iOS 11+):Broadcast Extension (Full Screen)
For full-screen capture including other apps, you need to implement a Broadcast Upload Extension. The SDK automatically uses the broadcast extension if configured:Screen Share Capture Options
ScreenShareCaptureOptions
Configure screen capture with these properties:| Property | Type | Default | Description |
|---|---|---|---|
dimensions | Dimensions | .h1080_169 | Target capture dimensions |
fps | Int | 30 | Frames per second |
showCursor | Bool | true | Show cursor in capture (macOS only) |
appAudio | Bool | false | Capture application audio (macOS 13+) |
useBroadcastExtension | Bool | auto | Use broadcast extension (iOS only) |
includeCurrentApplication | Bool | false | Include own app windows (macOS only) |
excludeWindowIDs | [UInt32] | [] | Window IDs to exclude (macOS only) |
Capturing Application Audio (macOS 13+)
On macOS 13 and later, you can capture audio from the screen share source:AudioManager and mixed with other audio sources.
Frame Resending
When screen content is static,MacOSScreenCapturer automatically resends the last frame at 1 fps to maintain the video stream. This ensures:
- Continuous video stream even when content doesn’t change
- Efficient bandwidth usage during static periods
- Smooth experience for viewers
Platform-Specific Considerations
macOS
- Requires macOS 12.3+ for ScreenCaptureKit-based capture
- User must grant screen recording permission in System Preferences
- Can capture individual windows or entire displays
- Supports audio capture on macOS 13+
- Automatically filters out small or system windows
iOS
- In-app capture only captures your app (iOS 11+)
- Full-screen capture requires Broadcast Upload Extension
- User initiates broadcast from Control Center
- Limited to portrait or landscape orientation
Error Handling
deviceNotFound: No screen capture source availableinvalidState: Screen capture permission not granted- Permission errors on macOS if screen recording is not allowed
See Also
- Camera Capturer - Camera video capture
- Custom Capturer - Creating custom video capturers
- LocalVideoTrack - Publishing screen share video