diff --git a/bigbluebutton-html5/client/main.html b/bigbluebutton-html5/client/main.html index d25cb76bee106bc9ed147035415237b7e5351944..80b99b45c461395f8f524cc0362c3173bad77ab7 100755 --- a/bigbluebutton-html5/client/main.html +++ b/bigbluebutton-html5/client/main.html @@ -56,6 +56,6 @@ --> <script src="/html5client/js/bower_components/reconnectingWebsocket/reconnecting-websocket.js"></script> <script src="/html5client/js/bower_components/adapter.js/release/adapter.js"></script> - <script src="/html5client/js/bower_components/kurento-utils/js/kurento-utils.js"></script> + <script src="/html5client/js/bower_components/kurento-utils/dist/kurento-utils.js"></script> <script src="/client/lib/kurento-extension.js"></script> </body> diff --git a/bigbluebutton-html5/imports/ui/components/video-dock/component.jsx b/bigbluebutton-html5/imports/ui/components/video-dock/component.jsx index f4fa2b807250a620f253e37b34ddeec10b1ce8e3..0d602db66f18fca7445ba7fa5a41ef59398900b0 100755 --- a/bigbluebutton-html5/imports/ui/components/video-dock/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/video-dock/component.jsx @@ -87,7 +87,7 @@ function adjustVideos(centerVideos) { videos.attr('height', best.height); } -window.addEventListener('resize', function() { +window.addEventListener('resize', () => { adjustVideos(true); }); diff --git a/labs/kurento-html5-video/lib/video.js b/labs/kurento-html5-video/lib/video.js index f2c225382b4c8c16958dffcb78a190ba9a0ad43c..527a4f7d1417df2f05e99b0c1842481354723af8 100644 --- a/labs/kurento-html5-video/lib/video.js +++ b/labs/kurento-html5-video/lib/video.js @@ -62,6 +62,8 @@ function Video(_ws, _id, _shared) { var id = _id; var shared = _shared; var webRtcEndpoint = null; + var notFlowingTimeout = null; + var notFlowingTimer = 15000; var candidatesQueue = []; @@ -105,10 +107,20 @@ function Video(_ws, _id, _shared) { var flowInOut = function(event) { console.log(' [=] ' + event.type + ' for endpoint ' + id); - if (event.state === 'NOT_FLOWING') { - ws.sendMessage({ id : 'playStop', cameraId : id }); - } else if (event.state === 'FLOWING') { - ws.sendMessage({ id : 'playStart', cameraId : id }); + if (event.state === 'NOT_FLOWING' && event.type === 'MediaFlowInStateChange') { + console.log(" [-] Media not flowing "); + notFlowingTimeout = setTimeout(function() { + console.log(" Timeout! sending playStop for id " + id); + ws.sendMessage({ id : 'playStop', cameraId : id }); + }, notFlowingTimer); + } else if (event.state === 'FLOWING' && event.type === 'MediaFlowInStateChange') { + console.log(" [o] Media flowing "); + if (notFlowingTimeout) { + clearTimeout(notFlowingTimeout); + notFlowingTimeout = null; + } else{ + ws.sendMessage({ id : 'playStart', cameraId : id }); + } } }; @@ -229,4 +241,4 @@ function Video(_ws, _id, _shared) { return this; }; -module.exports = Video; \ No newline at end of file +module.exports = Video; diff --git a/labs/kurento-html5-video/server.js b/labs/kurento-html5-video/server.js index fc290a3a4cc9b29f97123b06d4aa02f63d0a952a..e2e333b032bfa958e723b399e0b03be70a856b32 100755 --- a/labs/kurento-html5-video/server.js +++ b/labs/kurento-html5-video/server.js @@ -53,7 +53,7 @@ wss.on('connection', function(ws) { sessionId = request.session.id + "_" + clientId++; if (!sessions[sessionId]) { - sessions[sessionId] = {}; + sessions[sessionId] = {videos: {}, iceQueue: {}}; } console.log('Connection received with sessionId ' + sessionId); @@ -73,8 +73,8 @@ wss.on('connection', function(ws) { var message = JSON.parse(_message); var video; - if (message.cameraId && sessions[sessionId][message.cameraId]) { - video = sessions[sessionId][message.cameraId]; + if (message.cameraId && sessions[sessionId].videos[message.cameraId]) { + video = sessions[sessionId].videos[message.cameraId]; } switch (message.id) { @@ -84,13 +84,21 @@ wss.on('connection', function(ws) { console.log('[' + message.id + '] connection ' + sessionId); var video = new Video(ws, message.cameraId, message.cameraShared); - sessions[sessionId][message.cameraId] = video; + sessions[sessionId].videos[message.cameraId] = video; video.start(message.sdpOffer, function(error, sdpAnswer) { if (error) { return ws.sendMessage({id : 'error', message : error }); } + // Get ice candidates that arrived before video was created + if (sessions[sessionId].iceQueue) { + var queue = sessions[sessionId].iceQueue[message.cameraId]; + while (queue && queue.length > 0) { + video.onIceCandidate(queue.pop()); + } + } + ws.sendMessage({id : 'startResponse', cameraId: message.cameraId, sdpAnswer : sdpAnswer}); }); @@ -108,12 +116,7 @@ wss.on('connection', function(ws) { break; case 'onIceCandidate': - - if (video) { - video.onIceCandidate(message.candidate); - } else { - console.log(" [iceCandidate] Why is there no video on ICE CANDIDATE?"); - } + onIceCandidate(sessionId, message.cameraId, message.candidate); break; default: @@ -132,10 +135,16 @@ var stopSession = function(sessionId) { for (var i = 0; i < videoIds.length; i++) { - var video = sessions[sessionId][videoIds[i]]; - video.stop(); + var video = sessions[sessionId].videos[videoIds[i]]; + if (video){ + console.log(video); + console.log(videoIds[i]); + video.stop(); + } else { + console.log("Stop session but video was null"); + } - delete sessions[sessionId][videoIds[i]]; + delete sessions[sessionId].videos[videoIds[i]]; } delete sessions[sessionId]; @@ -155,5 +164,15 @@ var stopAll = function() { setTimeout(process.exit, 1000); } +function onIceCandidate(sessionId, id, candidate) { + if (sessions[sessionId][id]) { + sessions[sessionId][id].onIceCandidate(candidate); + } else { + sessions[sessionId].iceQueue = sessions[sessionId].iceQueue || {}; + sessions[sessionId].iceQueue[id] = sessions[sessionId].iceQueue[id] || []; + sessions[sessionId].iceQueue[id].push(candidate); + } +} + process.on('SIGTERM', stopAll); process.on('SIGINT', stopAll);