> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stmlink.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent 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.

# AI noise suppression (DeepFilterNet)

> Enable AI noise suppression with adjustable strength on the microphone with the optional cn.seastart.rtc:denoise plugin: adding the dependency, on/off and strength control, handling unsupported devices and CPU overload, and using a custom AudioCaptureProcessor.

`cn.seastart.rtc:denoise` is an AI noise suppression plugin based on [DeepFilterNet3](https://github.com/Rikorose/DeepFilterNet). It uses the same algorithm, model, and parameters as the Web [DeepFilterNet noise suppression plugin](https://docs.stmlink.com/en/rtc/web/advanced/deepfilternet.md), so it sounds the same on every platform. It implements the SDK's `AudioCaptureProcessor` interface and takes effect once attached with `RTCEngine.setAudioCaptureProcessor`, with **suppression strength adjustable at runtime** and a **temporary bypass**.

The plugin is a separate, optional dependency, available since RTC `2.0.39`. Apps that don't use AI noise suppression don't need it.

## 1. Add the dependency

```groovy theme={null}
dependencies {
    implementation 'cn.seastart.rtc:rtc:2.0.39'
    implementation 'cn.seastart.rtc:denoise:0.1.0'
}
```

* The plugin depends transitively on `cn.seastart.rtc:rtc` and requires RTC `2.0.39` or later.
* The plugin supports `arm64-v8a` and `armeabi-v7a`, the same as the SDK.
* The model is built into the plugin; you don't need to copy any extra resources.

## 2. Enable and disable

```kotlin theme={null}
import cn.seastart.rtc.denoise.DeepFilterNetProcessor
import cn.seastart.rtc.denoise.DenoiseNotSupportedException

private var denoiser: DeepFilterNetProcessor? = null

fun enableDenoise(context: Context, rtcEngine: RTCEngine) {
    // 1. Hide the noise suppression switch on unsupported devices
    if (!DeepFilterNetProcessor.isSupported()) return
    try {
        // 2. Create the plugin; strength 0–100, default 50
        val processor = DeepFilterNetProcessor(context, suppressionLevel = 50)
        // 3. If the CPU can't keep up during a call, the plugin pauses suppression and calls back on the main thread
        processor.overloadListener = DeepFilterNetProcessor.OverloadListener {
            showToast("Device too slow; AI noise suppression paused")
        }
        // 4. Takes effect as soon as it's attached, before or after joining; Engine-level, applies to all channels
        rtcEngine.setAudioCaptureProcessor(processor)
        denoiser = processor
    } catch (e: DenoiseNotSupportedException) {
        // Device not supported: e.code == RtcErrorCode.FEATURE_NOT_SUPPORTED (102032)
    }
}

fun disableDenoise(rtcEngine: RTCEngine) {
    rtcEngine.setAudioCaptureProcessor(null)   // Detach and restore the system's and SDK's built-in noise suppression
    denoiser = null
}
```

Adjust the strength or bypass temporarily at runtime without detaching:

```kotlin theme={null}
denoiser?.setSuppressionLevel(80)  // 0–100; higher suppresses more
denoiser?.setEnabled(false)        // Bypass: audio passes through unchanged while the processor stays attached
denoiser?.setEnabled(true)         // Resume suppression and clear a pause caused by CPU overload
```

## 3. API

| API | Description |
| - | - |
| `DeepFilterNetProcessor.isSupported(): Boolean` | Static method: whether the current device is supported. Check it before enabling, and hide the switch when unsupported |
| `DeepFilterNetProcessor(context, suppressionLevel = 50)` | Creates the plugin; `suppressionLevel` is the strength, 0–100. Throws `DenoiseNotSupportedException` on unsupported devices |
| `setSuppressionLevel(value: Int)` | Adjusts the strength (0–100) at runtime |
| `setEnabled(value: Boolean)` | Turns suppression on or off. With `false`, audio passes through unchanged; `true` resumes suppression and clears a pause caused by CPU overload |
| `suppressionLevel: Int` | Current strength, read-only |
| `isEnabled: Boolean` | Current on/off state, read-only. An automatic overload pause doesn't change it |
| `overloadListener: OverloadListener?` | Called when the CPU can't keep up during a call and suppression has been paused automatically. Runs on the main thread, once per pause |
| `DenoiseNotSupportedException.code` | Always `RtcErrorCode.FEATURE_NOT_SUPPORTED` (`102032`) |

## 4. Unsupported devices and CPU overload

AI noise suppression needs a certain amount of CPU power. The SDK handles this in two layers:

* **Before enabling**: only devices with low-performance little cores (common in some TVs, set-top boxes, and entry-level phones) are unsupported. On them `isSupported()` returns `false` and the constructor throws `DenoiseNotSupportedException` (`102032`). Check first and only then show the switch, rather than reporting an error after the user taps it.
* **During a call**: if the device stays overloaded (for example, while running other heavy workloads), the plugin switches to bypass automatically so the call doesn't stutter, and calls `overloadListener`. Tell the user something like "Device too slow; noise suppression paused" and let them decide whether to call `setEnabled(true)` to turn it back on.

## 5. Notes

* **When attached, the SDK turns off the system's and WebRTC's built-in noise suppression** and restores it on detach, so two layers of suppression don't stack and muffle the voice. Echo cancellation and automatic gain control are unaffected. This switch rebuilds microphone capture once, leaving a gap of less than half a second. To turn suppression off temporarily, use `setEnabled(false)`, which doesn't rebuild capture.
* The model loads in the background (usually in under 1 second). Until it's loaded, audio passes through unchanged and capture isn't blocked.
* It works only with 48 kHz mono capture; other capture formats pass through unchanged.
* Local volume (`getVolume`, speaker levels) reflects the volume before noise suppression.
* `setAudioCaptureProcessor` holds only one processor, applied to all channels; `releaseSDK()` doesn't clear it.
* License: DeepFilterNet itself is Apache-2.0/MIT; verify the license of the model weights yourself before distribution.

## 6. Custom capture processors

The `AudioCaptureProcessor` interface the plugin implements can also be used to plug in your own audio algorithms (noise suppression, voice changing, and so on). The processor processes each PCM frame in place on the SDK capture thread; the processed data is then distributed to all channels, and the local audio frame callback also receives the processed data.

```kotlin theme={null}
class MyProcessor : AudioCaptureProcessor {
    // Optional: require built-in noise suppression off; return null to leave it unchanged
    override val audioProcessing = AudioProcessingConstraints(noiseSuppression = false)

    override fun initialize(sampleRate: Int, channelCount: Int) {
        // Called when the capture format is determined (including rebuilds after device switches or route changes); return quickly
    }

    override fun process(data: ByteArray, offset: Int, length: Int) {
        // Process data[offset, offset + length) in place: 16-bit little-endian PCM, 48 kHz mono 10 ms (960 bytes) by default
        // Called every 10 ms and must return within a few milliseconds; the buffer is reused after return, so don't keep data
    }

    override fun release() {
        // Called when the processor is replaced or cleared; process isn't called afterward
    }
}

rtcEngine.setAudioCaptureProcessor(MyProcessor())
```

* Exceptions thrown from `process` are caught and logged by the SDK, and that frame is sent unchanged.
* `AudioProcessingConstraints` has the same meaning as the same-named type in the Web and Swift SDKs. Android currently handles only `noiseSuppression`; `echoCancellation` and `autoGainControl` keep the SDK defaults.
* For interface details, see [RTCEngine.setAudioCaptureProcessor](https://docs.stmlink.com/en/rtc/android/api-reference/RTCEngine.md#setaudiocaptureprocessor-processor) and [Types](https://docs.stmlink.com/en/rtc/android/types.md#audiocaptureprocessor).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.