Android Integration with the olcRTC gomobile Bindings
Android gomobile API: SetProtector, SetProviders, Start, Stop, WaitReady, Check, Ping, and all transport and liveness configuration setters for olcRTC.
Use this file to discover all available pages before exploring further.
The mobile package provides a gomobile-compatible API for Android. It exposes a local SOCKS5 proxy that tunnels traffic through an encrypted WebRTC session to an olcRTC server, with full support for Android VPN socket protection. The API is intentionally flat — all state is package-level, designed for the gomobile binding model.
This produces an .aar archive (and a .jar sources stub) that you include in your Android/Kotlin project like any other local dependency.
The default transport is vp8channel. The datachannel transport is also
supported and can be selected at runtime via SetTransport or
StartWithTransport.
type SocketProtector interface { Protect(fd int) bool}
Implement this in Kotlin/Java to protect raw sockets from being routed back through your VPN (VpnService.protect(fd)). Pass the implementation to SetProtector before calling Start.
class MySocketProtector(private val vpnService: VpnService) : mobile.SocketProtector { override fun protect(fd: Long): Boolean = vpnService.protect(fd.toInt())}
Registers all built-in carriers (jitsi, telemost, wbstream), links, and transports (datachannel, vp8channel, etc.). Must be called at least once before any Start, Check, or Ping call.
Sets the Android VPN socket protector. Pass nil to clear it. Must be called before Start to ensure all sockets created during the WebRTC handshake are protected.
Selects the transport used by subsequent Start calls. Accepted values: "vp8channel" (default) and "datachannel". Unrecognized values fall back to "vp8channel".
Sets a pre-issued WbStream account token. When set, the session joins as that account instead of as an anonymous guest. Empty string keeps the guest flow.
The datachannel transport over WbStream requires a moderator/account token
with canPublishData=true. Guest accounts cannot publish data on WbStream.
Either call SetWBToken with a valid account token, or switch to
vp8channel / seichannel which work without a special token.
Sets the local bind host for the SOCKS5 listener. Default is "127.0.0.1". Use "0.0.0.0" to accept connections from other network interfaces on the device.
Configures the vp8channel transport. fps controls the frame rate (default 30, max 120); batchSize controls the number of packets batched per frame (default 8, max 64). Values below 1 are clamped to 1.
Launches the olcRTC client in the background using the transport set by SetTransport (default vp8channel). Returns immediately; the tunnel is not yet ready when Start returns. Call WaitReady to block until the SOCKS5 listener is accepting connections.
Parameter
Description
carrierName
Auth provider: "jitsi", "telemost", or "wbstream".
roomID
Carrier-specific room identifier.
clientID
Client identifier that must match the server’s -client-id.
keyHex
64-character hex encryption key shared with the server.
socksPort
Local SOCKS5 port to listen on, e.g. 10808.
socksUser
SOCKS5 username (empty = no auth).
socksPass
SOCKS5 password (empty = no auth).
Returns errAlreadyRunning if the client is already active.
Blocks until the SOCKS5 listener is ready to accept connections, or until the timeout expires. Call this after Start before routing any traffic through the SOCKS5 proxy.Returns nil when the tunnel is ready. Returns errStartTimedOut if the timeout elapses, errStoppedBeforeReady if the client stopped before becoming ready, or errNotRunning if Start was never called.
Check and Ping run isolated, short-lived client sessions and do not interact with the singleton managed by Start/Stop. Multiple probes can run concurrently.
Check and Ping create their own independent client session each time they
are called. They do not share state with Start/Stop, so you can run
parallel latency checks across different rooms or providers while a main
tunnel session is active.
Starts an isolated client session and returns the elapsed milliseconds from call to SOCKS5 listener readiness. Use this to measure tunnel establishment latency for a given carrier/room combination.timeoutMillis ≤ 0 defaults to 8000 ms. vp8FPS and vp8BatchSize tune the vp8channel transport for this probe; values below 1 are clamped to 1.
Starts an isolated client session, waits until the SOCKS5 listener is ready, then performs HTTP requests through the tunnel and returns the best observed HTTP latency in milliseconds. The warmup request is excluded from the measurement. pingURL defaults to https://www.google.com/generate_204 if empty.The returned value measures only HTTP request latency after the tunnel is ready, not tunnel establishment time.Ping timing constants: