Skip to content
This repository has been archived by the owner on Aug 9, 2022. It is now read-only.

ricohapi/ricoh-cloud-sdk-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RICOH Cloud SDK for JavaScript

JavaScript client library for RICOH Cloud API.

Installation

$ git clone https://github.com/ricohapi/ricoh-cloud-sdk-js.git
$ copy ricoh-cloud-sdk-js/src/sfu/sfusdk.js /path/to/your-application

SDK Usage

WebRTC SFU

Broadcast Videos

Initialize SFUClient with <Room ID>.

const sfu = new SFUClient('up', <Room ID>);

Use setMedia to set audio/video codecs and stream obtained with getUserMedia(). You can also set a handler for close events with onclose.

sfu.setMedia({ codec_type: 'VP9', bit_rate: 1000 }, { codec_type: 'OPUS' }, stream);
sfu.onclose = () => {
  // Do something.
};

Call connect() to start broadcasting.

sfu.connect(<URL>, <Access Token>);

Watch Videos

Initialize SFUClient with <Room ID>.

const sfu = new SFUClient('down', <Room ID>);

Use onaddstream to set a remote stream object to your media and use setMedia to set audio/video codecs. You can also set a handler for close events with onclose.

sfu.onaddstream = event => {
  // Set event.streams[0] to the srcObject attribute of your media.
};
sfu.setMedia({ codec_type: 'VP9' }, { codec_type: 'OPUS' });
sfu.onclose = () => {
  // Do something.
};

Call connect() to start watching videos.

sfu.connect(<URL>, <Access Token>);

Stop Broadcasting / Watching Videos

Use disconnect() to stop broadcasting or watching videos.

sfu.disconnect();

Sample Codes

See Also