Red5WebRTCKit is the native iOS SDK for publishing and subscribing to live streams over WebRTC. It handles ICE negotiation, codec selection, camera and microphone capture, and license validation so you can focus on building your app. The SDK works with both Red5 Cloud (Stream Manager) deployments and standalone Red5 Pro servers, and is compatible with SwiftUI and UIKit.
Requirements
- iOS 13.0 or later
- Xcode 14.0 or later
- Swift 5.5 or later
- A valid Red5 Pro SDK license key
Installation
Add the SDK to your Xcode project using Swift Package Manager. Package URL:https://github.com/red5pro/red5pro-ios-sdk
Or declare it in your Package.swift:
Permissions
Add the following keys to yourInfo.plist before publishing. Camera permission is not required for audio-only sessions.
License key setup
Pass your license key to the builder with.setLicenseKey(). The SDK validates the key asynchronously when the client is built, and fires onLicenseValidated on your delegate before any streaming can begin.
Your license key is available on the Dev Resources page in the Red5 Cloud dashboard.
Minimal publish
Publishing requires three steps after the license validates: start a camera preview, then callpublish().
Build the client
Configure the client with your server details and media settings. Use
setStreamManagerHost() for Red5 Cloud or setServerIp() for a standalone server.Wait for license validation
The SDK fires
onLicenseValidated before any other callback. Start the camera preview only after validation succeeds.Publish when preview is ready
Enable your publish button in
onPreviewStarted, then call publish() when the user taps it.Minimal subscribe
Subscribing does not require a preview step. Build the client, attach a renderer for the incoming video, and callsubscribe().
Audio-only streaming
Set.setVideoEnabled(false) to publish or subscribe without video. No camera permission is required, and no RTCMTLVideoView renderer is needed.
publish() directly from onLicenseValidated — no preview step is needed:
Custom video settings
Configure resolution, frame rate, and bitrate on the builder before calling.build(). These settings cannot be changed after the client is created.
| Quality | Width | Height | FPS | Bitrate |
|---|---|---|---|---|
| 360p | 640 | 360 | 30 | 400 kbps |
| 480p | 854 | 480 | 30 | 750 kbps |
| 720p | 1280 | 720 | 30 | 1500 kbps |
| 720p 60fps | 1280 | 720 | 60 | 2500 kbps |
| 1080p | 1920 | 1080 | 30 | 3000 kbps |
Camera controls
Call these methods on the client instance any time afterstartPreview() completes.
Switch between front and back camera:
Event reference
ImplementRed5ProWebrtcEventDelegate in your class to receive SDK lifecycle events. All methods have default no-op implementations, so you only need to override the callbacks you care about.
Publish events
Publish events
| Callback | Description |
|---|---|
onPublishStarted() | Publish session started successfully |
onPublishStopped() | Publish session ended |
onPublishFailed(error: String) | Publish session failed |
Subscribe events
Subscribe events
| Callback | Description |
|---|---|
onSubscribeStarted() | Subscribe session started successfully |
onSubscribeStopped() | Subscribe session ended |
onSubscribeFailed(error: String) | Subscribe session failed |
Connection and lifecycle events
Connection and lifecycle events
| Callback | Description |
|---|---|
onPreviewStarted() | Local camera preview is running |
onPreviewStopped() | Local camera preview stopped |
onLicenseValidated(validated: Bool, message: String) | License check completed — always fires first |
onIceConnectionStateChanged(state: IceConnectionState) | ICE connection state changed |
onConnectionStateChanged(state: PeerConnectionState) | Peer connection state changed |
onError(error: String) | An unrecoverable error occurred |
Chat events
Chat events
| Callback | Description |
|---|---|
onChatConnected() | Connected to the PubNub chat service |
onChatDisconnected() | Disconnected from the PubNub chat service |
onChatMessageReceived(channel: String, message: Any) | Message received on the subscribed channel |
onChatSendSuccess(channel: String, timetoken: NSNumber) | Message sent successfully |
onChatSendError(channel: String, errorMessage: String) | Message failed to send |
Configuration reference
KeyRed5WebrtcClientBuilder methods:
| Method | Default | Description |
|---|---|---|
setStreamManagerHost(_ host: String) | — | Stream Manager host for Red5 Cloud |
setServerIp(_ ip: String) | — | Standalone server IP address |
setPort(_ port: Int) | 443 | Server port |
setAppName(_ name: String) | "live" | Application scope name |
setStreamName(_ name: String) | — | Stream name |
setLicenseKey(_ key: String) | — | Red5 Pro license key |
setVideoEnabled(_ enabled: Bool) | true | Enable or disable video |
setAudioEnabled(_ enabled: Bool) | true | Enable or disable audio |
setVideoWidth(_ width: Int) | 640 | Capture width in pixels |
setVideoHeight(_ height: Int) | 480 | Capture height in pixels |
setVideoFps(_ fps: Int) | 30 | Frame rate |
setVideoBitrate(_ bitrate: Int) | 500 | Bitrate in kbps |
setEventListener(_ delegate) | — | SDK event delegate |
Example apps
Each example is a self-contained Xcode project. CopyConfig.swift and the example file into a fresh project, fill in your server details, and run.
- 01-MinimalPublish — fewest lines needed to go live
- 02-MinimalSubscribe — fewest lines needed to receive a stream
- 03-AudioOnly — publish or subscribe with video disabled
- 04-CustomVideoSettings — configure resolution, frame rate, and bitrate
- 05-CameraControls — flip camera, mute/unmute video and audio while live
