Skip to main content

Prerequisites

  • You have completed SDK integration
  • Your backend can issue the meeting token used to log in to the SDK
  • Your app has requested camera and microphone permissions
The meeting token is issued by your backend and delivered to the client; the SDK only uses it. Don’t assemble credentials on the client yourself.

Minimal runnable example

The example below covers the core flow: log in to the SDK, create an instant meeting, enter the meeting, turn local audio and video on or off, render local and remote video, and exit the meeting.

Walkthrough

1. Create SMeetingEngine

SMeetingEngine is the single entry point of the SDK, responsible for login, meeting management, entering and exiting meetings, media control, host operations, and event dispatch. Create only one instance per app and hold it globally; multiple instances make meeting state and media devices compete with each other.

2. Log in and register for events

delegates is a weak-reference multicast that supports multiple observers at once. Every method of SMeetingDelegate has a default empty implementation, so you only implement the events you care about. Remember to call meeting.delegates.remove(delegate:) before the object is released or before logging out.

3. Create a meeting or enter one directly

Before the meeting and in the meeting are two separate stages:
  • createRoom(_:) creates a meeting and returns (roomNo, meetingId)
  • enterRoom(_:) enters a meeting; in MeetingEnterReq, provide either meetingId or roomNo
If the meeting has already been created by someone else (or by your backend), skip createRoom and enter directly with the room number.

4. Turn on local audio and video

The method names include request because they cover two steps: “asking the meeting for permission to turn it on” and “starting and publishing the local stream.” When the host has turned on mute all or camera off for everyone and doesn’t allow members to turn them back on themselves, calls from non-hosts throw SMeetingError.unauthorized. In SwiftUI, requestOpenCamera doesn’t need a view; just pass meeting.cameraTrack to SRTCVideoView(track:) for rendering.

5. Render remote video

Use SMeetingRemoteVideoView for remote video. It subscribes by uid + TrackDesc when the view appears and unsubscribes when the view disappears, so you don’t need to manage the subscription lifecycle yourself. To render in UIKit / AppKit, or to control subscription timing yourself, see Video rendering (Chinese).

6. Exit

  • exitRoom() exits the current meeting without logging out
  • logout() logs out; if you’re still in a meeting, it exits the meeting first automatically

Next steps