GithubHelp home page GithubHelp logo

pleymor / janus-client Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sipwise/janus-client

0.0 0.0 0.0 208 KB

javascript library to implement the websocket interface towards the janus server

License: GNU General Public License v3.0

JavaScript 97.45% Shell 0.58% Makefile 0.01% Dockerfile 1.95%

janus-client's Introduction

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

janus-client's People

Contributors

hpherzog avatar sipwise-jenkins avatar taurus-forever avatar guillemj avatar sergiik avatar linuxmaniac avatar cedbale avatar kylefoleyimajion avatar robgonnella avatar lu6fer avatar s-ol avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.