Skip to main content

Prerequisites

  • You have completed SDK integration
  • Your server can issue tokens for joining a channel
  • Your app has requested camera and microphone permissions
The token must be issued by your backend; the client isn’t involved in signing. For how to issue it, see Token and authentication.

Minimal runnable example

The example below covers the core path: initialize the SDK, join a channel, turn on the microphone and camera, subscribe to remote video, and leave the channel.

How the flow works

1. Initialize SRTCEngine

SRTCEngine is the main entry point of the SDK. It is responsible for:
  • Creating local tracks
  • Parsing the token and joining the channel
  • Managing the lifecycle of the current Channel
  • Configuring the log level and audio processors

2. Call joinChannel

The key idea: the core object in real-time audio and video isn’t a UI page but the connected channel state. That’s why joinChannel(...) returns a Channel object rather than a Boolean, and publishing, subscribing, messaging, and the user list all revolve around it.

3. Create and publish local tracks

Audio and video follow the same path:
  • create...Track(...) only creates the track object
  • startCapture() is what actually starts hardware capture
  • publishLocalTrack(...) is what sends the data to the channel
With these three steps separated, you get finer control over “when to acquire hardware resources” and “when to actually publish”.

4. Subscribe to remote video in the callback

When a remote user publishes, you’re notified through the didAddTrack callback of ChannelDelegate. Once you have the TrackInfo:
  • Call subscribeRemoteVideoTrack(uid:trackId:) to subscribe
  • Then get the track object with getRemoteTrack(uid:trackId:)
  • Pass the track to SRTCVideoView, VideoView, or SRTCVideoRenderer

Next steps