1.0.11 • Published 6 years ago

janus-videoroom-client-typescript v1.0.11

Weekly downloads
3
License
GPL-3.0
Repository
github
Last release
6 years ago

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: 'no',
   secret: '****',
   pin: '****',
   audiocodec: 'opus',
   videocodec: 'vp8',
   record: false
}).then((result)=>{
    var roomId = result.room;
    ...
});

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
1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago