The Red5 iOS SDK Testbed is a comprehensive example application that demonstrates the capabilities of the Red5 iOS SDK. This testbed provides working examples of publishing and subscribing to streams on both Red5 Cloud (Stream Manager) and standalone Red5Pro servers.
- Introduction
- Features
- Requirements
- Installation
- Configuration
- Usage
- 6.1 Settings Screen
- 6.2 Publishing Examples
- 6.3 Subscribing Examples
- Testing
- Troubleshooting
The testbed includes the following features:
- Stream Manager Publishing: Publish streams to Red5 Cloud using Stream Manager
- Standalone Publishing: Publish streams to standalone Red5Pro servers
- Stream Manager Subscribing: Subscribe to streams from Red5 Cloud
- Standalone Subscribing: Subscribe to streams from standalone Red5Pro servers
- Settings Management: Persistent settings for stream configuration
- Camera Controls: Switch between front and back cameras
- Audio/Video Controls: Mute/unmute microphone and enable/disable camera
- SwiftUI Interface: Modern SwiftUI-based user interface
- Real-time Status Updates: Live connection status and event notifications
You can clone this testbed project to explore all available features and implementations, or continue with the examples below to get started quickly.
- iOS 13.0 or later
- Xcode 14.0 or later
- Swift 5.5 or later
- Red5Pro SDK license key
- Red5Pro server (Cloud or standalone)
- Clone the repository:
git clone https://github.com/red5pro/red5pro-ios-testbed.git
cd red5pro-ios-testbed- Open the project in Xcode:
open SampleApp.xcodeproj- Install dependencies (if using CocoaPods):
pod install
open SampleApp.xcworkspace-
Add the Red5 iOS SDK framework to the project:
- Drag and drop the Red5WebRTCKit framework into your project
- Ensure it's added to "Frameworks, Libraries, and Embedded Content"
-
Configure your Info.plist with the required permissions:
<key>NSCameraUsageDescription</key>
<string>This app needs camera access to stream video</string>
<key>NSMicrophoneUsageDescription</key>
<string>This app needs microphone access to stream audio</string>-
Build and run the project on a physical device (camera functionality requires a real device).
-
If you have a Cloud account, you can download the SDK from your Account > Plans section or from the following link
-
If you have a Red5 Pro Account, you can download the SDK from your Downloads section. Read this documentation guide
The testbed uses a settings manager to store and retrieve configuration values. All settings are persisted using UserDefaults.
The SettingsManager class handles all configuration:
class SettingsManager: ObservableObject {
static let shared = SettingsManager()
// Configuration properties
@Published var streamManagerHost: String
@Published var standaloneServerIp: String
@Published var appName: String
@Published var nodeGroup: String
@Published var streamName: String
@Published var userName: String
@Published var password: String
@Published var dtlsSetup: DTLSSetup
}| Parameter | Description | Default |
|---|---|---|
streamManagerHost |
Stream Manager host for Red5 Cloud | Empty |
standaloneServerIp |
IP address for standalone server | Empty |
appName |
Application name on Red5 server | "live" |
nodeGroup |
Node group for Stream Manager | "default" |
streamName |
Name of the stream to publish/subscribe | "myStream" |
userName |
Username for authentication (if enabled) | Empty |
password |
Password for authentication (if enabled) | Empty |
dtlsSetup |
DTLS setup mode (actpass/active/passive) | "actpass" |
The SettingsManager provides static getter methods:
let streamManagerHost = SettingsManager.getStreamManagerHost()
let appName = SettingsManager.getAppName()
let streamName = SettingsManager.getStreamName()
let userName = SettingsManager.getUserName()
let password = SettingsManager.getPassword()- Launch the app
- Navigate to the Settings screen
- Configure your connection parameters:
- For Red5 Cloud: Enter your Stream Manager host (e.g.,
userid-755-2ccfa36e4c.cloud.red5.net) - For Standalone: Enter your server IP address (e.g.,
192.168.1.100) - Set the app name (default: "live")
- Set the stream name
- Enter credentials if authentication is enabled
- Select DTLS setup mode
- For Red5 Cloud: Enter your Stream Manager host (e.g.,
- Tap "Save Settings" to persist your configuration
- Configure Stream Manager settings in the Settings screen
- Navigate to "Stream Manager Publish" or "Cloud Publish"
- Grant camera and microphone permissions when prompted
- The preview will start automatically after license validation
- Tap "Start Publish" to begin streaming
- Use controls to:
- Mute/unmute microphone
- Enable/disable camera
- Switch between front and back cameras
- Tap "Stop Publish" to end the stream
- Configure standalone server IP in the Settings screen
- Navigate to "Standalone Publish"
- Grant camera and microphone permissions when prompted
- The preview will start automatically after license validation
- Tap "Start Publish" to begin streaming
- Use the same controls as Cloud Publishing
- Tap "Stop Publish" to end the stream
- Ensure a stream is already publishing with the configured stream name
- Configure Stream Manager settings in the Settings screen
- Navigate to "Stream Manager Subscribe" or "Cloud Subscribe"
- Tap "Start Subscribe" to begin playback
- The remote stream will display once connected
- Tap "Stop Subscribe" to end playback
- Ensure a stream is already publishing with the configured stream name
- Configure standalone server IP in the Settings screen
- Navigate to "Standalone Subscribe"
- Tap "Start Subscribe" to begin playback
- The remote stream will display once connected
- Tap "Stop Subscribe" to end playback
A SwiftUI wrapper for the WebRTC video renderer:
struct WebRTCPreviewView: UIViewRepresentable {
let renderer: RTCMTLVideoView
func makeUIView(context: Context) -> RTCMTLVideoView {
renderer.contentMode = .scaleAspectFill
renderer.videoContentMode = .scaleAspectFill
return renderer
}
func updateUIView(_ uiView: RTCMTLVideoView, context: Context) {
// No updates needed - WebRTC handles everything
}
}Handles all publishing operations:
class PublishManager: NSObject, ObservableObject {
private var webrtcClient: Red5WebrtcClient?
@Published var localVideoRenderer: RTCMTLVideoView?
@Published var isReady: Bool = false
func setup() { /* ... */ }
func startPreview() { /* ... */ }
func startPublish() { /* ... */ }
func stopPublish() { /* ... */ }
func toggleCamera() { /* ... */ }
func toggleAudio() { /* ... */ }
func switchCamera() { /* ... */ }
}Manages persistent configuration:
class SettingsManager: ObservableObject {
static let shared = SettingsManager()
// Published properties for two-way binding
@Published var streamManagerHost: String
@Published var standaloneServerIp: String
@Published var appName: String
// ... more properties
func saveSettings() { /* ... */ }
}- Configure your server settings (Cloud or Standalone)
- Navigate to the appropriate publish screen
- Start publishing
- Verify the stream appears in your Red5Pro server console
- Use another device or web browser to subscribe and verify the stream
- Start a stream from another device or the Red5Pro web example
- Configure the testbed with the same server and stream name
- Navigate to the appropriate subscribe screen
- Start subscribing
- Verify the stream plays correctly
- Camera Switch: Verify switching between front and back cameras
- Mute/Unmute: Verify audio muting and unmuting
- Camera Toggle: Verify enabling and disabling video
- Connection States: Verify proper handling of connection, disconnection, and errors
Issue: Camera or microphone not working
Solution:
- Check that permissions are granted in Settings > Privacy > Camera/Microphone
- Verify Info.plist contains the usage descriptions
- Restart the app after granting permissions
Issue: Unable to connect to server
Solution:
- Verify Stream Manager host or server IP is correct
- Check that port 443 (HTTPS) or 5080 (HTTP) is accessible
- Ensure firewall settings allow WebRTC connections
- Verify authentication credentials if auth is enabled
- Check server logs for connection attempts
Issue: License check failed message
Solution:
- Verify you have a valid Red5Pro SDK license key
- Ensure the license key is properly configured in the SDK
- Check that your license is not expired
- Contact Red5Pro support for license issues
Issue: Camera preview doesn't appear
Solution:
- Verify camera permissions are granted
- Check that another app isn't using the camera
- Ensure the video renderer is properly initialized
- Check the console logs for error messages
Issue: Subscriber can't find the stream
Solution:
- Verify the stream name matches exactly
- Ensure the publisher is actively streaming
- Check that both publisher and subscriber use the same server/app name
- Verify the stream appears in the server console
Issue: Low quality or choppy video
Solution:
- Check network connectivity and bandwidth
- Adjust video bitrate in the configuration
- Lower video resolution if needed
- Ensure the device has sufficient processing power
Modify video settings in the PublishManager setup:
config.videoWidth = 1280 // Default: 640
config.videoHeight = 720 // Default: 480
config.videoFps = 30 // Default: 30
config.videoBitrate = 1500 // Default: 750 (kbps)Change DTLS setup mode in settings:
- Actpass (Recommended): Negotiates the role automatically
- Active: Forces the client to be the DTLS client
- Passive: Forces the client to be the DTLS server
Enable debug logging for troubleshooting:
// Enable in SettingsManager
config.enableDebug = true