Skip to content

Commit

Permalink
#2458 Remove not used isUserStream RTC method. Move isUserStreamById …
Browse files Browse the repository at this point in the history
…RTC method into RTCUtils in order to fix circular dependency issue.

Require cycle: lib/lib-jitsi-meet/modules/RTC/RTC.js -> lib/lib-jitsi-meet/modules/RTC/TraceablePeerConnection.js -> lib/lib-jitsi-meet/modules/RTC/RTC.js
  • Loading branch information
Romick2005 committed Feb 15, 2024
1 parent 3898d7a commit e9ba31b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 43 deletions.
33 changes: 0 additions & 33 deletions modules/RTC/RTC.js
Original file line number Diff line number Diff line change
Expand Up @@ -654,39 +654,6 @@ export default class RTC extends Listenable {
return RTCUtils.setAudioOutputDevice(deviceId);
}

/**
* Returns <tt>true<tt/> if given WebRTC MediaStream is considered a valid
* "user" stream which means that it's not a "receive only" stream nor a
* "mixed" JVB stream.
*
* Clients that implement Unified Plan, such as Firefox use recvonly
* "streams/channels/tracks" for receiving remote stream/tracks, as opposed
* to Plan B where there are only 3 channels: audio, video and data.
*
* @param {MediaStream} stream The WebRTC MediaStream instance.
* @returns {boolean}
*/
static isUserStream(stream) {
return RTC.isUserStreamById(stream.id);
}

/**
* Returns <tt>true<tt/> if a WebRTC MediaStream identified by given stream
* ID is considered a valid "user" stream which means that it's not a
* "receive only" stream nor a "mixed" JVB stream.
*
* Clients that implement Unified Plan, such as Firefox use recvonly
* "streams/channels/tracks" for receiving remote stream/tracks, as opposed
* to Plan B where there are only 3 channels: audio, video and data.
*
* @param {string} streamId The id of WebRTC MediaStream.
* @returns {boolean}
*/
static isUserStreamById(streamId) {
return streamId && streamId !== 'mixedmslabel'
&& streamId !== 'default';
}

/**
* Allows to receive list of available cameras/microphones.
* @param {function} callback Would receive array of devices as an
Expand Down
24 changes: 20 additions & 4 deletions modules/RTC/RTCUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -834,16 +834,32 @@ class RTCUtils extends Listenable {
getEventDataForActiveDevice(device) {
const deviceList = [];
const deviceData = {
'deviceId': device.deviceId,
'kind': device.kind,
'label': device.label,
'groupId': device.groupId
deviceId: device.deviceId,
kind: device.kind,
label: device.label,
groupId: device.groupId
};

deviceList.push(deviceData);

return { deviceList };
}

/**
* Returns <tt>true<tt/> if a WebRTC MediaStream identified by given stream
* ID is considered a valid "user" stream which means that it's not a
* "receive only" stream nor a "mixed" JVB stream.
*
* Clients that implement Unified Plan, such as Firefox use recvonly
* "streams/channels/tracks" for receiving remote stream/tracks, as opposed
* to Plan B where there are only 3 channels: audio, video and data.
*
* @param {string} streamId The id of WebRTC MediaStream.
* @returns {boolean}
*/
isUserStreamById(streamId) {
return streamId && streamId !== 'mixedmslabel' && streamId !== 'default';
}
}

const rtcUtils = new RTCUtils();
Expand Down
8 changes: 4 additions & 4 deletions modules/RTC/TraceablePeerConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import SdpSimulcast from '../sdp/SdpSimulcast';
import { SdpTransformWrap } from '../sdp/SdpTransformUtil';

import JitsiRemoteTrack from './JitsiRemoteTrack';
import RTC from './RTC';
import RTCUtils from './RTCUtils';
import { TPCUtils } from './TPCUtils';

// FIXME SDP tools should end up in some kind of util module
Expand Down Expand Up @@ -857,7 +857,7 @@ TraceablePeerConnection.prototype._remoteTrackAdded = function(stream, track, tr
const mediaType = track.kind;

// Do not create remote tracks for 'mixed' JVB SSRCs (used by JVB for RTCP termination).
if (!this.isP2P && !RTC.isUserStreamById(streamId)) {
if (!this.isP2P && !RTCUtils.isUserStreamById(streamId)) {
return;
}
logger.info(`${this} Received track event for remote stream[id=${streamId},type=${mediaType}]`);
Expand Down Expand Up @@ -1016,7 +1016,7 @@ TraceablePeerConnection.prototype._remoteTrackRemoved = function(stream, track)
const trackId = track?.id;

// Ignore stream removed events for JVB "mixed" sources (used for RTCP termination).
if (!RTC.isUserStreamById(streamId)) {
if (!RTCUtils.isUserStreamById(streamId)) {
return;
}

Expand Down Expand Up @@ -2454,7 +2454,7 @@ TraceablePeerConnection.prototype.close = function() {
this._dtmfTonesQueue = [];

if (!this.rtc._removePeerConnection(this)) {
logger.error(`${this} RTC._removePeerConnection returned false`);
logger.error(`${this} rtc._removePeerConnection returned false`);
}
if (this.statsinterval !== null) {
window.clearInterval(this.statsinterval);
Expand Down
2 changes: 0 additions & 2 deletions types/hand-crafted/modules/RTC/RTC.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ export default class RTC extends Listenable {
static getCurrentlyAvailableMediaDevices: () => unknown[]; // TODO:
static getEventDataForActiveDevice: () => MediaDeviceInfo;
static setAudioOutputDevice: ( deviceId: string ) => Promise<unknown>; // TODO:
static isUserStream: ( stream: MediaStream ) => boolean;
static isUserStreamById: ( streamId: string ) => boolean;
static enumerateDevices: ( callback: () => unknown ) => void; // TODO:
static stopMediaStream: ( mediaStream: MediaStream ) => void;
static isDesktopSharingEnabled: () => boolean;
Expand Down
1 change: 1 addition & 0 deletions types/hand-crafted/modules/RTC/RTCUtils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ declare class RTCUtils extends Listenable {
getCurrentlyAvailableMediaDevices: () => unknown[]; // TODO:
getEventDataForActiveDevice: ( device: MediaDeviceInfo ) => unknown; // TODO:
arePermissionsGrantedForAvailableDevices: () => boolean;
isUserStreamById: ( streamId: string ) => boolean;
}

declare const rtcUtils: RTCUtils;
Expand Down

0 comments on commit e9ba31b

Please sign in to comment.