Skip to content
Snippets Groups Projects
Commit fcd22690 authored by Simon Döring's avatar Simon Döring
Browse files

Change sender room to be selected through query string

parent 9bf98fac
No related branches found
No related tags found
No related merge requests found
......@@ -8,17 +8,10 @@
<link rel="stylesheet" href="camera-sender.css">
</head>
<body>
<h3 id="room-indicator"></h3>
<div>
Leave the pin empty if the rooms has none set.
</div>
<select id="room-select">
<option value="1001">VNC 1</option>
<option value="1002">VNC 2</option>
<option value="1003">VNC 3</option>
<option value="1004">VNC 4</option>
<option value="1005">VNC 5</option>
<option value="1006">VNC 6</option>
</select>
<select id="res-select">
<option value="lowres">320x240</option>
<option value="lowres-16:9">320x180</option>
......
document.addEventListener('DOMContentLoaded', function() {
var server = 'https://' + window.location.hostname + ':8089/janus';
var janus = null;
......@@ -5,16 +6,13 @@ var videoroomHandle = null;
var room = 1006;
var sendResolution = 'stdres';
var startButton = null;
var stopButton = null;
// const socketNumber = room + 4000;
const socketNumber = 5006;
const socketNumber = room + 4000;
const socket = io('https://' + window.location.hostname, { path: '/socket.io/' + socketNumber });
document.addEventListener('DOMContentLoaded', function() {
startButton = document.getElementById('start');
stopButton = document.getElementById('stop');
var startButton = document.getElementById('start');
var stopButton = document.getElementById('stop');
parseRoomFromURL();
Janus.init({ debug: 'all', callback: function() {
if (!Janus.isWebrtcSupported()) {
......@@ -32,17 +30,14 @@ document.addEventListener('DOMContentLoaded', function() {
Janus.log('Plugin attached! (' + videoroomHandle.getPlugin() + ', id=' + videoroomHandle.getId() + ')');
startButton.onclick = function() {
var roomSelect = document.getElementById('room-select');
var resSelect = document.getElementById('res-select');
var pinInput = document.getElementById('pin-input');
startButton.setAttribute('disabled', '');
roomSelect.setAttribute('disabled', '');
resSelect.setAttribute('disabled', '');
stopButton.removeAttribute('disabled');
stopButton.onclick = function() {
janus.destroy();
};
room = parseInt(roomSelect.value);
sendResolution = resSelect.value;
Janus.log('sendResolution:', sendResolution);
shareCamera(pinInput.value);
......@@ -70,8 +65,6 @@ document.addEventListener('DOMContentLoaded', function() {
if (document.getElementById('camera-preview') == null) {
var video = document.createElement('video');
video.setAttribute('id', 'camera-preview');
video.setAttribute('width', '100%');
video.setAttribute('height', '100%');
video.setAttribute('autoplay', '');
video.setAttribute('playsinline', '');
video.setAttribute('muted', 'muted');
......@@ -97,7 +90,6 @@ document.addEventListener('DOMContentLoaded', function() {
}
});
}});
}, false);
function shareCamera(pin) {
var register = {
......@@ -167,3 +159,19 @@ function handleMessage(msg, jsep) {
videoroomHandle.handleRemoteJsep({ jsep });
}
};
function parseRoomFromURL() {
var urlParams = new URLSearchParams(window.location.search);
var roomParam = urlParams.get('room');
var roomIndicator = document.getElementById('room-indicator');
var appendix = '';
if (roomParam != null && !isNaN(roomParam)) {
room = parseInt(roomParam);
} else {
console.log('Got no valid room in URL search params, using default room ' + room);
appendix = ' (Default value)';
}
roomIndicator.innerText = `VNC ${room - 1000} - Room ${room}` + appendix;
}
}, false);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment