From 50b8bbce72400f9f5a7e4fe031c72aa8acc85199 Mon Sep 17 00:00:00 2001 From: prlanzarin Date: Thu, 12 Apr 2018 17:26:05 +0000 Subject: [PATCH] Refactored media-server element checkings --- .../lib/mcs-core/lib/media/media-server.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/labs/bbb-webrtc-sfu/lib/mcs-core/lib/media/media-server.js b/labs/bbb-webrtc-sfu/lib/mcs-core/lib/media/media-server.js index 078dad8ed8..7ec513cf3b 100644 --- a/labs/bbb-webrtc-sfu/lib/mcs-core/lib/media/media-server.js +++ b/labs/bbb-webrtc-sfu/lib/mcs-core/lib/media/media-server.js @@ -239,7 +239,7 @@ module.exports = class MediaServer extends EventEmitter { let mediaElement = this._mediaElements[elementId]; let kurentoCandidate = mediaServerClient.getComplexType('IceCandidate')(candidate); - if (mediaElement != null && candidate != null) { + if (!mediaElement && !candidate) { mediaElement.addIceCandidate(candidate); Logger.debug("[mcs-media] Added ICE candidate for => " + elementId); return Promise.resolve(); @@ -254,7 +254,7 @@ module.exports = class MediaServer extends EventEmitter { let mediaElement = this._mediaElements[elementId]; return new Promise((resolve, reject) => { - if (mediaElement != null) { + if (!mediaElement) { mediaElement.gatherCandidates((error) => { if (error) { error = this._handleError(error); @@ -273,7 +273,7 @@ module.exports = class MediaServer extends EventEmitter { setInputBandwidth (elementId, min, max) { let mediaElement = this._mediaElements[elementId]; - if (mediaElement != null) { + if (!mediaElement) { endpoint.setMinVideoRecvBandwidth(min); endpoint.setMaxVideoRecvBandwidth(max); } else { @@ -284,7 +284,7 @@ module.exports = class MediaServer extends EventEmitter { setOutputBandwidth (endpoint, min, max) { let mediaElement = this._mediaElements[elementId]; - if (mediaElement != null) { + if (!mediaElement) { endpoint.setMinVideoSendBandwidth(min); endpoint.setMaxVideoSendBandwidth(max); } else { @@ -295,7 +295,7 @@ module.exports = class MediaServer extends EventEmitter { setOutputBitrate (endpoint, min, max) { let mediaElement = this._mediaElements[elementId]; - if (mediaElement != null) { + if (!mediaElement) { endpoint.setMinOutputBitrate(min); endpoint.setMaxOutputBitrate(max); } else { @@ -307,7 +307,7 @@ module.exports = class MediaServer extends EventEmitter { let mediaElement = this._mediaElements[elementId]; return new Promise((resolve, reject) => { - if (mediaElement != null) { + if (!mediaElement) { mediaElement.processOffer(sdpOffer, (error, answer) => { if (error) { error = this._handleError(error); @@ -352,7 +352,7 @@ module.exports = class MediaServer extends EventEmitter { addMediaEventListener (eventTag, elementId) { let mediaElement = this._mediaElements[elementId]; // TODO event type validator - if (mediaElement != null) { + if (!mediaElement) { Logger.debug('[mcs-media] Adding media state listener [' + eventTag + '] for ' + elementId); mediaElement.on(eventTag, (event) => { if (eventTag === C.EVENT.MEDIA_STATE.ICE) {