C SDK instance lifecycle (rtc_create / rtc_destroy and when it is safe to free callback context), joining and leaving channels, rtc_get_last_error, auto-subscribe, log level and log upload, language, and every callback registration function with its threading rules.
This page covers creating and destroying SDK instances, joining and leaving channels, and every callback registration function.All functions are thread-safe.
Logging
rtc_set_log_level
void rtc_set_log_level(int level);
Sets the global log level. It applies to the whole process; we recommend calling it before rtc_create.
Parameter
Description
level
RTC_LOG_DEBUG(0) / RTC_LOG_INFO(1) / RTC_LOG_WARN(2) / RTC_LOG_ERROR(3); any other value is treated as INFO
It only affects local output (printed to stderr) and is independent of log upload below.
rtc_set_log_upload
void rtc_set_log_upload(int enable, int level);
Sets whether SDK logs are uploaded to the server (since 0.4.0). It applies to the whole process. Upload is on by default and covers RTC_LOG_INFO and above.When enabled, each time the instance joins a channel, the SDK uploads that channel’s logs (tagged with the channel name and uid) to the server-side log service in batches in the background. Technical support can then look them up by channel and user, so you no longer need to collect logs from the on-site server when troubleshooting. Failed uploads are discarded without retry and do not affect audio and video.
Parameter
Description
enable
Non-zero to upload, 0 to stop uploading
level
Upload level, same values as rtc_set_log_level; any other value is treated as INFO
The switch only applies to channels joined afterwards; the level takes effect immediately, including for instances already in a channel
If the deployment has no log service or it is unreachable, the SDK prints one upload-failure warning per minute locally; call rtc_set_log_upload(0, RTC_LOG_INFO) to turn upload off
Language
rtc_set_language
void rtc_set_language(const char* lang);
Sets the language (since 0.1.0). It applies to the whole process and can be called at any time; requests sent after the call use the new language.It determines the language of the reason text for server business errors (error code ≥1000), that is, what ends up in msg_buf when rtc_get_last_error returns a server error. Reasons for SDK errors (180xxx) are always in English and are not affected.
Parameter
Description
lang
Language tag, such as "en" or "zh-CN"; system locale forms like "zh_CN.UTF-8" are also accepted. Pass NULL or an empty string to go back to following the system language
When it isn’t called, the system language is used: the first non-empty value among the environment variables LC_ALL, LC_MESSAGES, and LANG. When the system language is C / POSIX or none of them is set, the server replies in Chinese.
rtc_set_language("en"); // server error reasons in English
Instance lifecycle
rtc_create
void* rtc_create();
Creates an SDK instance and returns the instance handle. Every channel-related function afterward takes this handle.One handle corresponds to one channel connection. To connect to multiple channels at the same time, create multiple instances.
rtc_destroy
void rtc_destroy(void* handle);
Destroys the instance and releases its resources. Starting with 0.0.11, rtc_destroy waits for all running callbacks to return before it returns. After it returns, no further callbacks fire for this instance, and you can safely free the context you passed to the callbacks.
You may call rtc_destroy from within one of this instance’s callbacks (including the disconnect callback). In that case it only waits for callbacks on other threads—don’t free the current callback’s context until that callback returns
If a callback does slow work (decoding, writing files), rtc_destroy waits correspondingly longer
Neither rtc_leave_channel nor replacing a callback with rtc_set_*_callback waits for running callbacks, so neither is a safe point to free context
0.0.10 and earlier don’t provide these guarantees: callbacks may still be running when rtc_destroy returns, and calling rtc_destroy from the disconnect callback deadlocks. With these older versions, don’t free context right after rtc_destroy, and don’t destroy the instance in the disconnect callback; we recommend upgrading to 0.0.11.
You must call rtc_destroy; otherwise the instance’s resources are not released. The handle can’t be used after it’s destroyed.
Joining and leaving a channel
rtc_join_channel
int rtc_join_channel(void* handle, const char* token);
Joins a channel asynchronously and returns immediately. The actual connection result is reported through the connection state callback (rtc_set_connection_callback).
The join request was initiated (doesn’t mean the connection succeeded)
RTC_INVALID_PARAM
Invalid handle, or the token is an empty string
rtc_join_channel_sync
int rtc_join_channel_sync(void* handle, const char* token, int timeout_ms);
Joins a channel synchronously, blocking until the connection succeeds, fails, or times out.
Parameter
Description
token
Channel join token issued by the server
timeout_ms
Timeout in milliseconds. On timeout, this join attempt is fully aborted, leaving no background tasks behind
Returns
Return value
Meaning
RTC_OK
Joined successfully
RTC_INVALID_PARAM
Invalid handle, or the token is an empty string
RTC_ERROR
Join failed (token invalid, session already taken, rejected by the server, etc.); get the specific reason with rtc_get_last_error
RTC_TIMEOUT
Didn’t complete before the timeout
rtc_get_last_error
int rtc_get_last_error(void* handle, char* msg_buf, int buf_len);
Gets the error details of this instance’s most recent failed call (since 0.0.9). Call it after join, subscribe, publish, or similar functions return anything other than RTC_OK. Since 0.1.0, returning RTC_INVALID_PARAM / RTC_NOT_CONNECTED also records an error (180031 / 180001).
Parameter
Description
msg_buf / buf_len
Optional. If provided, the error reason is written into it (truncated if too long, always \0-terminated); pass NULL, 0 if you don’t need the reason
Returns: The error code; 0 means nothing was recorded.
Value
Description
180xxx
SDK error. The last three digits are the error code shared by all SDKs (such as 180031 invalid argument); see Error codes. The reason is in English
≥1000 (such as 1033)
Server business error code, passed through as-is. The language of the reason text is set by rtc_set_language
-1
Internal error with no specific code; should not occur normally
If the handle itself is invalid there is no instance to record on, so 0 is returned; functions that take only a track handle, such as rtc_write_sample, don’t record errors.
if (rtc_join_channel_sync(rtc, token, 10000) != RTC_OK) { char msg[256]; int code = rtc_get_last_error(rtc, msg, sizeof(msg)); fprintf(stderr, "join failed: %d %s\n", code, msg); // e.g. 1033 concurrency limit reached}
Each instance keeps only the most recent error. When multiple threads call functions on the same instance concurrently, a later failure overwrites an earlier one.
rtc_leave_channel
int rtc_leave_channel(void* handle);
Leaves the channel. The instance stays valid after leaving and can join again. When you’re done with it for good, you still need to call rtc_destroy.Returns:RTC_OK / RTC_INVALID_PARAM (invalid handle).
Auto-subscribe
rtc_set_auto_subscribe
void rtc_set_auto_subscribe(void* handle, int auto_audio, int auto_video);
Sets whether to automatically subscribe to remote tracks. When on, every already-published and newly published track of the corresponding type in the channel is subscribed automatically, and all data goes through the track data callback.
Parameter
Description
auto_audio
1 = auto-subscribe to all audio, 0 = don’t
auto_video
1 = auto-subscribe to all video, 0 = don’t
Must be called before joining the channel. Setting it after joining has no effect on existing tracks.
If a user wants to “hear everyone,” the right approach is rtc_set_auto_subscribe(rtc, 1, 0) to subscribe to everyone’s audio and then mix it yourself. Don’t subscribe to the audio composite stream—it includes your own voice and causes echo.
Device type
rtc_set_device_type
void rtc_set_device_type(void* handle, int device_type);
Sets the device type this instance reports when it joins a channel (since 0.3.0). This is the value other members see in rtc_user_info_t.device_type and the device_type in server callbacks. Defaults to 80 (agent joining on the server side) if not called.
Parameter
Description
device_type
Device type number; see the device_type description in the Callback events guide. <= 0 restores the default 80
Must be called beforertc_join_channel / rtc_join_channel_sync. The device type is reported only once, at join time; setting it after joining has no effect on the current session (automatic reconnection keeps the same session, so it doesn’t change either). To change the type, leave and join again.
It applies per instance: multiple instances in the same process can each set their own. For example, a device gateway that creates one instance per connected device can report each device’s kind (82 for SIP devices, 83 for H.323 devices, 84 for GB28181 cameras, and so on), so your application can tell where each member comes from.
Callback registration
Every callback carries your context through the context parameter; the SDK passes it back unchanged without interpreting it.
context must be a real pointer (or NULL). Don’t cast small integers like 1 or 2 to pointers to use as IDs: the SDK stores it internally as a pointer, and a value below 4096 is treated as an invalid pointer and terminates the process immediately. If you need an ID, pass the address of memory that holds it.
Callbacks run on internal SDK threads. Keep three things in mind:
User, track, channel, custom message, reconnection (connection state 3 / 1) and SFU signaling (layer switch, network quality, active speakers) callbacks fire one at a time in the order the events happen and never run concurrently with each other (since 0.1.1). Media sample callbacks (one thread per track), keyframe request callbacks and disconnection callbacks (rtc_set_disconnected_callback and connection state 2) can run concurrently with them, so protect shared state yourself
Don’t do slow work in callbacks: event callbacks fire one at a time, so a blocked callback delays every event after it; queue slow processing and hand it to your own threads
Pointers in callback parameters (uid, track_info, data, props, content_json, speakers, etc.) are only valid during the callback; if you need to keep them (including handing them to another thread for async processing), copy them before the callback returns
Connection state changes. state: 0=connecting, 1=connected, 2=disconnected, 3=reconnecting.
rtc_set_disconnected_callback
typedef void (*rtc_disconnected_callback)(void* context, int reason, int code, const char* msg);void rtc_set_disconnected_callback(void* handle, rtc_disconnected_callback callback, void* context);
Fires once when the instance finally leaves the channel (at the same moment as state=2 in the connection state callback, and before it), with the disconnect reason (since 0.0.9).
The error code if there was an error (180xxx or a server 1xxx; see Error codes), otherwise 0
msg
The error reason; NULL if there was no error. Only valid during the callback
Use it to decide whether to rejoin automatically: don’t rejoin automatically when removed from the channel (KICKED), replaced by another session with the same uid (REPLACE), or when the channel is destroyed (DESTROY); in cases such as a heartbeat timeout (TIMEOUT), you can rejoin with a newly issued token.
Remote tracks added, updated, or removed. event_type: 0=added, 1=updated, 2=removed. With manual subscription, use this callback to discover tracks you can subscribe to.
Media data for subscribed tracks. Every subscribed track (including composite streams) comes out of this single callback; use user_info->uid + track_info->track_id to tell the sources apart.data is a complete encoded frame (one frame for video, one encoded packet for audio). The pointer is only valid during the callback:
uint8_t* saved = malloc(len);memcpy(saved, data, len); // Copy it if you need to keep it
The following three callbacks only fire when the channel uses the SeaStart engine; with other engines they’re never called. See SeaStart advanced features.
rtc_set_log_level(RTC_LOG_INFO);void* rtc = rtc_create();// 1) Register callbacks firstrtc_set_connection_callback(rtc, on_conn, ctx);rtc_set_user_event_callback(rtc, on_user, ctx);rtc_set_track_event_callback(rtc, on_track, ctx);rtc_set_track_sample_callback(rtc, on_sample, ctx);// 2) Then configure auto-subscribertc_set_auto_subscribe(rtc, 1, 1);// (Optional) set the device type reported at join; defaults to 80 if not called// rtc_set_device_type(rtc, 82);// 3) Finally join the channelrtc_join_channel_sync(rtc, token, 10000);// ... application runs ...rtc_leave_channel(rtc);rtc_destroy(rtc);
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"STMLink Docs","description":"STMLink 开发者文档:SRTC 音视频 SDK(频道通信、云录制与直播、语音录制、语音识别)与 SMeeting 会议 SDK(房间、会议管理),覆盖 iOS / Android / Windows / Web / 微信小程序 / C(服务端·嵌入式)多端接入与服务端 API。 STMLink developer docs: the SRTC audio/video SDK (channels, cloud recording and live streaming, voice recording, speech recognition) and the SMeeting conferencing SDK (rooms and meetings), covering client integration on iOS, Android, Windows, Web, WeChat Mini Programs and C (server/embedded), plus the Server API.","colors":{"primary":"#0066FF","light":"#3385FF","dark":"#0052CC"},"logo":{"light":"https://mintcdn.com/freewind/-N23X1jpF3KMqIP_/logo/light.svg?fit=max\u0026auto=format\u0026n=-N23X1jpF3KMqIP_\u0026q=85\u0026s=c87be878176892b493466cf0647c68cc","dark":"https://mintcdn.com/freewind/-N23X1jpF3KMqIP_/logo/dark.svg?fit=max\u0026auto=format\u0026n=-N23X1jpF3KMqIP_\u0026q=85\u0026s=d6697b8422020261e5703917bcf26a6b"},"favicon":"https://mintcdn.com/freewind/-N23X1jpF3KMqIP_/favicon.svg?fit=max\u0026auto=format\u0026n=-N23X1jpF3KMqIP_\u0026q=85\u0026s=dcf59f85b4c1c24462b5f99c37ff73d4","footer":{"socials":{"website":"https://www.stmlink.com"},"links":[{"header":"产品","items":[{"label":"官网","href":"https://www.stmlink.com"},{"label":"SRTC 音视频 SDK","href":"https://docs.stmlink.com/zh/rtc/overview"},{"label":"SMeeting 会议 SDK","href":"https://docs.stmlink.com/zh/meeting/overview"}]},{"header":"支持","items":[{"label":"联系我们","href":"https://www.stmlink.com"}]}]},"contextual":{"options":["copy","view","chatgpt","claude"],"display":"header"},"markdown":{"instructions":["对外开放的服务端接口有两组前缀,都用同一套鉴权:`/server/v1/...`(SRTC 与 SMeeting 的主接口)和 `/stm/srvapi/v1/...`(SMeeting 的用户体系,服务端极简对接会用到)。鉴权是 app_id + nonce + timestamp + signature 四个请求头,用 app_key 做 HMAC-SHA256 签名,只能从业务方自己的后端调用。除这两组前缀外的接口均为内部接口,不要建议客户调用。 Public server APIs use two path prefixes with the same authentication: `/server/v1/...` (the main APIs of both SRTC and SMeeting) and `/stm/srvapi/v1/...` (the SMeeting user system, used by server-side low-code integration). Authenticate with four request headers, app_id + nonce + timestamp + signature, where signature is HMAC-SHA256 keyed with app_key; call these APIs only from the customer's own backend. Any other path is internal: never suggest calling it.","app_key 是服务端密钥,绝不能出现在客户端代码、前端配置或移动 App 里。客户端加入频道用的 token 必须由业务方后端签发后下发(SRTC 走 `/server/v1/channel/grant`,SMeeting 走 `/stm/srvapi/v1/member/grant`)。 app_key is a server-side secret and must never appear in client code, frontend config, or a mobile app. The token a client uses to join must be issued by the customer's backend and passed down to the client (SRTC: `/server/v1/channel/grant`; SMeeting: `/stm/srvapi/v1/member/grant`).","SRTC 与 SMeeting 是上下两层不同的产品,术语不通用:SRTC 是音视频底座,说「频道 channel」「加入 / 退出」;SMeeting 建在 SRTC 之上,说「房间 room」「会议 meeting」「进入 / 退出」。回答时按用户所在的层用对应术语,不要把「房间」「会议」安到 SRTC 的接口上,也不要用「频道」「加入 / 离开」描述 SMeeting 的概念(接口标识符原样保留)。 SRTC and SMeeting are two separate layers with different terminology. SRTC is the audio/video foundation: it has channels, and users join and leave a channel. SMeeting is built on top of SRTC: it has rooms and meetings, and members enter and exit a meeting. Answer in the terms of the layer the user is working with: never apply \"room\" or \"meeting\" to SRTC APIs, and never describe SMeeting concepts in prose with \"channel\", \"join\", or \"leave\" (API identifiers such as `force_join` keep their literal names).","同一能力在各端 SDK 里的包名、类名、方法名并不相同。写示例代码时请使用文档中该端自己的 API,不要把一个端的写法套到另一个端上。苹果平台每个产品都有两套 SDK(Swift 原生与 Objective-C),两套 API 不能混用。 Package, class, and method names differ between platform SDKs for the same capability. In sample code, use the API documented for that platform; never carry one platform's code over to another. On Apple platforms each product ships two SDKs (native Swift and Objective-C) whose APIs must not be mixed."]},"styling":{"latex":false},"navigation":{"languages":[{"language":"zh","href":"zh/rtc/overview"},{"language":"en","footer":{"socials":{"website":"https://www.stmlink.com/en"},"links":[{"header":"Products","items":[{"label":"Website","href":"https://www.stmlink.com/en"},{"label":"SRTC Audio \u0026 Video SDK","href":"https://docs.stmlink.com/en/rtc/overview"},{"label":"SMeeting Conferencing SDK","href":"https://docs.stmlink.com/en/meeting/overview"}]},{"header":"Support","items":[{"label":"Contact us","href":"https://www.stmlink.com/en"}]}]},"href":"en/rtc/overview"}]}},"deployment":{"deploymentMetadataValue":{"subdomain":"freewind","hasAudioNarration":false,"actualSubdomain":"freewind","customDomains":["docs.stmlink.com"],"gitSource":{"type":"github","owner":"seastart","repo":"stmlink-docs","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":"","_id":"6b10d74a9ffae5051c40d9df"},"entitlements":{},"buildId":"6b1126a7c2332a331c7a888e","clientVersion":"0.0.4428","searchFilterCounts":[{"language":"zh","tag":"SRTC 音视频 SDK","count":175},{"language":"en","tag":"SRTC Audio \u0026 Video SDK","count":160},{"language":"zh","tag":"SMeeting 会议 SDK","count":154},{"language":"en","tag":"SMeeting Conferencing SDK","count":127},{"language":"zh","tag":"接口文档","count":110},{"language":"en","tag":"API reference","count":108},{"language":"zh","tag":"进阶实践","count":78},{"language":"en","tag":"Android SDK","count":66},{"language":"zh","tag":"Android SDK","count":66},{"language":"en","tag":"Advanced","count":57},{"language":"en","tag":"Swift SDK (iOS/macOS)","count":47},{"language":"zh","tag":"Swift SDK(iOS/macOS)","count":47},{"language":"zh","tag":"HarmonyOS SDK","count":42},{"language":"en","tag":"Windows SDK","count":41},{"language":"zh","tag":"Windows SDK","count":41},{"language":"en","tag":"Web SDK","count":33},{"language":"zh","tag":"Web SDK","count":33},{"language":"en","tag":"Server API","count":32},{"language":"zh","tag":"服务端 API","count":32},{"language":"en","tag":"iOS SDK (Objective-C)","count":27}]},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableContextualStarterQuestions":false,"enableAskAiSearchBar":true},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"starter-pricing","enabled":true,"variant":{"name":"treatment","enabled":true,"payload":{"type":"string","value":"treatment"},"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"auth-vite-origin","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"starterQuestions":[],"googleFontsInlined":false},"customCss":[]}
{"page":{"pagePath":"en/rtc/capi/api-reference/engine","slug":"/en/rtc/capi/api-reference/engine","pageMetadata":{"title":"Instance and channel","description":"C SDK instance lifecycle (rtc_create / rtc_destroy and when it is safe to free callback context), joining and leaving channels, rtc_get_last_error, auto-subscribe, log level and log upload, language, and every callback registration function with its threading rules.","href":"/en/rtc/capi/api-reference/engine"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"C SDK instance lifecycle (rtc_create / rtc_destroy and when it is safe to free callback context), joining and leaving channels, rtc_get_last_error, auto-subscribe, log level and log upload, language, and every callback registration function with its threading rules.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,hr:`hr`,li:`li`,ol:`ol`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,tbody:`tbody`,td:`td`,th:`th`,thead:`thead`,tr:`tr`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Note,Table,Tip,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Note)_missingMdxReference(`Note`,true);if(!Table)_missingMdxReference(`Table`,true);if(!Tip)_missingMdxReference(`Tip`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsx(_components.p,{children:`This page covers creating and destroying SDK instances, joining and leaving channels, and every callback registration function.`}),`\n`,_jsx(_components.p,{children:`All functions are thread-safe.`}),`\n`,_jsx(_components.hr,{}),`\n`,_jsx(Heading,{level:`2`,id:`logging`,children:`Logging`}),`\n`,_jsx(Heading,{level:`3`,id:`rtc_set_log_level`,children:`rtc_set_log_level`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`c`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`c`,children:_jsxs(_components.code,{language:`c`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` rtc_set_log_level`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`int`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` level`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Sets the global log level. It applies to the whole process; we recommend calling it before `,_jsx(_components.code,{children:`rtc_create`}),`.`]}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsx(_components.tbody,{children:_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`level`})}),_jsxs(_components.td,{children:[_jsx(_components.code,{children:`RTC_LOG_DEBUG`}),`(0) / `,_jsx(_components.code,{children:`RTC_LOG_INFO`}),`(1) / `,_jsx(_components.code,{children:`RTC_LOG_WARN`}),`(2) / `,_jsx(_components.code,{children:`RTC_LOG_ERROR`}),`(3); any other value is treated as `,_jsx(_components.code,{children:`INFO`})]})]})})]}),`\n`,_jsx(_components.p,{children:`It only affects local output (printed to stderr) and is independent of log upload below.`}),`\n`,_jsx(Heading,{level:`3`,id:`rtc_set_log_upload`,children:`rtc_set_log_upload`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`c`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`c`,children:_jsxs(_components.code,{language:`c`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` rtc_set_log_upload`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`int`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` enable`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`int`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` level`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Sets whether SDK logs are uploaded to the server (since 0.4.0). It applies to the whole process. Upload is on by default and covers `,_jsx(_components.code,{children:`RTC_LOG_INFO`}),` and above.`]}),`\n`,_jsx(_components.p,{children:`When enabled, each time the instance joins a channel, the SDK uploads that channel’s logs (tagged with the channel name and uid) to the server-side log service in batches in the background. Technical support can then look them up by channel and user, so you no longer need to collect logs from the on-site server when troubleshooting. Failed uploads are discarded without retry and do not affect audio and video.`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`enable`})}),_jsx(_components.td,{children:`Non-zero to upload, 0 to stop uploading`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`level`})}),_jsxs(_components.td,{children:[`Upload level, same values as `,_jsx(_components.code,{children:`rtc_set_log_level`}),`; any other value is treated as `,_jsx(_components.code,{children:`INFO`})]})]})]})]}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:`The switch only applies to channels joined afterwards; the level takes effect immediately, including for instances already in a channel`}),`\n`,_jsxs(_components.li,{children:[`If the deployment has no log service or it is unreachable, the SDK prints one upload-failure warning per minute locally; call `,_jsx(_components.code,{children:`rtc_set_log_upload(0, RTC_LOG_INFO)`}),` to turn upload off`]}),`\n`]}),`\n`,_jsx(_components.hr,{}),`\n`,_jsx(Heading,{level:`2`,id:`language`,children:`Language`}),`\n`,_jsx(Heading,{level:`3`,id:`rtc_set_language`,children:`rtc_set_language`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`c`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`c`,children:_jsxs(_components.code,{language:`c`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` rtc_set_language`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` char`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` lang`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`Sets the language (since 0.1.0). It applies to the whole process and can be called at any time; requests sent after the call use the new language.`}),`\n`,_jsxs(_components.p,{children:[`It determines the language of the reason text for `,_jsx(_components.strong,{children:`server business errors`}),` (error code ≥1000), that is, what ends up in `,_jsx(_components.code,{children:`msg_buf`}),` when `,_jsx(_components.code,{children:`rtc_get_last_error`}),` returns a server error. Reasons for SDK errors (`,_jsx(_components.code,{children:`180xxx`}),`) are always in English and are not affected.`]}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsx(_components.tbody,{children:_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`lang`})}),_jsxs(_components.td,{children:[`Language tag, such as `,_jsx(_components.code,{children:`\"en\"`}),` or `,_jsx(_components.code,{children:`\"zh-CN\"`}),`; system locale forms like `,_jsx(_components.code,{children:`\"zh_CN.UTF-8\"`}),` are also accepted. Pass `,_jsx(_components.code,{children:`NULL`}),` or an empty string to go back to following the system language`]})]})})]}),`\n`,_jsxs(_components.p,{children:[`When it isn’t called, the system language is used: the first non-empty value among the environment variables `,_jsx(_components.code,{children:`LC_ALL`}),`, `,_jsx(_components.code,{children:`LC_MESSAGES`}),`, and `,_jsx(_components.code,{children:`LANG`}),`. When the system language is `,_jsx(_components.code,{children:`C`}),` / `,_jsx(_components.code,{children:`POSIX`}),` or none of them is set, the server replies in Chinese.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`c`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`c`,children:_jsxs(_components.code,{language:`c`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`rtc_set_language`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"en\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // server error reasons in English`})]}),`\n`]})})}),`\n`,_jsx(_components.hr,{}),`\n`,_jsx(Heading,{level:`2`,id:`instance-lifecycle`,children:`Instance lifecycle`}),`\n`,_jsx(Heading,{level:`3`,id:`rtc_create`,children:`rtc_create`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`c`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`c`,children:_jsxs(_components.code,{language:`c`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` rtc_create`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`Creates an SDK instance and returns the instance handle. Every channel-related function afterward takes this handle.`}),`\n`,_jsx(_components.p,{children:`One handle corresponds to one channel connection. To connect to multiple channels at the same time, create multiple instances.`}),`\n`,_jsx(Heading,{level:`3`,id:`rtc_destroy`,children:`rtc_destroy`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`c`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`c`,children:_jsxs(_components.code,{language:`c`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` rtc_destroy`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` handle`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Destroys the instance and releases its resources. `,_jsx(_components.strong,{children:`Starting with 0.0.11`}),`, `,_jsx(_components.code,{children:`rtc_destroy`}),` waits for all running callbacks to return before it returns. After it returns, no further callbacks fire for this instance, and you can safely free the `,_jsx(_components.code,{children:`context`}),` you passed to the callbacks.`]}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`You may call `,_jsx(_components.code,{children:`rtc_destroy`}),` from within one of this instance’s callbacks (including the disconnect callback). In that case it only waits for callbacks on other threads—`,_jsxs(_components.strong,{children:[`don’t free the current callback’s `,_jsx(_components.code,{children:`context`}),` until that callback returns`]})]}),`\n`,_jsxs(_components.li,{children:[`If a callback does slow work (decoding, writing files), `,_jsx(_components.code,{children:`rtc_destroy`}),` waits correspondingly longer`]}),`\n`,_jsxs(_components.li,{children:[`Neither `,_jsx(_components.code,{children:`rtc_leave_channel`}),` nor replacing a callback with `,_jsx(_components.code,{children:`rtc_set_*_callback`}),` waits for running callbacks, so neither is a safe point to free `,_jsx(_components.code,{children:`context`})]}),`\n`]}),`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`0.0.10 and earlier don’t provide these guarantees`}),`: callbacks may still be running when `,_jsx(_components.code,{children:`rtc_destroy`}),` returns, and calling `,_jsx(_components.code,{children:`rtc_destroy`}),` from the disconnect callback deadlocks. With these older versions, don’t free `,_jsx(_components.code,{children:`context`}),` right after `,_jsx(_components.code,{children:`rtc_destroy`}),`, and don’t destroy the instance in the disconnect callback; we recommend upgrading to 0.0.11.`]})}),`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[`You must call `,_jsx(_components.code,{children:`rtc_destroy`}),`; otherwise the instance’s resources are not released. The handle can’t be used after it’s destroyed.`]})}),`\n`,_jsx(_components.hr,{}),`\n`,_jsx(Heading,{level:`2`,id:`joining-and-leaving-a-channel`,children:`Joining and leaving a channel`}),`\n`,_jsx(Heading,{level:`3`,id:`rtc_join_channel`,children:`rtc_join_channel`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`c`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`c`,children:_jsxs(_components.code,{language:`c`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`int`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` rtc_join_channel`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` handle`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` char`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` token`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Joins a channel asynchronously and returns immediately. The actual connection result is reported through the connection state callback (`,_jsx(_components.code,{children:`rtc_set_connection_callback`}),`).`]}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsx(_components.tbody,{children:_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`token`})}),_jsxs(_components.td,{children:[`Channel join token issued by the server; see `,_jsx(_components.a,{href:`/en/rtc/server-api/channel`,children:`Server API · Get a channel join token`})]})]})})]}),`\n`,_jsx(_components.p,{children:_jsx(_components.strong,{children:`Returns`})}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Return value`}),_jsx(_components.th,{children:`Meaning`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`RTC_OK`})}),_jsx(_components.td,{children:`The join request was initiated (doesn’t mean the connection succeeded)`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`RTC_INVALID_PARAM`})}),_jsx(_components.td,{children:`Invalid handle, or the token is an empty string`})]})]})]}),`\n`,_jsx(Heading,{level:`3`,id:`rtc_join_channel_sync`,children:`rtc_join_channel_sync`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`c`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`c`,children:_jsxs(_components.code,{language:`c`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`int`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` rtc_join_channel_sync`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` handle`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` char`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` token`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`int`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` timeout_ms`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`Joins a channel synchronously, blocking until the connection succeeds, fails, or times out.`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`token`})}),_jsx(_components.td,{children:`Channel join token issued by the server`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`timeout_ms`})}),_jsx(_components.td,{children:`Timeout in milliseconds. On timeout, this join attempt is fully aborted, leaving no background tasks behind`})]})]})]}),`\n`,_jsx(_components.p,{children:_jsx(_components.strong,{children:`Returns`})}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Return value`}),_jsx(_components.th,{children:`Meaning`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`RTC_OK`})}),_jsx(_components.td,{children:`Joined successfully`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`RTC_INVALID_PARAM`})}),_jsx(_components.td,{children:`Invalid handle, or the token is an empty string`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`RTC_ERROR`})}),_jsxs(_components.td,{children:[`Join failed (token invalid, session already taken, rejected by the server, etc.); get the specific reason with `,_jsx(_components.code,{children:`rtc_get_last_error`})]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`RTC_TIMEOUT`})}),_jsx(_components.td,{children:`Didn’t complete before the timeout`})]})]})]}),`\n`,_jsx(Heading,{level:`3`,id:`rtc_get_last_error`,children:`rtc_get_last_error`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`c`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`c`,children:_jsxs(_components.code,{language:`c`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`int`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` rtc_get_last_error`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` handle`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`char`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` msg_buf`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`int`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` buf_len`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Gets the error details of this instance’s `,_jsx(_components.strong,{children:`most recent failed call`}),` (since 0.0.9). Call it after join, subscribe, publish, or similar functions return anything other than `,_jsx(_components.code,{children:`RTC_OK`}),`. Since 0.1.0, returning `,_jsx(_components.code,{children:`RTC_INVALID_PARAM`}),` / `,_jsx(_components.code,{children:`RTC_NOT_CONNECTED`}),` also records an error (`,_jsx(_components.code,{children:`180031`}),` / `,_jsx(_components.code,{children:`180001`}),`).`]}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsx(_components.tbody,{children:_jsxs(_components.tr,{children:[_jsxs(_components.td,{children:[_jsx(_components.code,{children:`msg_buf`}),` / `,_jsx(_components.code,{children:`buf_len`})]}),_jsxs(_components.td,{children:[`Optional. If provided, the error reason is written into it (truncated if too long, always `,_jsx(_components.code,{children:`\\\\0`}),`-terminated); pass `,_jsx(_components.code,{children:`NULL, 0`}),` if you don’t need the reason`]})]})})]}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Returns:`}),` The error code; `,_jsx(_components.code,{children:`0`}),` means nothing was recorded.`]}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Value`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`180xxx`})}),_jsxs(_components.td,{children:[`SDK error. The last three digits are the error code shared by all SDKs (such as `,_jsx(_components.code,{children:`180031`}),` invalid argument); see `,_jsx(_components.a,{href:`/en/rtc/capi/error-codes`,children:`Error codes`}),`. The reason is in English`]})]}),_jsxs(_components.tr,{children:[_jsxs(_components.td,{children:[_jsx(_components.code,{children:`≥1000`}),` (such as `,_jsx(_components.code,{children:`1033`}),`)`]}),_jsxs(_components.td,{children:[`Server business error code, passed through as-is. The language of the reason text is set by `,_jsx(_components.a,{href:`#rtc_set_language`,children:_jsx(_components.code,{children:`rtc_set_language`})})]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{\"data-numeric\":`true`,children:_jsx(_components.code,{children:`-1`})}),_jsx(_components.td,{children:`Internal error with no specific code; should not occur normally`})]})]})]}),`\n`,_jsxs(_components.p,{children:[`If the handle itself is invalid there is no instance to record on, so `,_jsx(_components.code,{children:`0`}),` is returned; functions that take only a track handle, such as `,_jsx(_components.code,{children:`rtc_write_sample`}),`, don’t record errors.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`c`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`c`,children:_jsxs(_components.code,{language:`c`,numberOfLines:`5`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`rtc_join_channel_sync`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(rtc, token, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`10000`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`!=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` RTC_OK) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` char`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` msg`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`256`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`];`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` int`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` code `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` rtc_get_last_error`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(rtc, msg, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`sizeof`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(msg));`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` fprintf`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(stderr, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"join failed: `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#9CDCFE`},children:`%d`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#9CDCFE`},children:` %s`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\n`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, code, msg);`}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // e.g. 1033 concurrency limit reached`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsx(Note,{children:_jsx(_components.p,{children:`Each instance keeps only the most recent error. When multiple threads call functions on the same instance concurrently, a later failure overwrites an earlier one.`})}),`\n`,_jsx(Heading,{level:`3`,id:`rtc_leave_channel`,children:`rtc_leave_channel`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`c`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`c`,children:_jsxs(_components.code,{language:`c`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`int`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` rtc_leave_channel`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` handle`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Leaves the channel. The instance stays valid after leaving and can join again. When you’re done with it for good, you still need to call `,_jsx(_components.code,{children:`rtc_destroy`}),`.`]}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Returns:`}),` `,_jsx(_components.code,{children:`RTC_OK`}),` / `,_jsx(_components.code,{children:`RTC_INVALID_PARAM`}),` (invalid handle).`]}),`\n`,_jsx(_components.hr,{}),`\n`,_jsx(Heading,{level:`2`,id:`auto-subscribe`,children:`Auto-subscribe`}),`\n`,_jsx(Heading,{level:`3`,id:`rtc_set_auto_subscribe`,children:`rtc_set_auto_subscribe`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`c`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`c`,children:_jsxs(_components.code,{language:`c`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` rtc_set_auto_subscribe`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` handle`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`int`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` auto_audio`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`int`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` auto_video`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`Sets whether to automatically subscribe to remote tracks. When on, every already-published and newly published track of the corresponding type in the channel is subscribed automatically, and all data goes through the track data callback.`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`auto_audio`})}),_jsx(_components.td,{children:`1 = auto-subscribe to all audio, 0 = don’t`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`auto_video`})}),_jsx(_components.td,{children:`1 = auto-subscribe to all video, 0 = don’t`})]})]})]}),`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[`Must be called `,_jsx(_components.strong,{children:`before`}),` joining the channel. Setting it after joining has no effect on existing tracks.`]})}),`\n`,_jsx(Tip,{children:_jsxs(_components.p,{children:[`If a user wants to “hear everyone,” the right approach is `,_jsx(_components.code,{children:`rtc_set_auto_subscribe(rtc, 1, 0)`}),` to subscribe to everyone’s audio and then mix it yourself. `,_jsx(_components.strong,{children:`Don’t`}),` subscribe to the audio composite stream—it includes your own voice and causes echo.`]})}),`\n`,_jsx(_components.hr,{}),`\n`,_jsx(Heading,{level:`2`,id:`device-type`,children:`Device type`}),`\n`,_jsx(Heading,{level:`3`,id:`rtc_set_device_type`,children:`rtc_set_device_type`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`c`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`c`,children:_jsxs(_components.code,{language:`c`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` rtc_set_device_type`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` handle`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`int`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` device_type`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Sets the device type this instance reports when it joins a channel (since 0.3.0). This is the value other members see in `,_jsx(_components.code,{children:`rtc_user_info_t.device_type`}),` and the `,_jsx(_components.code,{children:`device_type`}),` in server callbacks. Defaults to `,_jsx(_components.code,{children:`80`}),` (agent joining on the server side) if not called.`]}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsx(_components.tbody,{children:_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`device_type`})}),_jsxs(_components.td,{children:[`Device type number; see the `,_jsx(_components.code,{children:`device_type`}),` description in the `,_jsx(_components.a,{href:`/en/rtc/server-api/guides/callbacks`,children:`Callback events guide`}),`. `,_jsx(_components.code,{children:`\u003c= 0`}),` restores the default `,_jsx(_components.code,{children:`80`})]})]})})]}),`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[`Must be called `,_jsx(_components.strong,{children:`before`}),` `,_jsx(_components.code,{children:`rtc_join_channel`}),` / `,_jsx(_components.code,{children:`rtc_join_channel_sync`}),`. The device type is reported only once, at join time; setting it after joining has no effect on the current session (automatic reconnection keeps the same session, so it doesn’t change either). To change the type, leave and join again.`]})}),`\n`,_jsx(Tip,{children:_jsxs(_components.p,{children:[`It applies per instance: multiple instances in the same process can each set their own. For example, a device gateway that creates one instance per connected device can report each device’s kind (`,_jsx(_components.code,{children:`82`}),` for SIP devices, `,_jsx(_components.code,{children:`83`}),` for H.323 devices, `,_jsx(_components.code,{children:`84`}),` for GB28181 cameras, and so on), so your application can tell where each member comes from.`]})}),`\n`,_jsx(_components.hr,{}),`\n`,_jsx(Heading,{level:`2`,id:`callback-registration`,children:`Callback registration`}),`\n`,_jsxs(_components.p,{children:[`Every callback carries your context through the `,_jsx(_components.code,{children:`context`}),` parameter; the SDK passes it back unchanged without interpreting it.`]}),`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[_jsx(_components.code,{children:`context`}),` must be a `,_jsx(_components.strong,{children:`real pointer`}),` (or `,_jsx(_components.code,{children:`NULL`}),`). Don’t cast small integers like `,_jsx(_components.code,{children:`1`}),` or `,_jsx(_components.code,{children:`2`}),` to pointers to use as IDs: the SDK stores it internally as a pointer, and a value below 4096 is treated as an invalid pointer and terminates the process immediately. If you need an ID, pass the address of memory that holds it.`]})}),`\n`,_jsxs(Warning,{children:[_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Callbacks run on internal SDK threads.`}),` Keep three things in mind:`]}),_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`User, track, channel, custom message, reconnection (connection state `,_jsx(_components.code,{children:`3`}),` / `,_jsx(_components.code,{children:`1`}),`) and SFU signaling (layer switch, network quality, active speakers) callbacks `,_jsx(_components.strong,{children:`fire one at a time in the order the events happen`}),` and never run concurrently with each other (since 0.1.1). Media sample callbacks (one thread per track), keyframe request callbacks and disconnection callbacks (`,_jsx(_components.code,{children:`rtc_set_disconnected_callback`}),` and connection state `,_jsx(_components.code,{children:`2`}),`) can run concurrently with them, so protect shared state yourself`]}),`\n`,_jsx(_components.li,{children:`Don’t do slow work in callbacks: event callbacks fire one at a time, so a blocked callback delays every event after it; queue slow processing and hand it to your own threads`}),`\n`,_jsxs(_components.li,{children:[`Pointers in callback parameters (`,_jsx(_components.code,{children:`uid`}),`, `,_jsx(_components.code,{children:`track_info`}),`, `,_jsx(_components.code,{children:`data`}),`, `,_jsx(_components.code,{children:`props`}),`, `,_jsx(_components.code,{children:`content_json`}),`, `,_jsx(_components.code,{children:`speakers`}),`, etc.) are `,_jsx(_components.strong,{children:`only valid during the callback`}),`; if you need to keep them (including handing them to another thread for async processing), copy them before the callback returns`]}),`\n`]})]}),`\n`,_jsx(Heading,{level:`3`,id:`rtc_set_connection_callback`,children:`rtc_set_connection_callback`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`c`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`c`,children:_jsxs(_components.code,{language:`c`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`typedef`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` void`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`rtc_connection_callback)(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` context, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`int`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` state);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` rtc_set_connection_callback`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` handle`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, rtc_connection_callback `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`callback`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` context`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Connection state changes. `,_jsx(_components.code,{children:`state`}),`: `,_jsx(_components.code,{children:`0`}),`=connecting, `,_jsx(_components.code,{children:`1`}),`=connected, `,_jsx(_components.code,{children:`2`}),`=disconnected, `,_jsx(_components.code,{children:`3`}),`=reconnecting.`]}),`\n`,_jsx(Heading,{level:`3`,id:`rtc_set_disconnected_callback`,children:`rtc_set_disconnected_callback`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`c`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`c`,children:_jsxs(_components.code,{language:`c`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`typedef`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` void`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`rtc_disconnected_callback)(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` context, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`int`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` reason, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`int`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` code, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` char`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` msg);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` rtc_set_disconnected_callback`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` handle`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, rtc_disconnected_callback `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`callback`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` context`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Fires once when the instance finally leaves the channel (at the same moment as `,_jsx(_components.code,{children:`state=2`}),` in the connection state callback, and before it), with the disconnect reason (since 0.0.9).`]}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`reason`})}),_jsxs(_components.td,{children:[`Disconnect reason `,_jsx(_components.code,{children:`RTC_DISCONNECT_*`}),`; see `,_jsx(_components.a,{href:`/en/rtc/capi/types#callback-parameter-enums`,children:`Types · Callback parameter enums`})]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`code`})}),_jsxs(_components.td,{children:[`The error code if there was an error (`,_jsx(_components.code,{children:`180xxx`}),` or a server `,_jsx(_components.code,{children:`1xxx`}),`; see `,_jsx(_components.a,{href:`/en/rtc/capi/error-codes`,children:`Error codes`}),`), otherwise `,_jsx(_components.code,{children:`0`})]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`msg`})}),_jsxs(_components.td,{children:[`The error reason; `,_jsx(_components.code,{children:`NULL`}),` if there was no error. Only valid during the callback`]})]})]})]}),`\n`,_jsx(Tip,{children:_jsxs(_components.p,{children:[`Use it to decide whether to rejoin automatically: don’t rejoin automatically when removed from the channel (`,_jsx(_components.code,{children:`KICKED`}),`), replaced by another session with the same uid (`,_jsx(_components.code,{children:`REPLACE`}),`), or when the channel is destroyed (`,_jsx(_components.code,{children:`DESTROY`}),`); in cases such as a heartbeat timeout (`,_jsx(_components.code,{children:`TIMEOUT`}),`), you can rejoin with a newly issued token.`]})}),`\n`,_jsx(Heading,{level:`3`,id:`rtc_set_user_event_callback`,children:`rtc_set_user_event_callback`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`c`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`c`,children:_jsxs(_components.code,{language:`c`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`typedef`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` void`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`rtc_user_event_callback)(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` context, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` char`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` uid, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`int`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` event_type);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` rtc_set_user_event_callback`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` handle`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, rtc_user_event_callback `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`callback`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` context`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Users joining and leaving the channel. `,_jsx(_components.code,{children:`event_type`}),`: `,_jsx(_components.code,{children:`0`}),`=joined, `,_jsx(_components.code,{children:`1`}),`=left.`]}),`\n`,_jsx(Heading,{level:`3`,id:`rtc_set_track_event_callback`,children:`rtc_set_track_event_callback`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`c`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`c`,children:_jsxs(_components.code,{language:`c`,numberOfLines:`3`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`typedef`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` void`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`rtc_track_event_callback)(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` context, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` char`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` uid,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` rtc_track_info_t`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` track_info, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`int`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` event_type);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` rtc_set_track_event_callback`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` handle`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, rtc_track_event_callback `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`callback`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` context`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Remote tracks added, updated, or removed. `,_jsx(_components.code,{children:`event_type`}),`: `,_jsx(_components.code,{children:`0`}),`=added, `,_jsx(_components.code,{children:`1`}),`=updated, `,_jsx(_components.code,{children:`2`}),`=removed. With manual subscription, use this callback to discover tracks you can subscribe to.`]}),`\n`,_jsx(Heading,{level:`3`,id:`rtc_set_track_sample_callback`,children:`rtc_set_track_sample_callback`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`6`,language:`c`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`c`,children:_jsxs(_components.code,{language:`c`,numberOfLines:`6`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`typedef`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` void`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`rtc_track_sample_callback)(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` context,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` rtc_user_info_t`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` user_info,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` rtc_track_info_t`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` track_info,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` uint8_t`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` data, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`int`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` len,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` int64_t`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` timestamp, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`int64_t`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` duration);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` rtc_set_track_sample_callback`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` handle`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, rtc_track_sample_callback `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`callback`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` context`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Media data for subscribed tracks. Every subscribed track (including composite streams) comes out of this single callback; use `,_jsx(_components.code,{children:`user_info->uid`}),` + `,_jsx(_components.code,{children:`track_info->track_id`}),` to tell the sources apart.`]}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`data`}),` is a complete encoded frame (one frame for video, one encoded packet for audio). The pointer is only valid during the callback:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`c`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`c`,children:_jsxs(_components.code,{language:`c`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`uint8_t`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` saved `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` malloc`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(len);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`memcpy`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(saved, data, len);`}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // Copy it if you need to keep it`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`3`,id:`rtc_set_custom_msg_callback`,children:`rtc_set_custom_msg_callback`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`c`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`c`,children:_jsxs(_components.code,{language:`c`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`typedef`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` void`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`rtc_custom_msg_callback)(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` context, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` rtc_custom_msg_t`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` msg);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` rtc_set_custom_msg_callback`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` handle`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, rtc_custom_msg_callback `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`callback`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` context`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`In-channel custom messages; see `,_jsx(_components.a,{href:`/en/rtc/capi/advanced/custom-msg`,children:`Custom messages`}),`.`]}),`\n`,_jsx(Heading,{level:`3`,id:`seastart-only-callbacks`,children:`SeaStart-only callbacks`}),`\n`,_jsxs(_components.p,{children:[`The following three callbacks only fire when the channel uses the SeaStart engine; with other engines they’re never called. See `,_jsx(_components.a,{href:`/en/rtc/capi/advanced/seastart`,children:`SeaStart advanced features`}),`.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`c`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`c`,children:_jsxs(_components.code,{language:`c`,numberOfLines:`3`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` rtc_set_layer_switched_callback`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` handle`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, rtc_layer_switched_callback `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`callback`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` context`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` rtc_set_connection_quality_callback`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` handle`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, rtc_connection_quality_callback `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`callback`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` context`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` rtc_set_active_speakers_callback`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` handle`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, rtc_active_speakers_callback `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`callback`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` context`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`]})})}),`\n`,_jsx(_components.hr,{}),`\n`,_jsx(Heading,{level:`2`,id:`typical-call-order`,children:`Typical call order`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`23`,language:`c`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`c`,children:_jsxs(_components.code,{language:`c`,numberOfLines:`23`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`rtc_set_log_level`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(RTC_LOG_INFO);`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` rtc `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` rtc_create`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// 1) Register callbacks first`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`rtc_set_connection_callback`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(rtc, on_conn, ctx);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`rtc_set_user_event_callback`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(rtc, on_user, ctx);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`rtc_set_track_event_callback`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(rtc, on_track, ctx);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`rtc_set_track_sample_callback`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(rtc, on_sample, ctx);`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// 2) Then configure auto-subscribe`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`rtc_set_auto_subscribe`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(rtc, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`1`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`1`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// (Optional) set the device type reported at join; defaults to 80 if not called`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// rtc_set_device_type(rtc, 82);`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// 3) Finally join the channel`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`rtc_join_channel_sync`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(rtc, token, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`10000`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// ... application runs ...`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`rtc_leave_channel`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(rtc);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`rtc_destroy`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(rtc);`})]}),`\n`]})})})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Instance and channel","description":"C SDK instance lifecycle (rtc_create / rtc_destroy and when it is safe to free callback context), joining and leaving channels, rtc_get_last_error, auto-subscribe, log level and log upload, language, and every callback registration function with its threading rules.","href":"/en/rtc/capi/api-reference/engine"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Logging","slug":"logging","depth":2,"children":[{"title":"rtc_set_log_level","slug":"rtc_set_log_level","depth":3,"children":[]},{"title":"rtc_set_log_upload","slug":"rtc_set_log_upload","depth":3,"children":[]}]},{"title":"Language","slug":"language","depth":2,"children":[{"title":"rtc_set_language","slug":"rtc_set_language","depth":3,"children":[]}]},{"title":"Instance lifecycle","slug":"instance-lifecycle","depth":2,"children":[{"title":"rtc_create","slug":"rtc_create","depth":3,"children":[]},{"title":"rtc_destroy","slug":"rtc_destroy","depth":3,"children":[]}]},{"title":"Joining and leaving a channel","slug":"joining-and-leaving-a-channel","depth":2,"children":[{"title":"rtc_join_channel","slug":"rtc_join_channel","depth":3,"children":[]},{"title":"rtc_join_channel_sync","slug":"rtc_join_channel_sync","depth":3,"children":[]},{"title":"rtc_get_last_error","slug":"rtc_get_last_error","depth":3,"children":[]},{"title":"rtc_leave_channel","slug":"rtc_leave_channel","depth":3,"children":[]}]},{"title":"Auto-subscribe","slug":"auto-subscribe","depth":2,"children":[{"title":"rtc_set_auto_subscribe","slug":"rtc_set_auto_subscribe","depth":3,"children":[]}]},{"title":"Device type","slug":"device-type","depth":2,"children":[{"title":"rtc_set_device_type","slug":"rtc_set_device_type","depth":3,"children":[]}]},{"title":"Callback registration","slug":"callback-registration","depth":2,"children":[{"title":"rtc_set_connection_callback","slug":"rtc_set_connection_callback","depth":3,"children":[]},{"title":"rtc_set_disconnected_callback","slug":"rtc_set_disconnected_callback","depth":3,"children":[]},{"title":"rtc_set_user_event_callback","slug":"rtc_set_user_event_callback","depth":3,"children":[]},{"title":"rtc_set_track_event_callback","slug":"rtc_set_track_event_callback","depth":3,"children":[]},{"title":"rtc_set_track_sample_callback","slug":"rtc_set_track_sample_callback","depth":3,"children":[]},{"title":"rtc_set_custom_msg_callback","slug":"rtc_set_custom_msg_callback","depth":3,"children":[]},{"title":"SeaStart-only callbacks","slug":"seastart-only-callbacks","depth":3,"children":[]}]},{"title":"Typical call order","slug":"typical-call-order","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"freewind","siteName":"STMLink Docs","title":"Instance and channel - STMLink Docs","contextualStarterQuestions":[],"navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{"zh":{"href":"/zh/rtc/capi/api-reference/engine","matchLevel":1},"en":{"href":"/en/rtc/capi/api-reference/engine","matchLevel":0}}},"lastModified":"2026-11-24T12:57:31.165Z","originalFileLocation":"en/rtc/capi/api-reference/engine.md","locale":"en"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"C SDK instance lifecycle (rtc_create / rtc_destroy and when it is safe to free callback context), joining and leaving channels, rtc_get_last_error, auto-subscribe, log level and log upload, language, and every callback registration function with its threading rules.\">\u003cmeta data-mint-head name=\"application-name\" content=\"STMLink Docs\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/freewind/ZKlibvJ7BVLSobx8/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/freewind/ZKlibvJ7BVLSobx8/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/freewind/ZKlibvJ7BVLSobx8/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/freewind/ZKlibvJ7BVLSobx8/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/freewind/ZKlibvJ7BVLSobx8/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/freewind/ZKlibvJ7BVLSobx8/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/freewind/ZKlibvJ7BVLSobx8/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/freewind/ZKlibvJ7BVLSobx8/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/freewind/ZKlibvJ7BVLSobx8/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Instance and channel - STMLink Docs\">\u003cmeta data-mint-head property=\"og:description\" content=\"C SDK instance lifecycle (rtc_create / rtc_destroy and when it is safe to free callback context), joining and leaving channels, rtc_get_last_error, auto-subscribe, log level and log upload, language, and every callback registration function with its threading rules.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"STMLink Docs\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.stmlink.com/en/rtc/capi/api-reference/engine\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://freewind.mintlify.site/_mintlify/api/og/v2?division=API+reference\u0026amp;title=Instance+and+channel\u0026amp;description=C+SDK+instance+lifecycle+%28rtc_create+%2F+rtc_destroy+and+when+it+is+safe+to+free+callback+context%29%2C+joining+and+leaving+channels%2C+rtc_get_last_error%2C+auto-subscri\u0026amp;theme=3db2af3ca713d1d9c29377dc\u0026amp;signature=2eebd821771da093eea549eea539e209ff794d4c29c92837a4234e9dc3744018\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Instance and channel - STMLink Docs\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"C SDK instance lifecycle (rtc_create / rtc_destroy and when it is safe to free callback context), joining and leaving channels, rtc_get_last_error, auto-subscribe, log level and log upload, language, and every callback registration function with its threading rules.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://freewind.mintlify.site/_mintlify/api/og/v2?division=API+reference\u0026amp;title=Instance+and+channel\u0026amp;description=C+SDK+instance+lifecycle+%28rtc_create+%2F+rtc_destroy+and+when+it+is+safe+to+free+callback+context%29%2C+joining+and+leaving+channels%2C+rtc_get_last_error%2C+auto-subscri\u0026amp;theme=3db2af3ca713d1d9c29377dc\u0026amp;signature=2eebd821771da093eea549eea539e209ff794d4c29c92837a4234e9dc3744018\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/freewind/ZKlibvJ7BVLSobx8/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"STMLink Docs\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#0066FF\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.stmlink.com/en/rtc/capi/api-reference/engine\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/en/rtc/capi/api-reference/engine.md\">\u003clink data-mint-head rel=\"alternate\" hreflang=\"en\" href=\"https://docs.stmlink.com/en/rtc/capi/api-reference/engine\">\u003clink data-mint-head rel=\"alternate\" hreflang=\"zh\" href=\"https://docs.stmlink.com/zh/rtc/capi/api-reference/engine\">\u003clink data-mint-head rel=\"alternate\" hreflang=\"x-default\" href=\"https://docs.stmlink.com/zh/rtc/capi/api-reference/engine\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.stmlink.com/#organization\",\"name\":\"STMLink Docs\",\"url\":\"https://docs.stmlink.com\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/freewind/-N23X1jpF3KMqIP_/logo/light.svg?fit=max\u0026auto=format\u0026n=-N23X1jpF3KMqIP_\u0026q=85\u0026s=c87be878176892b493466cf0647c68cc\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.stmlink.com#website\",\"name\":\"STMLink Docs\",\"url\":\"https://docs.stmlink.com\",\"publisher\":{\"@id\":\"https://docs.stmlink.com/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.stmlink.com/en/rtc/capi/api-reference/engine#webpage\",\"url\":\"https://docs.stmlink.com/en/rtc/capi/api-reference/engine\",\"name\":\"Instance and channel\",\"description\":\"C SDK instance lifecycle (rtc_create / rtc_destroy and when it is safe to free callback context), joining and leaving channels, rtc_get_last_error, auto-subscribe, log level and log upload, language, and every callback registration function with its threading rules.\",\"dateModified\":\"2026-11-24T12:57:31.165Z\",\"isPartOf\":{\"@id\":\"https://docs.stmlink.com#website\"},\"breadcrumb\":{\"@id\":\"https://docs.stmlink.com/en/rtc/capi/api-reference/engine#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.stmlink.com/en/rtc/capi/api-reference/engine#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"C SDK (server/embedded)\",\"item\":\"https://docs.stmlink.com/en/rtc/capi/integration\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Instance and channel\",\"item\":\"https://docs.stmlink.com/en/rtc/capi/api-reference/engine\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.stmlink.com/en/rtc/capi/api-reference/engine#article\",\"headline\":\"Instance and channel\",\"name\":\"Instance and channel\",\"description\":\"C SDK instance lifecycle (rtc_create / rtc_destroy and when it is safe to free callback context), joining and leaving channels, rtc_get_last_error, auto-subscribe, log level and log upload, language, and every callback registration function with its threading rules.\",\"url\":\"https://docs.stmlink.com/en/rtc/capi/api-reference/engine\",\"mainEntityOfPage\":{\"@id\":\"https://docs.stmlink.com/en/rtc/capi/api-reference/engine#webpage\"},\"dateModified\":\"2026-11-24T12:57:31.165Z\",\"publisher\":{\"@id\":\"https://docs.stmlink.com/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.stmlink.com#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"STMLink Docs\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"STMLink Docs\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/en/rtc/capi/api-reference/engine.md","siteName":"STMLink Docs","nav":{"global":null,"languages":[{"language":"zh","pages":[{"title":"zh","href":"/zh/rtc/capi/api-reference/engine"}]},{"language":"en","footer":{"socials":{"website":"https://www.stmlink.com/en"},"links":[{"header":"Products","items":[{"label":"Website","href":"https://www.stmlink.com/en"},{"label":"SRTC Audio \u0026 Video SDK","href":"https://docs.stmlink.com/en/rtc/overview"},{"label":"SMeeting Conferencing SDK","href":"https://docs.stmlink.com/en/meeting/overview"}]},{"header":"Support","items":[{"label":"Contact us","href":"https://www.stmlink.com/en"}]}]},"tabs":[{"tab":"SRTC Audio \u0026 Video SDK","groups":[{"group":"Overview","pages":[{"title":"Overview","href":"/en/rtc/overview"},{"title":"Choosing SRTC or SMeeting","href":"/en/choose"},{"title":"Quickstart","href":"/en/rtc/quickstart"},{"title":"Key concepts","href":"/en/rtc/key-concepts"},{"title":"Token and authentication","href":"/en/rtc/token"},{"title":"Network lines","href":"/en/rtc/network-line"},{"title":"Whiteboard","href":"/en/rtc/whiteboard"},{"title":"Error code format and unified table","href":"/en/rtc/error-codes"},{"title":"Build with AI","href":"/en/ai"}]},{"group":"Web SDK","pages":[{"title":"Integration","href":"/en/rtc/web/integration"},{"title":"Quickstart","href":"/en/rtc/web/quickstart"},{"title":"Key concepts","href":"/en/rtc/web/key-concepts"},{"title":"Channel messages","href":"/en/rtc/web/channel-messages"},{"title":"Network quality","href":"/en/rtc/web/network-quality"},{"group":"Advanced","pages":[{"title":"Multi-channel","href":"/en/rtc/web/advanced/multi-channel"},{"title":"Mute vs. unpublish","href":"/en/rtc/web/advanced/mute-vs-unpublish"},{"title":"Simulcast and resolution","href":"/en/rtc/web/advanced/video-stream-layers"},{"title":"Screen sharing","href":"/en/rtc/web/advanced/screen-sharing"},{"title":"Multi-window and dual-screen video layout","href":"/en/rtc/web/advanced/multi-window-video-layout"},{"title":"Custom tracks","href":"/en/rtc/web/advanced/custom-track"},{"title":"Local recording","href":"/en/rtc/web/advanced/local-recording"},{"title":"Audio/video processors (plugins)","href":"/en/rtc/web/advanced/audio-processor"},{"title":"RNN noise suppression plugin","href":"/en/rtc/web/advanced/rnnoise"},{"title":"DeepFilterNet noise suppression plugin","href":"/en/rtc/web/advanced/deepfilternet"}]},{"group":"API reference","pages":[{"title":"SRTC","href":"/en/rtc/web/api-reference/SRTC"},{"title":"media-tracks","href":"/en/rtc/web/api-reference/media-tracks"}]},{"title":"Events","href":"/en/rtc/web/events"},{"title":"Types","href":"/en/rtc/web/types"},{"title":"Error codes","href":"/en/rtc/web/error-codes"},{"title":"Changelog","href":"/en/rtc/web/changelog"},{"title":"FAQ","href":"/en/rtc/web/faq"}]},{"group":"Android SDK","pages":[{"title":"Integration","href":"/en/rtc/android/integration"},{"title":"Quickstart","href":"/en/rtc/android/quickstart"},{"title":"Network quality","href":"/en/rtc/android/network-quality"},{"group":"Advanced","pages":[{"title":"Multi-channel","href":"/en/rtc/android/advanced/multi-channel"},{"title":"Audio routing","href":"/en/rtc/android/advanced/audio-routing"},{"title":"Custom tracks","href":"/en/rtc/android/advanced/custom-track"},{"title":"AI noise suppression (DeepFilterNet)","href":"/en/rtc/android/advanced/deepfilternet"},{"title":"Whiteboard integration","href":"/en/rtc/android/advanced/whiteboard"}]},{"group":"API reference","pages":[{"title":"RTCEngine","href":"/en/rtc/android/api-reference/RTCEngine"},{"title":"RTCChannel","href":"/en/rtc/android/api-reference/RTCChannel"},{"title":"RTCEngineEvent","href":"/en/rtc/android/api-reference/RTCEngineEvent"},{"title":"LocalCameraTrack","href":"/en/rtc/android/api-reference/LocalCameraTrack"},{"title":"LocalScreenTrack","href":"/en/rtc/android/api-reference/LocalScreenTrack"},{"title":"LocalMicTrack","href":"/en/rtc/android/api-reference/LocalMicTrack"},{"title":"LocalCustomVideoTrack","href":"/en/rtc/android/api-reference/LocalCustomVideoTrack"},{"title":"RemoteVideoTrack","href":"/en/rtc/android/api-reference/RemoteVideoTrack"},{"title":"RemoteAudioMixTrack","href":"/en/rtc/android/api-reference/RemoteAudioMixTrack"},{"title":"RTCClientEvent","href":"/en/rtc/android/api-reference/RTCClientEvent"},{"title":"RTCMediaEvent","href":"/en/rtc/android/api-reference/RTCMediaEvent"},{"title":"RTCCameraDeviceEvent","href":"/en/rtc/android/api-reference/RTCCameraDeviceEvent"},{"title":"RTCMicDeviceEvent","href":"/en/rtc/android/api-reference/RTCMicDeviceEvent"},{"title":"RTCLocalAudioFrameEvent","href":"/en/rtc/android/api-reference/RTCLocalAudioFrameEvent"},{"title":"RTCImEvent","href":"/en/rtc/android/api-reference/RTCImEvent"},{"title":"AudioRouterManager","href":"/en/rtc/android/api-reference/AudioRouterManager"},{"title":"LogUtil","href":"/en/rtc/android/api-reference/LogUtil"}]},{"group":"Presets","pages":[{"title":"Camera preset","href":"/en/rtc/android/presets/camera"},{"title":"Microphone preset","href":"/en/rtc/android/presets/microphone"},{"title":"Screen sharing preset","href":"/en/rtc/android/presets/screen-sharing"},{"title":"Custom video preset","href":"/en/rtc/android/presets/custom-video"}]},{"title":"Types","href":"/en/rtc/android/types"},{"title":"Enums","href":"/en/rtc/android/enums"},{"title":"Media quality","href":"/en/rtc/android/media-quality"},{"title":"Error codes","href":"/en/rtc/android/error-codes"},{"title":"Changelog","href":"/en/rtc/android/changelog"}]},{"group":"Windows SDK","pages":[{"title":"Integration","href":"/en/rtc/windows/integration"},{"group":"Quickstart","pages":[{"title":"C++ Quickstart","sidebarTitle":"C++","href":"/en/rtc/windows/quickstart-cpp"},{"title":"C# Quickstart","sidebarTitle":"C#","href":"/en/rtc/windows/quickstart-csharp"}]},{"group":"API reference","pages":[{"title":"IRTCEngine","href":"/en/rtc/windows/api-reference/IRTCEngine"},{"title":"IRTCEngineEvent","href":"/en/rtc/windows/api-reference/IRTCEngineEvent"},{"title":"IRTCChannel","href":"/en/rtc/windows/api-reference/IRTCChannel"},{"title":"IRTCChannelEvent","href":"/en/rtc/windows/api-reference/IRTCChannelEvent"},{"title":"IRTCRecord","href":"/en/rtc/windows/api-reference/IRTCRecord"},{"title":"IRTCLocalScreenTrack","href":"/en/rtc/windows/api-reference/IRTCLocalScreenTrack"},{"title":"IRTCLocalCameraTrack","href":"/en/rtc/windows/api-reference/IRTCLocalCameraTrack"},{"title":"IRTCLocalMicTrack","href":"/en/rtc/windows/api-reference/IRTCLocalMicTrack"},{"title":"IRTCLocalVideoTrack","href":"/en/rtc/windows/api-reference/IRTCLocalVideoTrack"},{"title":"IRTCLocalAudioTrack","href":"/en/rtc/windows/api-reference/IRTCLocalAudioTrack"},{"title":"IRTCRemoteVideoTrack","href":"/en/rtc/windows/api-reference/IRTCRemoteVideoTrack"},{"title":"IRTCRemoteAudioTrack","href":"/en/rtc/windows/api-reference/IRTCRemoteAudioTrack"},{"title":"IRTCCustomVideoTrack","href":"/en/rtc/windows/api-reference/IRTCCustomVideoTrack"},{"title":"IRTCCustomAudioTrack","href":"/en/rtc/windows/api-reference/IRTCCustomAudioTrack"},{"title":"IRTCView","href":"/en/rtc/windows/api-reference/IRTCView"},{"title":"IRTCTrack","href":"/en/rtc/windows/api-reference/IRTCTrack"},{"title":"IRTCChannelSetting","href":"/en/rtc/windows/api-reference/IRTCChannelSetting"}]},{"title":"Types","href":"/en/rtc/windows/types"},{"title":"Enums","href":"/en/rtc/windows/enums"},{"title":"Error codes","href":"/en/rtc/windows/error-codes"},{"title":"Changelog","href":"/en/rtc/windows/changelog"}]},{"group":"Swift SDK (iOS/macOS)","pages":[{"title":"Integration","href":"/en/rtc/swift/integration"},{"title":"Quickstart","href":"/en/rtc/swift/quickstart"},{"title":"Key concepts","href":"/en/rtc/swift/key-concepts"},{"group":"Advanced","pages":[{"title":"Mute vs. unpublish","href":"/en/rtc/swift/advanced/mute-vs-unpublish"},{"title":"Device management","href":"/en/rtc/swift/advanced/device-management"},{"title":"Audio routing (iOS)","href":"/en/rtc/swift/advanced/audio-routing"},{"title":"Screen sharing","href":"/en/rtc/swift/advanced/screen-sharing"},{"title":"Virtual background","href":"/en/rtc/swift/advanced/virtual-background"},{"title":"AI noise suppression (DeepFilterNet)","href":"/en/rtc/swift/advanced/deepfilternet"},{"title":"Multi-channel","href":"/en/rtc/swift/advanced/multi-channel"},{"title":"Call quality and active speakers","href":"/en/rtc/swift/advanced/call-quality"},{"title":"Custom tracks","href":"/en/rtc/swift/advanced/custom-track"}]},{"group":"API reference","pages":[{"title":"SRTCEngine","href":"/en/rtc/swift/api-reference/SRTCEngine"},{"title":"Channel and Track","href":"/en/rtc/swift/api-reference/media-tracks"}]},{"title":"Events","href":"/en/rtc/swift/events"},{"title":"Types","href":"/en/rtc/swift/types"},{"title":"Error codes","href":"/en/rtc/swift/error-codes"},{"title":"Changelog","href":"/en/rtc/swift/changelog"}]},{"group":"iOS SDK (Objective-C)","pages":[{"title":"Integration","href":"/en/rtc/ios/integration"},{"title":"Quickstart","href":"/en/rtc/ios/quickstart"},{"title":"IM","href":"/en/rtc/ios/instant-messaging"},{"group":"Advanced","pages":[{"title":"Screen recording","href":"/en/rtc/ios/advanced/screen-recording"},{"title":"Beauty filter","href":"/en/rtc/ios/advanced/beauty"},{"title":"Virtual background","href":"/en/rtc/ios/advanced/virtual-background"}]},{"group":"API reference","pages":[{"title":"RTCEngineKit","href":"/en/rtc/ios/api-reference/RTCEngineKit"},{"title":"RTCEngineChannel","href":"/en/rtc/ios/api-reference/RTCEngineChannel"},{"title":"RTCEngineDelegate","href":"/en/rtc/ios/api-reference/RTCEngineDelegate"},{"title":"RTCEngineChannelDelegate","href":"/en/rtc/ios/api-reference/RTCEngineChannelDelegate"},{"title":"RTCEngineIMDelegate","href":"/en/rtc/ios/api-reference/RTCEngineIMDelegate"}]},{"title":"Types","href":"/en/rtc/ios/types"},{"title":"Error codes","href":"/en/rtc/ios/error-codes"},{"title":"Changelog","href":"/en/rtc/ios/changelog"},{"title":"FAQ","href":"/en/rtc/ios/faq"}]},{"group":"C SDK (server/embedded)","pages":[{"title":"Integration","href":"/en/rtc/capi/integration"},{"title":"Quickstart","href":"/en/rtc/capi/quickstart"},{"group":"Advanced","pages":[{"title":"Composite stream (program)","href":"/en/rtc/capi/advanced/mcu"},{"title":"SeaStart advanced features","href":"/en/rtc/capi/advanced/seastart"},{"title":"Custom messages","description":"How the C SDK receives in-channel custom messages sent by other clients: the rtc_custom_msg_t fields, parsing content_json with a JSON library, and the memory and threading rules for the callback.","href":"/en/rtc/capi/advanced/custom-msg"}]},{"group":"API reference","pages":[{"title":"Instance and channel","href":"/en/rtc/capi/api-reference/engine"},{"title":"Subscribing and receiving","description":"C SDK functions for subscribing to remote audio and video tracks (auto-subscribe vs. manual subscription in the track event callback), unsubscribing, and rtc_request_key_frame, including when you should and shouldn't request a keyframe.","href":"/en/rtc/capi/api-reference/subscribe"},{"title":"Publishing","href":"/en/rtc/capi/api-reference/publish"},{"title":"User info queries","href":"/en/rtc/capi/api-reference/users"}]},{"title":"Types","href":"/en/rtc/capi/types"},{"title":"Error codes","href":"/en/rtc/capi/error-codes"},{"title":"Changelog","href":"/en/rtc/capi/changelog"}]},{"group":"Python SDK (server-side AI)","pages":[{"title":"Integration","href":"/en/rtc/python/integration"},{"title":"Quickstart","href":"/en/rtc/python/quickstart"},{"group":"Advanced","pages":[{"title":"Voice AI agent guide","href":"/en/rtc/python/advanced/ai-agent"},{"title":"Integrating pipecat","href":"/en/rtc/python/advanced/pipecat"}]},{"group":"API reference","pages":[{"title":"Channel","href":"/en/rtc/python/api-reference/channel"},{"title":"Event callbacks","href":"/en/rtc/python/api-reference/events"},{"title":"Audio and video data","href":"/en/rtc/python/api-reference/audio"}]},{"title":"Types","href":"/en/rtc/python/types"},{"title":"Error codes","href":"/en/rtc/python/error-codes"},{"title":"Changelog","href":"/en/rtc/python/changelog"}]},{"group":"Server API","pages":[{"title":"Overview","href":"/en/rtc/server-api/overview"},{"group":"Guides","pages":[{"title":"Cloud recording and stream mixing guide","href":"/en/rtc/server-api/guides/recording"},{"title":"Media output guide","href":"/en/rtc/server-api/guides/media-output"},{"title":"Callback events guide","href":"/en/rtc/server-api/guides/callbacks"},{"title":"Device integration guide","href":"/en/rtc/server-api/guides/agents"}]},{"group":"API reference","pages":[{"title":"Channel","href":"/en/rtc/server-api/channel"},{"title":"Cloud recording and stream mixing","href":"/en/rtc/server-api/mcu"},{"title":"Per-speaker voice recording","href":"/en/rtc/server-api/talkrec"},{"title":"Device integration","href":"/en/rtc/server-api/agent"},{"title":"IM messages","href":"/en/rtc/server-api/im"},{"title":"Whiteboard","href":"/en/rtc/server-api/white-board"},{"title":"Transcription","href":"/en/rtc/server-api/asr"},{"title":"Meeting minutes","href":"/en/rtc/server-api/ai"},{"title":"Simultaneous Interpretation","href":"/en/rtc/server-api/interp"},{"title":"Media output","href":"/en/rtc/server-api/stream"},{"title":"Network ID","href":"/en/rtc/server-api/network"}]},{"title":"Error codes","href":"/en/rtc/server-api/error-codes"},{"title":"Reference backend implementation","href":"/en/rtc/server-api/server-demo"}]}]},{"tab":"SMeeting Conferencing SDK","pages":[{"title":"SMeeting Conferencing SDK","href":"/en/meeting/overview"}]},{"tab":"Product \u0026 deployment","pages":[{"title":"Product \u0026 deployment","href":"/en/product/overview"}]}]}]},"basePath":"","title":"Instance and channel - STMLink Docs","deploymentId":"dpl_4dgnk6TA5fUgboKHTvWWyeqm3idh","buildId":"dpl_4dgnk6TA5fUgboKHTvWWyeqm3idh","dynamics":[],"chunks":[]}