forked from mpromonet/webrtc-streamer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjoinxmpproom.js
executable file
·58 lines (47 loc) · 1.75 KB
/
joinxmpproom.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env node
/*
* NodeJS example to send a webrtc-streamer stream to jitsi
*/
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
// decode arguments
if (process.argv.length <= 2) {
console.log("Usage: " + __filename + " <webrtc-streamer url> <videourl>");
process.exit(-1);
}
var webrtcstreamerurl = process.argv[2];
console.log("webrtcstreamerurl: " + webrtcstreamerurl);
var videourl = process.argv[3];
console.log("videourl: " + videourl);
var jsdom = require("jsdom");
const { JSDOM } = jsdom;
const { window } = new JSDOM("");
global.jquery = require("jquery")(window);
global.$ = (selector,context) => {return new jquery.fn.init(selector,context); };
global.window = window;
global.document = window.document;
global.DOMParser = window.document.DOMParser;
global.XMLHttpRequest = window.XMLHttpRequest;
var strophe = require("strophe.js");
global.Strophe = strophe.Strophe;
global.$iq = strophe.$iq;
//global.Strophe.log = console.log;
require("strophejs-plugin-disco");
require("strophejs-plugin-muc");
global.SDP = require("strophe.jingle/strophe.jingle.sdp.js");
request = require("then-request");
var XMPPVideoRoom = require("./html/xmppvideoroom.js");
// get configuration from webrtc-streamer using janusvideoroom.json
request( "GET", webrtcstreamerurl + "/xmppvideoroom.json" ).done(
function (response) {
if (response.statusCode === 200) {
console.log("HTTP answer:"+ response.body);
eval("{" + response.body + "}");
var xmpp = new XMPPVideoRoom(xmppRoomConfig.url, webrtcstreamerurl);
var username = "user"+Math.random().toString(36).slice(2);
console.log("join " + xmppRoomConfig.roomId + "/" + username);
xmpp.join(xmppRoomConfig.roomId,videourl,username);
} else {
console.log("HTTP code:"+ response.statusCode);
}
}
);