Skip to main content
Starting with 3.0.0, the SDK has two layers: RTCEngineKit is a process-level singleton that handles initialization, shared hardware (camera, audio routing, screen capture), and creating channel instances; RTCEngineChannel is a channel instance that handles joining the channel, publishing, and subscribing to streams. A single process can create multiple channel instances and join multiple channels at the same time.

Step 1: Initialize the SDK

Create the initialization parameters

You must initialize the SDK before calling any other SDK function. To initialize the SDK, create an instance of the RTCEngineConfig object.
  • The following table describes all properties of the RTCEngineConfig object.

Initialize the RTC engine

After creating the RTCEngineConfig object, call the SDK’s initializeWithConfig function to set the delegate and verify that initialization succeeded.

Set the delegates

The SDK has two event protocols; implement each according to which events it owns:
  • RTCEngineDelegate: process-level events (audio route changes, network speed tests, app performance), passed in during initialization;
  • RTCEngineChannelDelegate: in-channel events (connection, users, messages, streams, screen sharing), passed in when you create a channel instance.

Implement the callbacks

The first parameter of every RTCEngineChannelDelegate callback is the channel instance the event comes from. In multi-channel scenarios, use it to tell which channel an event belongs to; the channel name is available from channel.channel.
  • Join succeeded callback
  • Local user data updated callback
  • Reconnecting callback
  • Reconnected callback
  • Disconnected callback
  • Custom message callback
  • Channel updated callback
  • User joined callback
  • User data updated callback
  • User left callback
  • User stream changed callback

Step 2: Create a channel instance and join the channel

Create a channel instance

To join multiple channels at the same time, call createChannelWithDelegate: multiple times and hold each instance separately. User data, stream statistics, and rendering don’t interfere across instances.

Join the channel

Leave the channel

Destroy the channel instance

You must destroy the instance when you’re done with it; otherwise the engine keeps holding the channel.

Step 3: Publish video

The camera is process-level shared hardware, so capture and preview are controlled through the RTCEngineKit singleton; whether that video is published to a given channel is controlled separately by that channel instance’s publishLocalVideo:.

Start the preview

Update the preview

Stop the preview

Resume/pause publishing to the current channel

Step 4: Subscribe to and unsubscribe from remote video

Subscribe to a remote user’s video

  • The following table describes all values of the RTCTrackIdentifierFlags track ID enum.

Update a remote user’s video

Unsubscribe from a remote user’s video

Unsubscribe from all video streams of a specific remote user

Step 5: Release resources

destroy first destroys all live channel instances and waits for them to finish leaving before releasing process-level resources, so you don’t need to call destroy on each channel instance yourself.