MOQ Beta | Now Open For Developers / Learn More

Red5 Documentation

iOS SDK

The Red5 Pro iOS SDK (Red5WebRTCKit) enables native iOS applications to publish and subscribe to live streams over WebRTC with sub-second latency. Built on top of the WebRTC stack, the SDK handles ICE negotiation, codec selection, camera/microphone capture, and license validation — letting you focus on your application logic.

Requirements

  • iOS 16.0 or later
  • Xcode 15 or later
  • A valid Red5 Pro license key
  • A running Red5 Pro server (standalone or via Stream Manager)

Installation

Add the SDK to your project via Swift Package Manager by pointing at the Red5 Pro iOS SDK repository. Then import the framework where needed:

import Red5WebRTCKit

Core Concepts

Building a Client

Every session starts with Red5WebrtcClientBuilder. Chain the configuration setters and call .build():

let client = Red5WebrtcClientBuilder()
    .setServerIp("your-server-ip")
    .setPort(8554)
    .setAppName("live")
    .setStreamName("stream1")
    .setLicenseKey("XXXX-XXXX-XXXX-XXXX")
    .setVideoEnabled(true)
    .setAudioEnabled(true)
    .setEventListener(self)
    .build()

Event Delegate

Conform to Red5ProWebrtcEventDelegate to receive lifecycle callbacks:

Callback Fired when
onLicenseValidated(validated:message:) License check completes (always first)
onPreviewStarted() Local camera capture is running
onPublishStarted() Server confirmed publish session
onPublishStopped() Publish session ended cleanly
onSubscribeStarted() Incoming stream is being received
onSubscribeStopped() Subscribe session ended
onError(error:) Unrecoverable error occurred

Lifecycle Order — Publish

build() → onLicenseValidated → startPreview() → onPreviewStarted → publish() → onPublishStarted

Lifecycle Order — Subscribe

build() → subscribe() → onSubscribeStarted

Rendering Video

Attach an RTCMTLVideoView renderer before starting capture or subscribing:

let renderer = RTCMTLVideoView()
renderer.videoContentMode = .scaleAspectFill
client.setVideoRenderer(renderer)

Examples

Each example below is a self-contained iOS app that demonstrates one specific feature. Copy the two files (Config.swift + the example file) into a fresh Xcode project, edit Config.swift with your server details, and run.