Skip to main content
The C SDK does neither capture nor encoding. The complete publishing pipeline is: you capture → you encode → feed raw data with rtc_write_sample → the SDK packetizes and sends. Standard flow:

rtc_create_local_track

Creates a local track and returns the track handle; returns NULL on failure. Whether the track is audio or video is determined by the codec; you don’t need to specify it separately.

rtc_destroy_local_track

Destroys a local track. A published track should be unpublished with rtc_unpublish_local_track before it’s destroyed. Starting with 0.0.11, it first removes the keyframe request callback and waits for any running keyframe callback to return before returning; after that you can safely free the context passed to rtc_set_keyframe_request_callback. In 0.0.10 and earlier, the keyframe callback may still fire after the track is destroyed.

rtc_publish_local_track

Publishes a local track to the channel. Publish options rtc_publish_options_t
If props fails to parse, the SDK only logs a warning and continues publishing as if there were no custom properties; it doesn’t fail the publish.
Returns

rtc_unpublish_local_track

Unpublishes. Return values are the same as above.

rtc_publish_mcu_video_track / rtc_publish_mcu_audio_track

Publishes the channel-level composite stream; see Composite stream (program).

rtc_write_sample

Pushes one frame of encoded data to a published track. Compute samples from each codec’s clock rate: Returns
The SDK copies the data you pass in, so you can reuse or free the data buffer as soon as the call returns.
The SDK doesn’t control send pacing—each frame is sent as soon as it’s written. When your data source is faster than real time (reading a file, TTS synthesis), you must write at the pace of the frame duration (for example, one audio packet every 20 ms). Otherwise several seconds of data go out in an instant, the remote jitter buffer can’t hold it and drops some, and it sounds like swallowed words or sped-up audio.

rtc_write_sample_ts

New in 0.2.0. Does the same as rtc_write_sample, except that instead of a timestamp increment you pass the frame’s content time (when it was captured or composited). The SDK converts it to the RTP timestamp and generates RTCP SR from the content time. Suited to scenarios where audio and video are captured separately and encoding time varies (such as server-side compositing or transcoding): when the subscriber aligns audio and video using SR, it uses the content time rather than the send time, so jitter from encoding time and send queuing doesn’t affect A/V sync, and you don’t need to shape the send pacing yourself for that. Returns: same as rtc_write_sample; returns RTC_ERROR if rtc_write_sample and rtc_write_sample_ts are mixed on the same track.
  • One or the other per track: from the moment a track is published, write to it with only one of the two functions.
  • All tracks in the same process that call this function must use the same clock for audio and video to align. If the clock you pass differs from the monotonic clock above by more than 60 seconds, the SDK falls back to converting from the time the first frame was written: A/V alignment is unaffected, but the absolute SR time lags by the first-frame write delay.
  • Write each track from one thread, in increasing time order. A time that goes backwards, repeats, or jumps forward by more than 1 hour is treated as a clock anomaly: the RTP timestamp keeps increasing, and the conversion baseline is re-established from that frame. If you resume writing after a pause, the RTP timestamp advances by the real interval.
  • As with rtc_write_sample, the SDK doesn’t control send pacing—each frame is sent as soon as it’s written.

rtc_set_audio_level

New in 0.5.2. Sets the current level of a local audio track. Once set, every audio packet sent afterwards carries the level (RFC 6464 audio-level). The server uses it to determine who is speaking and sends the result to the other members of the channel (see rtc_set_active_speakers_callback), so the web client and others can show the active speaker. Without this call, other members of the channel never see this track as speaking. When you bring the audio of terminals or devices into a channel with the C SDK, call it once per frame. Return value: RTC_OK on success; RTC_INVALID_PARAM if the handle is invalid.
  • The SDK receives encoded data (such as Opus) and cannot compute the level itself; the caller must compute it from the PCM before encoding.
  • Call it once per frame (about 20 ms). It can run on a different thread from sample writing and does not block it.
  • Tracks that never call this function behave exactly as in 0.5.1 and earlier. Calling it on a video track has no effect.
  • Currently only the SeaStart engine uses it to send active speakers.

rtc_set_keyframe_request_callback

Sets the keyframe request callback. It fires when the SFU uses RTCP (PLI / FIR) to ask this track to produce a keyframe immediately; in the callback, have the encoder produce an IDR frame right away and send it with rtc_write_sample.
You must set it on the track before publishing. Without it, newly joined viewers don’t see video until the encoder’s next natural GOP—with a long GOP, that’s several seconds of black screen.The callback fires on a separate thread, so synchronize with your encoding thread. Pass NULL to clear the callback.

Complete example


The C interface doesn’t support publishing multi-layer simulcast streams—server-side scenarios (recording / MCU / AI agents) almost never need to publish multiple layers. Multi-layer switching on the subscriber side is done automatically by the SDK with no configuration. If you do need to publish multiple layers, contact us.