There are two layers of objects in the call sequence; tell them apart first:
- IRTCEngine—process-level; one is enough. It creates channels, enumerates devices, and handles IM and log upload
- IRTCChannel—one object per channel. User queries, tracks, publishing and subscribing, and local recording are all on it
Initialize the SDK
The log switch and log directory can only be set here; see RTCEngineOptions.
Set the engine-level event handler
This handler only receives callbacks that don’t belong to any channel: device changes, network probing, and IM.
For details, see IRTCEngineEvent. Channel-level callbacks are covered in the next step.
Join a channel
This takes two steps: createChannel only creates the object and doesn’t join; call join() after you’ve configured it.
The reason for two steps: onJoinChannel is called back before join() returns, so if you set the handler too late, you miss it.
For more settings, see IRTCChannelSetting; for channel-level callbacks, see IRTCChannelEvent.
Turn the camera on and off
The two publish overloads have no default argument, so you must pass opt explicitly. And you can’t write publish(tk, nullptr) directly—
the video and audio overloads would be ambiguous. Use a typed null pointer variable as shown above.
For more local camera methods, see IRTCLocalCameraTrack.
Turn the microphone on and off
For more local microphone methods, see IRTCLocalMicTrack.
Start and stop screen sharing
For more local screen sharing methods, see IRTCLocalScreenTrack.
Turn the speaker on and off
For more speaker methods, see IRTCRemoteAudioTrack.
Show and hide remote video
addPlayView takes an IRTCView*. For window rendering, you can use the ready-made
SRTC::RTCHwndView from the header directly; make sure its lifetime extends past removeAllPlayView.
Start and stop local recording
Each channel has only one recording object. The mid parameter is kept only for interface compatibility; pass an empty string.
For more local recording methods, see IRTCRecord.
Leave the channel
IRTCChannel itself has no leave(). To leave all channels at once, use _irtc->leaveAllChannel();
after that, every IRTCChannel* becomes invalid.