|
|
|
@ -3,12 +3,11 @@ import { AnyAction } from 'redux'; |
|
|
|
|
import { IStore } from '../app/types'; |
|
|
|
|
import { |
|
|
|
|
CONFERENCE_JOINED, |
|
|
|
|
CONFERENCE_WILL_LEAVE |
|
|
|
|
CONFERENCE_WILL_LEAVE, |
|
|
|
|
ENDPOINT_MESSAGE_RECEIVED |
|
|
|
|
} from '../base/conference/actionTypes'; |
|
|
|
|
import { getCurrentConference } from '../base/conference/functions'; |
|
|
|
|
import { JitsiConferenceEvents } from '../base/lib-jitsi-meet'; |
|
|
|
|
import { getLocalParticipant, getParticipantCount } from '../base/participants/functions'; |
|
|
|
|
import { IParticipant } from '../base/participants/types'; |
|
|
|
|
import MiddlewareRegistry from '../base/redux/MiddlewareRegistry'; |
|
|
|
|
import { TRACK_ADDED, TRACK_REMOVED, TRACK_UPDATED } from '../base/tracks/actionTypes'; |
|
|
|
|
|
|
|
|
@ -28,27 +27,22 @@ MiddlewareRegistry.register((store: IStore) => (next: Function) => (action: AnyA |
|
|
|
|
FaceLandmarksDetector.init(store); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// allow using remote face centering data when local face centering is not enabled
|
|
|
|
|
action.conference.on( |
|
|
|
|
JitsiConferenceEvents.ENDPOINT_MESSAGE_RECEIVED, |
|
|
|
|
(participant: IParticipant | undefined, eventData: any) => { |
|
|
|
|
if (!participant || !eventData || !participant.getId) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (eventData.type === FACE_BOX_EVENT_TYPE) { |
|
|
|
|
dispatch({ |
|
|
|
|
type: UPDATE_FACE_COORDINATES, |
|
|
|
|
faceBox: eventData.faceBox, |
|
|
|
|
id: participant.getId() |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
return next(action); |
|
|
|
|
} else if (action.type === ENDPOINT_MESSAGE_RECEIVED) { |
|
|
|
|
// Allow using remote face centering data when local face centering is not enabled.
|
|
|
|
|
const { participant, data } = action; |
|
|
|
|
|
|
|
|
|
if (data?.type === FACE_BOX_EVENT_TYPE) { |
|
|
|
|
dispatch({ |
|
|
|
|
type: UPDATE_FACE_COORDINATES, |
|
|
|
|
faceBox: data.faceBox, |
|
|
|
|
id: participant.getId() |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return next(action); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!isEnabled) { |
|
|
|
|
return next(action); |
|
|
|
|
} |
|
|
|
@ -57,7 +51,7 @@ MiddlewareRegistry.register((store: IStore) => (next: Function) => (action: AnyA |
|
|
|
|
case CONFERENCE_WILL_LEAVE : { |
|
|
|
|
FaceLandmarksDetector.stopDetection(store); |
|
|
|
|
|
|
|
|
|
return next(action); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case TRACK_ADDED: { |
|
|
|
|
const { jitsiTrack: { isLocal, videoType }, muted } = action.track; |
|
|
|
@ -67,18 +61,18 @@ MiddlewareRegistry.register((store: IStore) => (next: Function) => (action: AnyA |
|
|
|
|
FaceLandmarksDetector.startDetection(store, action.track); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return next(action); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case TRACK_UPDATED: { |
|
|
|
|
const { jitsiTrack: { isLocal, videoType } } = action.track; |
|
|
|
|
|
|
|
|
|
if (videoType !== 'camera' || !isLocal()) { |
|
|
|
|
return next(action); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const { muted } = action.track; |
|
|
|
|
|
|
|
|
|
if (muted !== undefined) { |
|
|
|
|
if (typeof muted !== 'undefined') { |
|
|
|
|
// addresses video mute state changes
|
|
|
|
|
if (muted) { |
|
|
|
|
FaceLandmarksDetector.stopDetection(store); |
|
|
|
@ -87,7 +81,7 @@ MiddlewareRegistry.register((store: IStore) => (next: Function) => (action: AnyA |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return next(action); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case TRACK_REMOVED: { |
|
|
|
|
const { jitsiTrack: { isLocal, videoType } } = action.track; |
|
|
|
@ -96,7 +90,7 @@ MiddlewareRegistry.register((store: IStore) => (next: Function) => (action: AnyA |
|
|
|
|
FaceLandmarksDetector.stopDetection(store); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return next(action); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case ADD_FACE_LANDMARKS: { |
|
|
|
|
const state = getState(); |
|
|
|
@ -110,7 +104,7 @@ MiddlewareRegistry.register((store: IStore) => (next: Function) => (action: AnyA |
|
|
|
|
// Disabling for now as there is no value of having the data in speakerstats at the server
|
|
|
|
|
// sendFaceExpressionToServer(conference, faceLandmarks);
|
|
|
|
|
|
|
|
|
|
return next(action); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case NEW_FACE_COORDINATES: { |
|
|
|
|
const state = getState(); |
|
|
|
@ -127,6 +121,8 @@ MiddlewareRegistry.register((store: IStore) => (next: Function) => (action: AnyA |
|
|
|
|
faceBox, |
|
|
|
|
id: localParticipant?.id |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|