> ## Documentation Index
> Fetch the complete documentation index at: https://daily-hush-pcc-session-recordings-docs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Small WebRTC Transport

> WebRTC implementation for Android

The Small WebRTC transport enables real-time audio communication with a Pipecat bot over a direct WebRTC connection, with no third-party account required.

## Installation

Add the transport dependency to your `app/build.gradle.kts`:

```kotlin theme={null}
dependencies {
    implementation("ai.pipecat:small-webrtc-transport:1.2.0")
}
```

Add the microphone permission to `AndroidManifest.xml`:

```xml theme={null}
<uses-permission android:name="android.permission.RECORD_AUDIO" />
```

## Usage

```kotlin theme={null}
import ai.pipecat.client.PipecatClientOptions
import ai.pipecat.client.PipecatEventCallbacks
import ai.pipecat.client.small_webrtc_transport.PipecatClientSmallWebRTC
import ai.pipecat.client.small_webrtc_transport.SmallWebRTCTransport
import ai.pipecat.client.small_webrtc_transport.SmallWebRTCTransportConnectParams
import ai.pipecat.client.types.APIRequest
import ai.pipecat.client.types.BotReadyData
import ai.pipecat.client.types.Value

val callbacks = object : PipecatEventCallbacks() {
    override fun onBackendError(message: String) {
        Log.e(TAG, "Backend error: $message")
    }

    override fun onBotReady(data: BotReadyData) {
        Log.d(TAG, "Bot is ready")
    }
}

val options = PipecatClientOptions(callbacks = callbacks, enableMic = true)
val client = PipecatClientSmallWebRTC(SmallWebRTCTransport(context), options)

// Connect via your server's /start endpoint (recommended)
client.startBotAndConnect(
    APIRequest(
        endpoint = "https://your-server.com/start",
        // Pipecat Cloud and the Pipecat development runner use these fields
        // to decide how to run the bot; unknown fields are ignored
        requestData = Value.Object(
            "transport" to Value.Str("webrtc"),
            "enableDefaultIceServers" to Value.Bool(true),
        )
    )
).withCallback { result ->
    result.errorOrNull?.let { Log.e(TAG, "Connection failed: $it") }
}

// Or connect with coroutines
// client.startBotAndConnect(...).await()
```

To connect directly to a WebRTC offer endpoint instead (bypassing `/start`), pass `SmallWebRTCTransportConnectParams` to `connect()`:

```kotlin theme={null}
client.connect(
    SmallWebRTCTransportConnectParams(
        webrtcRequestParams = APIRequest(
            endpoint = "https://your-server.com/api/offer",
            requestData = Value.Object()
        )
    )
)
```

## Configuration

### IceConfig

Pass custom ICE servers for TURN/STUN support:

```kotlin theme={null}
val iceConfig = IceConfig(
    iceServers = listOf(
        IceServer(
            urls = listOf("turn:your-turn-server.com:3478"),
            username = "user",
            credential = "pass"
        )
    )
)

val transport = SmallWebRTCTransport(context, iceConfig = iceConfig)
```

### Audio devices

The transport exposes static constants for audio routing:

```kotlin theme={null}
// Route audio to speakerphone (default) or earpiece
client.updateMic(SmallWebRTCTransport.AudioDevices.Speakerphone.id)
client.updateMic(SmallWebRTCTransport.AudioDevices.Earpiece.id)
```

### Camera selection

```kotlin theme={null}
// Switch between front and rear cameras
client.updateCam(SmallWebRTCTransport.Cameras.Front.id)
client.updateCam(SmallWebRTCTransport.Cameras.Rear.id)
```

## Resources

<CardGroup cols={2}>
  <Card horizontal title="Demo" icon="play" href="https://github.com/pipecat-ai/pipecat-examples/tree/main/p2p-webrtc/video-transform/client/android">
    Demo App
  </Card>

  <Card horizontal title="Source" icon="github" href="https://github.com/pipecat-ai/pipecat-client-android-transports/">
    Client Transports
  </Card>
</CardGroup>

<Card title="Pipecat Android Client Reference" icon="book-open" href="https://docs-android.rtvi.ai/">
  Complete API documentation for the Pipecat Android client.
</Card>
