Skip to content
Snippets Groups Projects
Commit 4dce4676 authored by Lucas Fialho Zawacki's avatar Lucas Fialho Zawacki
Browse files

Wait a while before closing streams if media stops flowing on bbb-webrtc-sfu

parent c36f322f
No related branches found
No related tags found
No related merge requests found
......@@ -23,6 +23,7 @@ module.exports = class Video {
this.iceQueue = null;
this.candidatesQueue = [];
this.notFlowingTimeout = null;
}
onIceCandidate (_candidate) {
......@@ -80,15 +81,26 @@ module.exports = class Video {
Logger.info('[video] ' + msEvent.type + '[' + msEvent.state + ']' + ' for media session', event.id, "for video", this.id);
if (msEvent.state === 'NOT_FLOWING') {
this.bbbGW.publish(JSON.stringify({
connectionId: this.sessionId,
type: 'video',
role: this.role,
id : 'playStop',
cameraId: this.id,
}), C.FROM_VIDEO);
Logger.warn("Setting up a timeout for " + this.sessionId + " camera " + this.id);
if (!this.notFlowingTimeout) {
this.notFlowingTimeout = setTimeout(() => {
this.bbbGW.publish(JSON.stringify({
connectionId: this.sessionId,
type: 'video',
role: this.role,
id : 'playStop',
cameraId: this.id,
}), C.FROM_VIDEO);
}, config.get('mediaFlowTimeoutDuration'));
}
}
else if (msEvent.state === 'FLOWING') {
if (this.notFlowingTimeout) {
Logger.warn("Received a media flow before stopping " + this.sessionId + " camera " + this.id);
clearTimeout(this.notFlowingTimeout);
this.notFlowingTimeout = null;
}
this.bbbGW.publish(JSON.stringify({
connectionId: this.sessionId,
type: 'video',
......@@ -152,6 +164,12 @@ module.exports = class Video {
if (this.shared) {
sharedWebcams[this.id] = null;
}
if (this.notFlowingTimeout) {
clearTimeout(this.notFlowingTimeout);
this.notFlowingTimeout = null;
}
this._candidatesQueue = null;
Promise.resolve();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment