RtcDuplexSession

class RtcDuplexSession(context: Context)

One audio sendrecv peer and a reliable text data channel. No signaling protocol is assumed. run owns the connection until cancellation or failure. The application owns microphone permission, the capture mixer, audio routing, and the coroutine collecting this session. The separate outgoing and incoming streams never feed decoded audio into capture. Create one instance per call; run disposes both streams on exit.

Constructors

Link copied to clipboard
constructor(context: Context)

Properties

Link copied to clipboard

Playback stream with communication audio attributes; do not register with capture.

Link copied to clipboard

Register with the capture mixer; closing this stream cancels the active call.

Functions

Link copied to clipboard
fun dispose()

Releases streams before starting, or after run has finished. Idempotent.

Link copied to clipboard
suspend fun run(dataChannelLabel: String, iceServers: List<String> = emptyList(), timeoutMillis: Long, exchange: suspend (String) -> String, onText: (String) -> Unit, onConnected: () -> Unit)

exchange receives a complete (non-trickle) SDP offer and returns an SDP answer. onText executes on the caller's coroutine context and must not block. Returns only on cancellation or failure; no automatic reconnect is performed.

Link copied to clipboard
fun send(text: String)

Sends text only after the connected callback has run.