CloudHub Docs
Download Documents

RTS


Quick start RTS SDK

ready

Run the installation command:

npm install cloudhub-rts-electron-sdk --save

start

1. Obtain SDK

const cloudhubRtsElectron = require('cloudhub-rts-electron-sdk').default

2. Push stream

// Get push object
const rtsPusher = new cloudhubRtsElectron.RtsUpStream();
// Use the push streaming method, see RTS SDK for details
// Equipment collection
rtsPusher.startCamera();
rtsPusher.startMicrophone();
// Set up the camera
const deviceid = $("videoContent").getAttribute("deviceid");
const id = String(deviceid);
rtsPusher.setVideoDevice(id); //Set up video equipment
// Play local video
rtsPusher.setupLocalVideo($("playVideoBox"));  // $("playVideoBox") Element for video playback

// Stop camera capture
rtsPusher.stopCamera(); // Stop camera capture

See the method

Push stream to monitor stream events

...
rtsPusher.onEvent("onPushstateupdated", (data) => {
    console.log("pushstateupdated", data);
});
rtsPusher.onEvent("onFirstlocalaudioframe", (data) => {
    console.log("firstlocalaudioframe", data);
});
rtsPusher.onEvent("onLocalVideoStateChanged", (data) => {
    console.log("localVideoStateChanged", data);
});
rtsPusher.onEvent("onLocalAudioStateChanged", (data) => {
    console.log("localAudioStateChanged", data);
});
...

For details of the event, see

2. Pull flow

// Get the pull object
const rtsPuller = new cloudhubRtsElectron.RtsDownStream();

// Start to pull
rtsPuller.startPull(String(url)) // url is the streaming address
rtsPuller.setupRemoteVideo($("playVideoBox")) // $("playVideoBox") Element for video playback

//  Stop streaming
rtsPuller.removeRemoteVideo() // Remove remote stream
rtsPuller.stopPull() // Stop streaming

See the method

Pull the stream to listen to the stream event

...
rtsPuller.onEvent("onRtsstats", (data) => {
    console.log("rtsstats", data);
});

rtsPuller.onEvent("onPullstateupdated", (data) => {
    console.log("pullstateupdated", data);
});

rtsPuller.onEvent("onVideosizechanged", (data) => {
    console.log("videosizechanged", data);
});

rtsPuller.onEvent("onRemoteVideoStateChanged", (data) => {
    console.log("remoteVideoStateChanged", data);
});
...

For details of the event, see

other instructions

If a 64-bit system is packed with a 32-bit electron

  1. Add the configuration item cloudhub_electron_arch in the root directory

If cloudhub_electron_arch is not configured, follow the system version
If configured, the corresponding addon will be downloaded

{
   "name": "cloudhub-rts-electron-sdk-demo",
   "dependencies": {
      "cloudhub-rts-electron-sdk": "^1.0.0",
   },
   "devDependencies": {
      "electron": "^10.1.3",
   },
   "cloudhub_electron_arch": "ia32"
}
  1. Install 32-bit electron

The installed 32-bit electron version must be consistent with the electron version configured in package.json

npm i electron@10.1.3 --arch=ia32