Skip to content

Commit

Permalink
fix(tracks): Remove code that handles TRACK_OWNER_CHANGED event.
Browse files Browse the repository at this point in the history
When ssrc-rewriting is enabled, LJM doesn't fire TRACK_OWNER_CHANGED events; it will instead fire TRACK_REMOVED followed by TRACK_ADDED event.
  • Loading branch information
jallamsetty1 committed Apr 18, 2024
1 parent cc03949 commit f4d600f
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 83 deletions.
35 changes: 33 additions & 2 deletions react/features/base/participants/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,15 +468,15 @@ export function getScreenshareParticipantIds(stateful: IStateful): Array<string>
}

/**
* Returns a list source name associated with a given remote participant and for the given media type.
* Returns a list of source names associated with a given remote participant and for the given media type.
*
* @param {(Function|Object)} stateful - The (whole) redux state, or redux's {@code getState} function to be used to
* retrieve the state.
* @param {string} id - The id of the participant whose source names are to be retrieved.
* @param {string} mediaType - The type of source, audio or video.
* @returns {Array<string>|undefined}
*/
export function getSourceNamesByMediaType(
export function getSourceNamesByMediaTypeAndParticipant(
stateful: IStateful,
id: string,
mediaType: string): Array<string> | undefined {
Expand All @@ -497,6 +497,37 @@ export function getSourceNamesByMediaType(
.map(s => s[0]);
}

/**
* Returns a list of source names associated with a given remote participant and for the given video type (only for
* video sources).
*
* @param {(Function|Object)} stateful - The (whole) redux state, or redux's {@code getState} function to be used to
* retrieve the state.
* @param {string} id - The id of the participant whose source names are to be retrieved.
* @param {string} videoType - The type of video, camera or desktop.
* @returns {Array<string>|undefined}
*/
export function getSourceNamesByVideoTypeAndParticipant(
stateful: IStateful,
id: string,
videoType: string): Array<string> | undefined {
const participant: IParticipant | undefined = getParticipantById(stateful, id);

if (!participant) {
return;
}

const sources = participant.sources;

if (!sources) {
return;
}

return Array.from(sources.get(MEDIA_TYPE.VIDEO) ?? new Map())
.filter(source => source[1].videoType === videoType && (videoType === VIDEO_TYPE.CAMERA || !source[1].muted))
.map(s => s[0]);
}

/**
* Returns the presence status of a participant associated with the passed id.
*
Expand Down
10 changes: 0 additions & 10 deletions react/features/base/tracks/actionTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,6 @@ export const TRACK_MUTE_UNMUTE_FAILED = 'TRACK_MUTE_UNMUTE_FAILED';
*/
export const TRACK_NO_DATA_FROM_SOURCE = 'TRACK_NO_DATA_FROM_SOURCE';

/**
* The type of redux action dispatched when the owner of a track changes due to ssrc remapping.
*
* {
* type: TRACK_OWNER_CHANGED,
* track: Track
* }
*/
export const TRACK_OWNER_CHANGED = 'TRACK_OWNER_CHANGED';

/**
* The type of redux action dispatched when a track has been (locally or
* remotely) removed from the conference.
Expand Down
34 changes: 0 additions & 34 deletions react/features/base/tracks/actions.any.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {
TRACK_CREATE_ERROR,
TRACK_MUTE_UNMUTE_FAILED,
TRACK_NO_DATA_FROM_SOURCE,
TRACK_OWNER_CHANGED,
TRACK_REMOVED,
TRACK_STOPPED,
TRACK_UPDATED,
Expand Down Expand Up @@ -381,9 +380,6 @@ export function trackAdded(track: any) {
track.on(
JitsiTrackEvents.TRACK_VIDEOTYPE_CHANGED,
(type: VideoType) => dispatch(trackVideoTypeChanged(track, type)));
track.on(
JitsiTrackEvents.TRACK_OWNER_CHANGED,
(owner: string) => dispatch(trackOwnerChanged(track, owner)));
const local = track.isLocal();
const mediaType = track.getVideoType() === VIDEO_TYPE.DESKTOP
? MEDIA_TYPE.SCREENSHARE
Expand Down Expand Up @@ -539,10 +535,6 @@ export function trackRemoved(track: any): {
};
type: 'TRACK_REMOVED';
} {
track.removeAllListeners(JitsiTrackEvents.TRACK_MUTE_CHANGED);
track.removeAllListeners(JitsiTrackEvents.TRACK_VIDEOTYPE_CHANGED);
track.removeAllListeners(JitsiTrackEvents.NO_DATA_FROM_SOURCE);

return {
type: TRACK_REMOVED,
track: {
Expand Down Expand Up @@ -625,32 +617,6 @@ export function trackStreamingStatusChanged(track: any, streamingStatus: string)
};
}

/**
* Create an action for when the owner of the track changes due to ssrc remapping.
*
* @param {(JitsiRemoteTrack)} track - JitsiTrack instance.
* @param {string} participantId - New owner's participant ID.
* @returns {{
* type: TRACK_OWNER_CHANGED,
* track: Track
* }}
*/
export function trackOwnerChanged(track: any, participantId: string): {
track: {
jitsiTrack: any;
participantId: string;
};
type: 'TRACK_OWNER_CHANGED';
} {
return {
type: TRACK_OWNER_CHANGED,
track: {
jitsiTrack: track,
participantId
}
};
}

/**
* Signals passed tracks to be added.
*
Expand Down
18 changes: 0 additions & 18 deletions react/features/base/tracks/middleware.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
TRACK_ADDED,
TRACK_MUTE_UNMUTE_FAILED,
TRACK_NO_DATA_FROM_SOURCE,
TRACK_OWNER_CHANGED,
TRACK_REMOVED,
TRACK_STOPPED,
TRACK_UPDATED
Expand Down Expand Up @@ -82,23 +81,6 @@ MiddlewareRegistry.register(store => next => action => {
return result;
}

case TRACK_OWNER_CHANGED: {
const oldTrack = getTrackByJitsiTrack(store.getState()['features/base/tracks'], action.track?.jitsiTrack);
const oldOwner = oldTrack?.participantId;
const result = next(action);
const newOwner = action.track?.participantId;

if (oldOwner) {
logTracksForParticipant(store.getState()['features/base/tracks'], oldOwner, 'Owner changed');
}

if (newOwner) {
logTracksForParticipant(store.getState()['features/base/tracks'], newOwner, 'Owner changed');
}

return result;
}

case TRACK_MUTE_UNMUTE_FAILED: {
const { jitsiTrack } = action.track;
const muted = action.wasMuted;
Expand Down
14 changes: 0 additions & 14 deletions react/features/base/tracks/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
TRACK_CREATE_CANCELED,
TRACK_CREATE_ERROR,
TRACK_NO_DATA_FROM_SOURCE,
TRACK_OWNER_CHANGED,
TRACK_REMOVED,
TRACK_UPDATED,
TRACK_WILL_CREATE
Expand Down Expand Up @@ -43,18 +42,6 @@ function track(state: ITrack, action: AnyAction) {
}
break;

case TRACK_OWNER_CHANGED: {
const t = action.track;

if (state.jitsiTrack === t.jitsiTrack) {
return {
...state,
participantId: t.participantId
};
}
break;
}

case TRACK_UPDATED: {
const t = action.track;

Expand Down Expand Up @@ -104,7 +91,6 @@ ReducerRegistry.register<ITracksState>('features/base/tracks', (state = [], acti
switch (action.type) {
case PARTICIPANT_ID_CHANGED:
case TRACK_NO_DATA_FROM_SOURCE:
case TRACK_OWNER_CHANGED:
case TRACK_UPDATED:
return state.map((t: ITrack) => track(t, action));
case TRACK_ADDED: {
Expand Down
12 changes: 7 additions & 5 deletions react/features/video-quality/subscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import debounce from 'lodash/debounce';
import { IReduxState, IStore } from '../app/types';
import { _handleParticipantError } from '../base/conference/functions';
import { getSsrcRewritingFeatureFlag } from '../base/config/functions.any';
import { MEDIA_TYPE } from '../base/media/constants';
import { MEDIA_TYPE, VIDEO_TYPE } from '../base/media/constants';
import {
getLocalParticipant,
getSourceNamesByMediaType
getSourceNamesByMediaTypeAndParticipant,
getSourceNamesByVideoTypeAndParticipant
} from '../base/participants/functions';
import StateListenerRegistry from '../base/redux/StateListenerRegistry';
import { getTrackSourceNameByMediaTypeAndParticipant } from '../base/tracks/functions';
Expand Down Expand Up @@ -322,7 +323,7 @@ function _getSourceNames(participantList: Array<string>, state: IReduxState): Ar
participantList.forEach(participantId => {
if (getSsrcRewritingFeatureFlag(state)) {
const sourceNames: string[] | undefined
= getSourceNamesByMediaType(state, participantId, MEDIA_TYPE.VIDEO);
= getSourceNamesByMediaTypeAndParticipant(state, participantId, MEDIA_TYPE.VIDEO);

sourceNames?.length && sourceNamesList.push(...sourceNames);
} else {
Expand Down Expand Up @@ -428,8 +429,9 @@ function _updateReceiverVideoConstraints({ getState }: IStore) {
if (remoteScreenShares.includes(largeVideoParticipantId)) {
largeVideoSourceName = largeVideoParticipantId;
} else {
largeVideoSourceName = getTrackSourceNameByMediaTypeAndParticipant(
tracks, MEDIA_TYPE.VIDEO, largeVideoParticipantId);
largeVideoSourceName = getSsrcRewritingFeatureFlag(state)
? getSourceNamesByVideoTypeAndParticipant(state, largeVideoParticipantId, VIDEO_TYPE.CAMERA)?.[0]
: getTrackSourceNameByMediaTypeAndParticipant(tracks, MEDIA_TYPE.VIDEO, largeVideoParticipantId);
}
}

Expand Down

0 comments on commit f4d600f

Please sign in to comment.