var server = null; if(window.location.protocol === 'http:') server = "http://192.168.131.21:8088/janus"; else server = "https://192.168.131.21:8089/janus"; var janus = null; var mixertest = null; var opaqueId = "audiobridgetest-"+Janus.randomString(12); var spinner = null; var myroom = 1001; // Demo room var myid = null; var webrtcUp = false; var audioenabled = false; $(document).ready(function() { Janus.init({debug: "all", callback: function() { janus = new Janus( { server: server, success: function() { janus.attach( { plugin: "janus.plugin.audiobridge", opaqueId: opaqueId, success: function(pluginHandle) { mixertest = pluginHandle; registerUsername(); $('#start').removeAttr('disabled').html("Stop") .click(function() { $(this).attr('disabled', true); janus.destroy(); }); }, error: function(error) { Janus.error(" -- Error attaching plugin...", error); }, consentDialog: function(on) { Janus.debug("Consent dialog should be " + (on ? "on" : "off") + " now"); }, iceState: function(state) { Janus.log("ICE state changed to " + state); }, mediaState: function(medium, on) { Janus.log("Janus " + (on ? "started" : "stopped") + " receiving our " + medium); }, webrtcState: function(on) { Janus.log("Janus says our WebRTC PeerConnection is " + (on ? "up" : "down") + " now"); }, onmessage: function(msg, jsep) { Janus.debug(" ::: Got a message :::", msg); var event = msg["audiobridge"]; Janus.debug("Event: " + event); if(event) { if(event === "joined") { // Successfully joined, negotiate WebRTC now if(msg["id"]) { myid = msg["id"]; Janus.log("Successfully joined room " + msg["room"] + " with ID " + myid); if(!webrtcUp) { webrtcUp = true; // Publish our stream mixertest.createOffer( { media: { video: false}, // This is an audio only room success: function(jsep) { Janus.debug("Got SDP!", jsep); var publish = { request: "configure", muted: false }; mixertest.send({ message: publish, jsep: jsep }); }, error: function(error) { Janus.error("WebRTC error:", error); } }); } } } } if(jsep) { Janus.debug("Handling SDP as well...", jsep); mixertest.handleRemoteJsep({ jsep: jsep }); } }, onlocalstream: function(stream) { Janus.debug(" ::: Got a local stream :::", stream); }, onremotestream: function(stream) { if($('#roomaudio').length === 0) { $('#mixedaudio').append('