Bridge Server Architecture & Session Management
Build a server that sits between MeetStream and your AI stack. The bridge receives real-time meeting audio, manages one session per MeetStream connection, routes audio through your processing pipeline, and sends responses (audio, chat, images) back into the meeting.
Architecture

The bridge server exposes two WebSocket endpoints. Each MeetStream connection opens one to each:
Each MeetStream connection is identified by a bot_id. The session manager maintains one AI session per bot_id, created on first connection and torn down when both WebSockets disconnect.
Session Lifecycle

Key rules:
- Either channel can arrive first. The session is created on whichever connects first.
- Both channels share the same
bot_idand the same AI session. - Cleanup happens when both WebSockets have disconnected for a given
bot_id.
Core Components
1. Session Manager
The session manager is the central coordinator. It maps bot_id to:
- An AI session (your STT/LLM/TTS pipeline)
- References to the audio and control WebSockets
- Per-session locks to prevent race conditions during creation
2. Audio Decoder
Decodes the binary frame format from MeetStream. See Live Audio Capture & Frame Decoding for the full specification.
Google Meet and Teams send 0x01 frames at 48 kHz. Zoom sends 0x04 frames, which carry the sample rate and the channel count in the header. The decoder returns the sample rate with the audio.
3. Audio Resampler
Google Meet and Teams audio arrives at 48 kHz. Zoom audio arrives at the rate in the frame header (32 kHz). Resample to the rate of your model before you send audio to it (for example, 24 kHz for OpenAI Realtime or 16 kHz for Whisper), and resample back to 48 kHz before you send audio to the meeting.
4. Speaker Filter
Filter out MeetStream’s own audio to prevent echo/feedback loops. The display name appears in the speaker_name field.
5. Command Sender
Helper functions to build outbound commands for the control channel. See Meeting Control & Command Patterns for the full command reference.
On Zoom and Teams, send resume_audio after an interrupt. Google Meet ignores resume_audio, so you can send it on all platforms.
WebSocket Endpoints
Audio Endpoint: /bridge/audio
Receives binary audio frames from the meeting. Decodes speaker metadata, filters out MeetStream’s own audio, and routes PCM to your AI pipeline.
Control Endpoint: /bridge
Your AI pipeline sends commands (sendaudio, sendmsg, interrupt, resume_audio) over this connection. MeetStream sends the ready handshake and command acknowledgements.
Event Pump
The event pump is a background task that continuously reads output from your AI pipeline and forwards it to the meeting through the control WebSocket. This is the outbound half of the bridge.
Note: The event types above (
audio,audio_interrupted,text_response) are illustrative. Replace them with whatever events your AI framework emits. Keep theresume_audiostep: on Zoom and Teams, sendresume_audioafter aninterrupt. Google Meet ignoresresume_audio, so you can send it on all platforms.
Full Working Skeleton
A minimal but complete bridge server. Replace the YourAISession class with your actual AI pipeline.
Run:
Connecting MeetStream
When creating a MeetStream session, point both WebSocket URLs at your bridge server:
Both connections carry the same bot_id in their handshake, so the session manager can link them together.
Design Decisions
Why two separate WebSocket connections?
Separation of concerns. The audio channel is high-throughput binary data (hundreds of frames per minute). The control channel is low-frequency JSON commands. Splitting them avoids head-of-line blocking and makes it easier to handle each independently.
Why does the decoder check byte 0?
Google Meet and Teams send 0x01 frames at 48 kHz. Zoom sends 0x04 frames that carry the sample rate in the header. Reading byte 0 lets one decoder handle every platform and skip frame types that it does not know.
Why lock on session creation?
Both WebSocket connections race to ensure_session(). Without a lock, two AI sessions could be created for the same bot_id. The async lock ensures exactly one session is created.
Why clean up only when both connections close?
A single reconnecting WebSocket shouldn’t destroy the running session. The session stays alive as long as at least one channel is connected.
Why resample instead of sending at the model's native rate?
Meeting audio arrives at 48 kHz from Google Meet and Teams and at 32 kHz from Zoom. Your model can need 16 kHz or 24 kHz. Send audio back to the meeting at 48 kHz. The bridge handles both conversions, so neither MeetStream nor your model needs to know about the other’s sample rate.
Related Documentation
- Live Audio Capture & Frame Decoding: binary frame formats (
0x01and0x04), decode examples in 4 languages, FAQ - Meeting Control & Command Patterns: full command reference for
sendaudio,sendmsg,interrupt,resume_audio,sendimg,sendimg_url
