Skip to content

yashksaini-coder/RTMS-webhook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ RTMS Quickstart

This simple app demonstrates integration with the Zoom Realtime Media Streams SDK for Node.js.

npm docs

πŸ“‹ Setup

The SDK is already included in package dependencies. Install other dependencies:

npm install

βš™οΈ Configuration

Copy the example environment file and fill in your credentials:

cp .env.example .env

Set your Zoom OAuth credentials:

ZM_RTMS_CLIENT=your_client_id
ZM_RTMS_SECRET=your_client_secret

πŸƒβ€β™‚οΈ Running the App

Start the application:

npm start

For webhook testing with ngrok:

ngrok http 8080

Use the generated ngrok URL as your Zoom webhook endpoint. Then, start a meeting to see your data!

🎯 Basic Usage

Here's how you can implement the SDK yourself.

Import the SDK

ES Modules:

import rtms from "@zoom/rtms";

CommonJS:

const rtms = require('@zoom/rtms').default;

Two Usage Patterns

The SDK supports two approaches for connecting to meetings:

1. 🏒 Client-Based Approach (Multiple Meetings)

Use this for handling multiple concurrent meetings:

// Create clients for each meeting
const client = new rtms.Client();

// Set up callbacks
client.onAudioData((buffer, size, timestamp, metadata) => {
  console.log(`🎡 Audio from ${metadata.userName}: ${size} bytes`);
});

client.onVideoData((buffer, size, timestamp, metadata) => {
  console.log(`πŸ“Ή Video from ${metadata.userName}: ${size} bytes`);
});

client.onTranscriptData((buffer, size, timestamp, metadata) => {
  const text = buffer.toString('utf8');
  console.log(`πŸ’¬ ${metadata.userName}: ${text}`);
});

// Join the meeting
client.join({
  meeting_uuid: "meeting-uuid",
  rtms_stream_id: "stream-id", 
  server_urls: "wss://rtms.zoom.us"
});

2. 🌐 Global Singleton Approach (Single Meeting)

Use this for simple single-meeting applications:

// Set up global callbacks
rtms.onAudioData((buffer, size, timestamp, metadata) => {
  console.log(`🎡 Audio from ${metadata.userName}: ${size} bytes`);
});

rtms.onTranscriptData((buffer, size, timestamp, metadata) => {
  const text = buffer.toString('utf8');
  console.log(`πŸ’¬ ${metadata.userName}: ${text}`);
});

// Join the meeting
rtms.join({
  meeting_uuid: "meeting-uuid",
  rtms_stream_id: "stream-id",
  server_urls: "wss://rtms.zoom.us"
});

πŸͺ Webhook Integration

Set up webhook handling to automatically connect when meetings start:

// Listen for Zoom webhook events
rtms.onWebhookEvent(({ event, payload }) => {
  if (event === "meeting.rtms_started") {
    const client = new rtms.Client();
    
    // Configure callbacks
    client.onAudioData((buffer, size, timestamp, metadata) => {
      // Process audio data
    });
    
    // Join using webhook payload
    client.join(payload);
  }
});

πŸ“Š Media Parameter Configuration

Configure audio, video, and deskshare processing parameters before joining:

🎡 Audio Parameters

client.setAudioParams({
  contentType: rtms.AudioContentType.RAW_AUDIO,
  codec: rtms.AudioCodec.OPUS,
  sampleRate: rtms.AudioSampleRate.SR_16K,
  channel: rtms.AudioChannel.STEREO,
  dataOpt: rtms.AudioDataOption.AUDIO_MIXED_STREAM,
  duration: 20,     // 20ms frames
  frameSize: 640    // 16kHz * 2 channels * 20ms
});

πŸ“Ή Video Parameters

client.setVideoParams({
  contentType: rtms.VideoContentType.RAW_VIDEO,
  codec: rtms.VideoCodec.H264,
  resolution: rtms.VideoResolution.HD,
  dataOpt: rtms.VideoDataOption.VIDEO_SINGLE_ACTIVE_STREAM,
  fps: 30
});

πŸ–₯️ Deskshare Parameters

client.setDeskshareParams({
  contentType: rtms.VideoContentType.RAW_VIDEO,
  codec: rtms.VideoCodec.H264,
  resolution: rtms.VideoResolution.FHD,
  dataOpt: rtms.VideoDataOption.VIDEO_SINGLE_ACTIVE_STREAM,
  fps: 15
});

πŸ“ž Available Callbacks

  • onJoinConfirm(reason) - βœ… Join confirmation
  • onSessionUpdate(op, sessionInfo) - πŸ”„ Session state changes
  • onUserUpdate(op, participantInfo) - πŸ‘₯ Participant join/leave
  • onAudioData(buffer, size, timestamp, metadata) - 🎡 Audio data
  • onVideoData(buffer, size, timestamp, metadata) - πŸ“Ή Video data
  • onTranscriptData(buffer, size, timestamp, metadata) - πŸ’¬ Live transcription
  • onLeave(reason) - πŸ‘‹ Meeting ended

πŸ“š API Reference

For complete parameter options and detailed documentation:

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published