Janus Media Server
May 01, 2020
1 min

janus media server

Webrtc provide peer to peer communication between browser. if there are more than 2 people need to create more webrtc peer connection between browser. it is not the best way to handle communication between the peers. to solve this problem media server play the role. browser create peer connection with server and communicate between browser and server.

There are many webrtc media server. in this we will look at janus media server. Janus is general webrtc media server it bit complex, if you do not familiar with webrtc. They provide janus javascript library to web developers.

how work?

They provide plugin mechanism to enable the janus feature.

Janus.init({debug: "all", callback: function() {
      // Make sure the browser supports WebRTC
      // Create session
        janusRoom = new Janus(
              server: JANUS_SERVER_URL,
              iceServers: ICE_SERVERS,
              success: function() {
                  // Attach to VideoRoom plugin
                          plugin: "janus.plugin.videoroom",

we have to choose if we want subscribe or publish. if subscribe we only receive media.

const register = { "request": "join", "room": myroom, "ptype": "publisher", "display": reg };

they provide basic function createOffer(),createAnswer(), it is same as webrtc function. it is handle the sdx exchange

                            jsep: jsep,
                            // Add data:true here if you want to subscribe to datachannels as well
                            // (obviously only works if the publisher offered them in the first place)
                            media: { audioSend: false, videoSend: false },  // We want recvonly audio/video
                            success: function(jsep) {
                                console.log("Got SDP!", jsep);
                                let body = { request: "start", room: myroom };
                                remoteFeed.send({ message: body, jsep: jsep });

after that we can start communication.



Related Posts

How to install Janus Gateway in Ubuntu Server 18.04
July 15, 2021
1 min