REALLY respect recorded=false authority when recording on HTML5

This commit is contained in:
Lucas Fialho Zawacki 2018-04-26 21:29:46 +00:00
parent a2b670174b
commit 61e08b4396
8 changed files with 50 additions and 22 deletions

View File

@ -10,6 +10,7 @@
const BigBlueButtonGW = require('../bbb/pubsub/bbb-gw');
const C = require('../bbb/messages/Constants');
const Logger = require('../utils/Logger');
const isRecordedStream = require('../utils/Utils.js').isRecordedStream;
module.exports = class BaseManager {
constructor (connectionChannel, additionalChannels = [], logPrefix = C.BASE_MANAGER_PREFIX) {
@ -25,8 +26,9 @@ module.exports = class BaseManager {
}
_trackRecordedStream () {
this._bbbGW.on(C.STREAM_IS_RECORDED, (stream) => {
Logger.info("[BaseManager] Server notifies that stream ", stream, " is recorded");
this._bbbGW.on(C.USER_CAM_BROADCAST_STARTED_2x, (streamUrl) => {
Logger.info("[BaseManager] Server notifies that stream ", streamUrl, " is recorded");
let stream = isRecordedStream(streamUrl);
this.setStreamAsRecorded(stream);
});
}

View File

@ -58,7 +58,7 @@ const config = require('config');
STOP_TRANSCODER_REQ_2x: "StopTranscoderSysReqMsg",
STOP_TRANSCODER_RESP_2x: "StopTranscoderSysRespMsg",
USER_CAM_BROADCAST_STARTED_2X: "UserBroadcastCamStartMsg",
USER_CAM_BROADCAST_STARTED_2x: "UserBroadcastCamStartMsg",
USER_CAM_BROADCAST_STOPPED_2x: "UserBroadcastCamStopMsg",
STREAM_IS_RECORDED: "StreamIsRecordedMsg",

View File

@ -87,15 +87,7 @@ module.exports = class BigBlueButtonGW extends EventEmitter {
this.emit(C.STOP_TRANSCODER_RESP_2x, payload);
break;
case C.USER_CAM_BROADCAST_STARTED_2x:
const flashStream = /^([A-z0-9]+)-([A-z0-9]+)-([A-z0-9+])(-recorded)?$/;
const recordedStream = /^(_A-z0-9]+)-recorded$/;
if (!payload[C.STREAM_URL].match(flashStream)) {
let res = payload[C.STREAM_URL].match(recordedStream);
if (res) {
this.emit(C.STREAM_IS_RECORDED, res[0]);
}
}
this.emit(C.USER_CAM_BROADCAST_STARTED_2x, payload[C.STREAM_URL]);
break;
// SCREENSHARE

View File

@ -71,14 +71,15 @@ module.exports = class ConnectionManager {
const screenshare = await this._bbbGW.addSubscribeChannel(C.FROM_SCREENSHARE);
const video = await this._bbbGW.addSubscribeChannel(C.FROM_VIDEO);
const audio = await this._bbbGW.addSubscribeChannel(C.FROM_AUDIO);
const toAkka = await this._bbbGW.addSubscribeChannel(C.TO_AKKA_APPS);
screenshare.on(C.REDIS_MESSAGE, (data) => {
const emitFunk = (data) => {
this._emitter.emit('response', data);
});
};
video.on(C.REDIS_MESSAGE, (data) => {
this._emitter.emit('response', data);
});
toAkka.on(C.REDIS_MESSAGE, emitFunk);
screenshare.on(C.REDIS_MESSAGE, emitFunk);
video.on(C.REDIS_MESSAGE, emitFunk);
Logger.info('[ConnectionManager] Successfully subscribed to processes redis channels');
}

View File

@ -15,3 +15,24 @@ exports.hrTime = function () {
return t[0]*1000 + parseInt(t[1]/1000000);
}
/*
* isRecordedStream
*
* Returns the stream id if it's not a flash stream and is recorded
*/
exports.isRecordedStream = function (stream) {
const flashStream = /^([A-z0-9]+)-([A-z0-9]+)-([A-z0-9+])(-recorded)?$/;
const recordedStream = /^([_A-z0-9]+)-recorded$/;
if (!stream.match(flashStream)) {
let res = stream.match(recordedStream);
console.log(res);
if (res) {
return res[1];
}
}
return null;
}

View File

@ -18,14 +18,26 @@ module.exports = class VideoManager extends BaseManager {
this.messageFactory(this._onMessage);
}
_findByIdAndRole (id, role) {
let sesh = null;
let keys = Object.keys(this._sessions);
keys.forEach((sessionId) => {
let session = this._sessions[sessionId];
if (sessionId === (session.connectionId + id + '-' + role)) {
sesh = session;
}
});
return sesh;
}
setStreamAsRecorded (id) {
let video = this._sessions[id];
let video = this._findByIdAndRole(id, 'share');
if (video) {
Logger.info("[VideoManager] Setting ", id, " as recorded");
video.setRecorded();
video.setStreamAsRecorded();
} else {
Logger.warn("[VideoManager] Tryed to set stream to recorded but ", id, " has no session!");
Logger.warn("[VideoManager] Tried to set stream to recorded but ", id, " has no session!");
}
}

View File

@ -4,7 +4,7 @@ const VideoManager= require('./VideoManager');
const BaseProcess = require('../base/BaseProcess');
const C = require('../bbb/messages/Constants');
const manager = new VideoManager(C.TO_VIDEO, [], C.VIDEO_MANAGER_PREFIX);
const manager = new VideoManager(C.TO_VIDEO, [C.TO_AKKA_APPS], C.VIDEO_MANAGER_PREFIX);
const newProcess = new BaseProcess(manager, C.VIDEO_PROCESS_PREFIX);
newProcess.start();

View File

@ -176,7 +176,7 @@ module.exports = class Video extends EventEmitter {
}
shouldRecord () {
this.streamRecorded && this.shared && config.get('recordWebcams');
return this.streamRecorded && this.shared && config.get('recordWebcams');
}
async startRecording() {