You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Go to file
Sipwise Jenkins Builder c2af42d6f1
Release new version 5.0.0.0+0~mr9.5.9.1
2 years ago
debian Release new version 5.0.0.0+0~mr9.5.9.1 2 years ago
src TT#111150 Remove unused requires 5 years ago
t TT#118659 Switch Dockerfile from Debian buster to bullseye 5 years ago
test TT#66572 Prevent uncaught rejections on websocket timeout #19 6 years ago
.editorconfig TT#2723 Implement janus-client JS library to communicate from App to Janus 9 years ago
.gitignore TT#2723 Implement janus-client JS library to communicate from App to Janus 9 years ago
.gitreview TT#2722 Add .gitreview 9 years ago
.npmrc TT#64704 Force npm cli to download packages from sipwise npm mirror 7 years ago
CHANGELOG.md TT#113752 Integrate PR #18 5 years ago
LICENSE TT#33392 Added license file 8 years ago
Makefile TT#4931 Initial empty package to start using Jenkins on Gerrit 9 years ago
README.md TT#107204 Document how to delete a video room 5 years ago
package-lock.json TT#113752 Integrate PR #18 5 years ago
package.json TT#113752 Integrate PR #18 5 years ago

README.md

Conferencing with Janus WebRTC Gateway

Node.js client that implements a subset of the WebSocket interface of the Janus WebRTC Gateway.

Note: For now it supports the videoroom plugin only.

Setup janus client

var JanusClient = require('janus-videoroom-client').Janus;

Establish connection to the Janus WebSocket API

1. Create client

Without authentication

var client = new JanusClient({
    url: 'ws://localhost:8188'
});

Token based authentication

var client = new JanusClient({
    url: 'ws://localhost:8188',
    token: 'yourToken'
});

Static secret authentication

var client = new JanusClient({
    url: 'ws://localhost:8188',
    apiSecret: 'yourStaticSecret'
});

2. Register events connected, disconnected, error

client.onConnected(()=>{
    client.createSession().then((session)=>{
        ...
    }).catch((err)=>{
        ...
    })
});
client.onDisconnected(()=>{
    
});
client.onError((err)=>{
    
});

3. Call connect method

client.connect();

Create a new janus session

client.createSession().then((session)=>{
    ...
});

Create a new videoroom handle

client.createSession().then((session)=>{
    return session.videoRoom().createVideoRoomHandle();
}).then((videoRoomHandle)=>{
    ...
});

Get default videoroom handle

client.createSession().then((session)=>{
    return session.videoRoom().defaultHandle();
}).then((videoRoomHandle)=>{
    ...
});

Create a new videoroom

videoRoomHandle.create({
   publishers: 3,
   is_private: false,
   secret: '****',
   pin: '****',
   audiocodec: 'opus',
   videocodec: 'vp8',
   record: false
}).then((result)=>{
    var roomId = result.room;
    ...
});

Delete a videoroom

videoRoomHandle.destroy({
   room: roomId
}).then((result) => {
  ...
}).catch((err) => {
  ...
});

Publish media stream

session.videoRoom().publishFeed(room, offerSdp).then((publisherHandle)=>{
    var answerSdp = publisherHandle.getAnswer();
    ...
});
publisherHandle.trickle(candidate).then(()=>{
    ...
});

Subscribe to a media stream

session.videoRoom().listenFeed(room, feed).then((listenerHandle)=>{
    var offerSdp = listenerHandle.getOffer();
    ...
});
listenerHandle.trickle(candidate).then(()=>{
    ...
});
listenerHandle.setRemoteAnswer(answerSdp).then(()=>{
    ...
});

Get current published media streams

session.videoRoom().getFeeds(room).then((feeds)=>{
    for(let feed of feeds) {
        ...
    }
});

Run tests

npm test