GoogleMeetInput
Browser audio input provider that joins a Google Meet conference via the Meet Media API (Developer Preview) and emits the meeting's mixed audio.
Defined in: src/providers/io/meet/GoogleMeetInput.ts:419
Browser audio input provider that joins a Google Meet conference via the Meet Media API (Developer Preview) and emits the meeting’s mixed audio.
Remarks
GoogleMeetInput negotiates a WebRTC session directly with Google Meet:
- Creates an
RTCPeerConnection(Google STUN,max-bundle). - Adds exactly AUDIO_TRANSCEIVER_COUNT | 3
recvonlyaudio transceivers (Meet uses 3 virtual audio SSRCs; Opus is negotiated by default). - Opens the required
session-controlandmedia-statsdata channels (bothordered: true) before creating the SDP offer. - POSTs the offer to
{endpoint}/v2beta/{spaceName}:connectActiveConferencewith aBearerOAuth token and applies the returned SDP answer. - Mixes the incoming audio tracks through a shared
AudioContextprocessing node (AudioWorklet preferred,ScriptProcessorNodefallback), downsamples to 16 kHz mono linear16, and emits AudioChunk objects while active.
The media-stats channel is serviced per the Meet reference client: the provider sends nothing until the server’s configuration resource arrives, then uploads allowlisted RTCPeerConnection.getStats() sections at the server-specified interval.
The Meet Media API is receive-only — this provider covers only the 'input' role and cannot inject audio into the conference.
Data-flow diagram:
Meet SFU ──RTP (Opus ×3)──▶ RTCPeerConnection.ontrack
│
MediaStream ──▶ AudioContext (auto-mixed)
│
worklet / script-processor (Float32)
│
downsample 16 kHz → floatTo16BitPCM
│
active && !paused ? callback(chunk) : drop
Example
import { GoogleMeetInput } from 'composite-voice';
const meet = new GoogleMeetInput({
apiKey: 'ya29.a0...', // OAuth token with meetings.conference.media.audio.readonly
spaceName: 'spaces/jQCFfuBOdN5z',
debug: true,
});
meet.onSessionStatus((status) => console.log('Meet session:', status.connectionState));
meet.onAudio((chunk) => console.log(`audio: ${chunk.data.byteLength} bytes`));
await meet.initialize(); // joins the conference
meet.start(); // begin emitting audio chunks
// ...
await meet.dispose(); // sends a leave request and tears down WebRTC
See
- GoogleMeetInputConfig for configuration options
- AudioInputProvider for the interface contract
- GoogleMeetSessionStatus for session lifecycle notifications
Implements
Constructors
Constructor
new GoogleMeetInput(config): GoogleMeetInput;
Defined in: src/providers/io/meet/GoogleMeetInput.ts:522
Creates a new GoogleMeetInput instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
config | GoogleMeetInputConfig | Provider configuration. apiKey (OAuth access token or async factory) and spaceName (spaces/{space}) are required. |
Returns
GoogleMeetInput
Remarks
Construction is side-effect free; the WebRTC session is established in initialize().
Example
const meet = new GoogleMeetInput({
apiKey: async () => getFreshAccessToken(),
spaceName: 'spaces/jQCFfuBOdN5z',
});
Properties
| Property | Modifier | Type | Default value | Description | Defined in |
|---|---|---|---|---|---|
roles | readonly | readonly ProviderRole[] | undefined | Pipeline roles covered by this provider. Remarks The Meet Media API is receive-only, so GoogleMeetInput covers only the 'input' slot. Pair it with NullOutput or another output provider. | src/providers/io/meet/GoogleMeetInput.ts:436 |
type | readonly | ProviderType | 'websocket' | Communication type for this provider. Remarks 'websocket' because the provider holds a persistent WebRTC peer connection (media + data channels) for the lifetime of the session. | src/providers/io/meet/GoogleMeetInput.ts:427 |
Methods
dispose()
dispose(): Promise<void>;
Defined in: src/providers/io/meet/GoogleMeetInput.ts:644
Leave the conference and release all resources.
Returns
Promise<void>
Remarks
Sends a leave request on the session-control channel (per the Meet Media API contract: {"request":{"requestId":n,"leave":{}}}), then closes the data channels, the peer connection, and the AudioContext. The provider may be re-initialized afterwards. Safe to call multiple times.
Implementation of
getMetadata()
getMetadata(): AudioMetadata;
Defined in: src/providers/io/meet/GoogleMeetInput.ts:750
Get the audio format metadata for the emitted audio.
Returns
AudioMetadata — linear16, 16000 Hz, 1 channel, 16-bit.
Remarks
The provider always emits 16 kHz mono 16-bit linear PCM regardless of the AudioContext hardware rate (audio is downsampled internally). Used by the pipeline to auto-configure the STT provider.
Implementation of
AudioInputProvider.getMetadata
getSessionStatus()
getSessionStatus():
| GoogleMeetSessionStatus
| null;
Defined in: src/providers/io/meet/GoogleMeetInput.ts:792
Get the most recent session status received from the server.
Returns
| GoogleMeetSessionStatus | null
The latest GoogleMeetSessionStatus, or null if no status has been received yet.
initialize()
initialize(): Promise<void>;
Defined in: src/providers/io/meet/GoogleMeetInput.ts:549
Join the active conference: negotiate the WebRTC session with the Meet Media API and set up the audio mixing pipeline.
Returns
Promise<void>
Remarks
Performs the full connect flow described in the class documentation. The conference identified by GoogleMeetInputConfig.spaceName must be active, and the OAuth token must carry a Meet Media API audio scope. If already initialized, this is a no-op.
Throws
ProviderInitializationError when configuration is invalid, RTCPeerConnection is unavailable (non-browser environment), or WebRTC setup fails.
Throws
ProviderConnectionError when the connectActiveConference request is rejected (non-2xx response or a response without an SDP answer).
Implementation of
isActive()
isActive(): boolean;
Defined in: src/providers/io/meet/GoogleMeetInput.ts:722
Check whether the provider is actively emitting audio.
Returns
boolean
true when started and not paused.
Implementation of
isReady()
isReady(): boolean;
Defined in: src/providers/io/meet/GoogleMeetInput.ts:662
Check whether the provider is connected to the conference.
Returns
boolean
true after initialize completes and until dispose is called or the server disconnects the session.
Implementation of
onAudio()
onAudio(callback): void;
Defined in: src/providers/io/meet/GoogleMeetInput.ts:736
Register a callback to receive audio chunks.
Parameters
| Parameter | Type | Description |
|---|---|---|
callback | (chunk) => void | Function invoked with each AudioChunk of mixed 16 kHz mono linear16 meeting audio. |
Returns
void
Remarks
Only one callback can be registered at a time; subsequent calls replace the previous callback.
Implementation of
onSessionStatus()
onSessionStatus(callback): void;
Defined in: src/providers/io/meet/GoogleMeetInput.ts:782
Register a callback for Meet session status updates.
Parameters
| Parameter | Type | Description |
|---|---|---|
callback | (status) => void | Function invoked with each GoogleMeetSessionStatus. |
Returns
void
Remarks
Invoked whenever the server pushes a sessionStatus resource on the session-control data channel — on admission (STATE_WAITING → STATE_JOINED) and on disconnect (STATE_DISCONNECTED, with a GoogleMeetDisconnectReason). When the session disconnects, the provider automatically stops emission and tears down the WebRTC session.
Example
meet.onSessionStatus((status) => {
if (status.connectionState === 'STATE_DISCONNECTED') {
console.log('Meeting over:', status.disconnectReason);
}
});
pause()
pause(): void;
Defined in: src/providers/io/meet/GoogleMeetInput.ts:700
Temporarily pause audio emission.
Returns
void
Remarks
Used by the turn-taking system during TTS playback. Audio received while paused is silently dropped.
Implementation of
resume()
resume(): void;
Defined in: src/providers/io/meet/GoogleMeetInput.ts:711
Resume audio emission after a pause.
Returns
void
See
Implementation of
start()
start(): void;
Defined in: src/providers/io/meet/GoogleMeetInput.ts:676
Start emitting audio chunks.
Returns
void
Remarks
Meeting audio received while stopped is silently dropped (the WebRTC session keeps flowing; only emission is gated). Must be called after initialize.
Implementation of
stop()
stop(): void;
Defined in: src/providers/io/meet/GoogleMeetInput.ts:688
Stop emitting audio chunks.
Returns
void
Remarks
The WebRTC session stays connected — call start to resume emission, or dispose to leave the conference.