Skip to main content
This page walks through the minimal working flow of the Android SRTC SDK in this order: create the Engine → bind callbacks → join a channel → start capture and publish → subscribe to remote media → leave and release. Before you start, complete the following:
  • Configure the Maven repository, SDK dependency, and basic environment as described in Integration.
  • Prepare a channel token issued by your server.
  • Request camera and microphone runtime permissions in your app.
  • To manage output devices such as the speaker, earpiece, or Bluetooth headsets, see Audio routing (Chinese).
Use cn.seastart.rtc.media.original.render.VcsPlayerGlTextureView or VcsPlayerGlSurfaceView for preview and remote display views, with this package path in both code imports and XML layouts.

Step 1: Create and initialize RTCEngine

RTCEngine.create(...) requires an Engine-level error listener. It receives errors that don’t belong to any channel callback, as well as blocking errors such as calling a channel that hasn’t started; channelId is null when it can’t be determined.
For full parameter descriptions, see RTCEngine (Chinese) and RTCEngineEvent (Chinese).

Step 2: Prepare channel and media callbacks

Every join(...) call takes its own RTCClientEvent for that channel. If you only override a few events, extend RTCClientSimpleEvent instead of implementing the full interface.
Every channel-level callback explicitly carries channel. Even if a listener is bound to only one RTCChannel, use this parameter to keep logs and state separated. For more definitions, see RTCClientEvent (Chinese) and RTCMediaEvent (Chinese).

Step 3: Join a channel

join(...) synchronously returns RTCChannel?:
  • A non-null return only means the SDK accepted the request and created a channel handle, not that the join succeeded.
  • The actual result is reported by onJoinSucceed(...) or onJoinFailed(...).
  • If the SDK isn’t initialized or has been released, it synchronously throws SdkNotInitializedException.
The first join creates the default channel, and the flat APIs on RTCEngine—publish, subscribe, query, leave(), and so on—all act on it. The SDK also supports joining multiple channels at the same time; this quickstart covers only the single-channel flow. For details, see Multi-channel (Chinese).

Step 4: Start local capture and publish

Run the following publishing flow after onJoinSucceed(...). Capture and publishing are two separate actions: explicitly start local capture first, then publish the same local track to the channel. Unpublishing doesn’t automatically stop shared capture; when you no longer need the device, also call the track’s stopCapture().

4.1 Camera capture and publishing

For details, see LocalCameraTrack (Chinese).

4.2 Microphone capture and publishing

The microphone capture module is decoupled from joining and publishing. publishLocalAudio(...) no longer opens the microphone; you must call LocalMicTrack.startCapture(...) first.
Explicit capture also works outside a channel. Set setRtcLocalAudioFrameEvent(...) first, then call micTrack.startCapture(...) to receive local PCM data for recording or processing; registering the callback alone doesn’t open the microphone. See LocalMicTrack (Chinese) and RTCEngine (Chinese).

4.3 Screen sharing (optional)

For API details, see LocalScreenTrack (Chinese).

Step 5: Subscribe to and play remote media

After receiving onStreamTrackAdd(...), get the remote track from the default channel, bind a render view, then subscribe:
For details, see RemoteVideoTrack (Chinese).

Step 6: Leave the channel and release resources

releaseSDK() releases all channels and shared resources from the current initialization cycle; you can call initSDK() again afterward.

More capabilities

  • Joining multiple channels concurrently, per-channel publishing and subscription, and resource isolation: Multi-channel (Chinese)
  • Microphone input device enumeration, switching, and PCM callbacks: LocalMicTrack (Chinese)
  • Custom video publishing: Custom tracks (Chinese)
  • Whiteboard: Whiteboard
  • Audio output device management: Audio routing (Chinese)
  • Full SDK API: RTCEngine (Chinese)