Skip to main content
SRTCEngine is the main entry point of the Swift SDK. It’s responsible for joining channels, leaving channels, creating local tracks, and configuring logging and audio processors.

Initialization

init()

Creates an SDK instance and completes the underlying WebRTC initialization.

Properties

logLevel

Sets the SDK log level. Example:

audioCaptureProcessor

Audio processor applied after microphone capture, usable for voice changing, noise suppression, and similar processing.

audioRenderProcessor

Processor applied to remote audio before playback, usable for playback-side audio enhancement.

channels

The list of channels that have been joined and are still live ([Channel]), ordered by join time. An empty array means you’re not in any channel.

defaultChannel

The default channel (Channel?): the earliest-joined one that’s still live; once you leave it, the next one takes its place. The no-argument leaveChannel() applies to it. See Multi-channel for details.

Methods

joinChannel(token:options:)

Joins a channel and returns a Channel instance. You can call it multiple times to join several channels at once; each channel’s publishing, subscriptions, users, and events are independent of each other. It throws alreadyJoined only when the same channel name has already been joined (or a join is in progress).
Returns: Channel Throws:
  • SRTCError.alreadyJoined
  • SRTCError.tokenExpired
  • SRTCError.tokenInvalid
  • Other network, signaling, and media streaming connection errors

leaveChannel()

Leaves the default channel (the earliest-joined one that’s still live).
If no channel is currently joined, the call is safely ignored.

leaveChannel(_:)

Leaves the specified channel, equivalent to channel.leave(); other channels aren’t affected. With multiple channels we recommend this version, to avoid ambiguity from “the default channel moving to the next one”.

createLocalMicTrack(preset:)

Creates a local microphone track.
Returns: LocalMicTrack

createLocalCameraTrack(preset:)

Creates a local camera track.
Returns: LocalCameraTrack

createLocalScreenTrack(preset:audioPreset:mode:)

Creates a local screen-sharing track.
Returns: LocalScreenTrack
With iOS full-screen capture, a successful startCapture() only means the SDK has started listening; video is transmitted only after the user starts the broadcast from the system UI. The actual start / end is notified through TrackDelegate.screenBroadcastDidStart / screenBroadcastDidFinish(_:reason:).

createLocalScreenTrack(source:preset:audioPreset:excludedWindowIds:excludesCurrentApplication:)

Overload for macOS 12.3+ only, used to specify a display or window source.
Returns: LocalScreenTrack
Since 1.4.2, full-display sharing includes your own app’s windows by default. Put every window that renders this shared content into excludedWindowIds; otherwise you get an infinite mirror. The window list is snapshotted once at startCapture(), and windows opened afterward all appear in the capture.

createLocalCustomVideoTrack(desc:)

Creates a custom video track, for scenarios where frames are pushed from outside.
Returns: LocalVideoTrack After calling it, you can inject CVPixelBuffer values through pushFrame(...).

createLocalCustomAudioTrack(desc:)

Creates a custom audio track, for scenarios with external PCM input.
Returns: LocalAudioTrack After calling it, you can inject AVAudioPCMBuffer values through pushAudioBuffer(...).

Video preprocessing

defaultVideoProcessors

The default video processor pipeline. Configure it once here, and every camera track created afterward picks it up automatically.
A camera track is created anew every time the camera is turned on (turning the camera off destroys it), so if you set processors only on the track, the effect is gone the next time the camera is turned on—this property exists for exactly that reason. It affects only tracks created afterward and doesn’t apply retroactively to existing tracks; custom video tracks aren’t affected (frames on that path are pushed by you via pushFrame, so you decide whether they go through processors).

Virtual background

The following methods forward to SRTCVirtualBackground.shared, with a single process-wide state. Once enabled, it automatically applies to all camera tracks, and you don’t need to add anything to videoProcessors. For usage and tuning, see Virtual background. Throws: SRTCError.virtualBackgroundAlreadyInstalled, .virtualBackgroundNotInstalled, .virtualBackgroundModelNotFound(String), .virtualBackgroundSessionFailed(String) Background blur and background replacement are mutually exclusive, and the later call wins; both are also remembered if called before installing, and take effect automatically once installation completes.