> For the complete documentation index, see [llms.txt](https://docs.roomiekit.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.roomiekit.io/open-source-starter/media.md).

# Media and streaming

Roomie uses Agora by default through a small provider surface in `web/src/media`.

## Channel Names

* Room voice and avatar TV-head video: `roomie-room-<room-code>-voice`
* Direct 1:1 calls: `roomie-call-<call-id>`
* Personal-room group calls: `roomie-personal-<room-slug>-video`
* Theater streams: `roomie-theater-<room-slug>-stream`

## Token Flow

The app requests channel-scoped tokens from `supabase/functions/agora-token`.

1. Browser/native client sends authenticated request with `channelName`, `uid`, and `role`.
2. Edge Function validates the Supabase user.
3. Edge Function signs an Agora RTC token with `AGORA_APP_CERTIFICATE`.
4. Client joins Agora with the returned token.

If the token endpoint is not configured, the app falls back to tokenless joins for local Agora projects that allow them. Production should use App Certificate tokens.

## Provider Surface

New media work should target `MediaProvider`, `MediaSession`, `MediaTrackState`, and `RoomieMediaConfig`. The default implementation is `AgoraMediaProvider`.

`MediaSession` owns join/leave cleanup, audio/video publish controls, remote subscribe/play helpers, token renewal, and remote user/connection callbacks. Room voice, avatar TV-head video, direct calls, personal-room group video, and theater streaming should all enter Agora through the provider surface. `web/src/voice/agoraManager.ts` is now a compatibility adapter over `defaultMediaProvider`; keep new media code out of legacy Agora-specific service files.

The only frontend file that should import `agora-rtc-sdk-ng` is `web/src/media/agoraMediaProvider.ts`. Treat any new direct SDK import outside that layer as release-blocking unless it is part of a provider implementation.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.roomiekit.io/open-source-starter/media.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
