From edb317740843720c9bb979e030c12dc346b3c6a5 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard <dr@jones.dk> Date: Sun, 26 Mar 2017 10:52:18 +0200 Subject: Initial live-video support. --- js/app/live-video.js | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 js/app/live-video.js (limited to 'js/app') diff --git a/js/app/live-video.js b/js/app/live-video.js new file mode 100644 index 0000000..f39e801 --- /dev/null +++ b/js/app/live-video.js @@ -0,0 +1,44 @@ +var websocket_server = null; +if(window.location.protocol === 'http:') + websocket_server = "ws://" + window.location.hostname + "/janus-ws"; +else + websocket_server = "wss://" + window.location.hostname + "/janus-ws"; + +var janus = null; +var streaming = null; + +Janus.init({callback: function() { + janus = new Janus( + { + server: [websocket_server, "/janus"], + iceServers: [{url: "turn:turn.homebase.dk", username: "myturn", credential: "notsecure"}], + ipv6: false, + success: function() { + janus.attach( + { + plugin: "janus.plugin.streaming", + opaqueId: "streaming-"+Janus.randomString(12), + success: function(pluginHandle) { + streaming = pluginHandle; + streaming.send({"message": { "request": "watch", id: 1}}); + }, + onmessage: function(msg, jsep) { + if(jsep !== undefined && jsep !== null) { + streaming.createAnswer( + { + jsep: jsep, + media: { audioSend: false, videoSend: false }, + success: function(jsep) { + var body = { "request": "start" }; + streaming.send({"message": body, "jsep": jsep}); + }, + }); + } + }, + onremotestream: function(stream) { + Janus.attachMediaStream(document.getElementById('live-video'), stream); + }, + }); + }, + }); +}}); -- cgit v1.2.3