Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

feat(rtc-stats): send camera off and on events (#12522)

Gabriel Borleaf4e8f860b175
diff --git a/react/features/face-landmarks/FaceLandmarksDetector.ts b/react/features/face-landmarks/FaceLandmarksDetector.ts
index e22c3c8d4f..7fe803f2f8 100644
--- a/react/features/face-landmarks/FaceLandmarksDetector.ts
+++ b/react/features/face-landmarks/FaceLandmarksDetector.ts
@@ -7,7 +7,6 @@ import { getBaseUrl } from '../base/util/helpers';
import {
addFaceExpression,
clearFaceExpressionBuffer,
- faceLandmarkDetectionStopped,
newFaceBox
} from './actions';
import {
@@ -249,7 +248,6 @@ class FaceLandmarksDetector {
this.detectionInterval = null;
this.imageCapture = null;
this.recognitionActive = false;
- dispatch(faceLandmarkDetectionStopped(Date.now()));
logger.log('Stop face detection');
}
diff --git a/react/features/face-landmarks/actionTypes.ts b/react/features/face-landmarks/actionTypes.ts
index c21468aee6..e4231f9346 100644
--- a/react/features/face-landmarks/actionTypes.ts
+++ b/react/features/face-landmarks/actionTypes.ts
@@ -49,12 +49,3 @@ export const UPDATE_FACE_COORDINATES = 'UPDATE_FACE_COORDINATES';
* }
*/
export const NEW_FACE_COORDINATES = 'NEW_FACE_COORDINATES';
-
- /**
- * Redux action type dispatched in order to signal that the face landmarks detection stopped.
- * {
- * type: FACE_LANDMARK_DETECTION_STOPPED,
- * timestamp: number,
- * }
-*/
-export const FACE_LANDMARK_DETECTION_STOPPED = 'FACE_LANDMARK_DETECTION_STOPPED';
diff --git a/react/features/face-landmarks/actions.ts b/react/features/face-landmarks/actions.ts
index e353eac4f8..a603a0313b 100644
--- a/react/features/face-landmarks/actions.ts
+++ b/react/features/face-landmarks/actions.ts
@@ -6,7 +6,6 @@ import {
ADD_FACE_EXPRESSION,
ADD_TO_FACE_EXPRESSIONS_BUFFER,
CLEAR_FACE_EXPRESSIONS_BUFFER,
- FACE_LANDMARK_DETECTION_STOPPED,
NEW_FACE_COORDINATES
} from './actionTypes';
import { FaceBox } from './types';
@@ -69,16 +68,3 @@ export function newFaceBox(faceBox: FaceBox): AnyAction {
faceBox
};
}
-
-/**
- * Dispatches the face landmarks detection stopped event in order to be sent to services.
- *
- * @param {number} timestamp - The timestamp when the camera was off.
- * @returns {AnyAction}
- */
-export function faceLandmarkDetectionStopped(timestamp: number): AnyAction {
- return {
- type: FACE_LANDMARK_DETECTION_STOPPED,
- timestamp
- };
-}
diff --git a/react/features/rtcstats/middleware.ts b/react/features/rtcstats/middleware.ts
index 739b5c3f04..fbe0cf838a 100644
--- a/react/features/rtcstats/middleware.ts
+++ b/react/features/rtcstats/middleware.ts
@@ -14,7 +14,7 @@ import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
import { TRACK_ADDED, TRACK_UPDATED } from '../base/tracks/actionTypes';
import { getCurrentRoomId, isInBreakoutRoom } from '../breakout-rooms/functions';
import { extractFqnFromPath } from '../dynamic-branding/functions.any';
-import { ADD_FACE_EXPRESSION, FACE_LANDMARK_DETECTION_STOPPED } from '../face-landmarks/actionTypes';
+import { ADD_FACE_EXPRESSION } from '../face-landmarks/actionTypes';
import RTCStats from './RTCStats';
import {
@@ -118,8 +118,16 @@ MiddlewareRegistry.register((store: IStore) => (next: Function) => (action: AnyA
}
case TRACK_UPDATED: {
if (canSendRtcstatsData(state)) {
- const { videoType, jitsiTrack } = action?.track || { };
- const { ssrc } = jitsiTrack || { };
+ const { videoType, jitsiTrack, muted } = action?.track || { };
+ const { ssrc, isLocal, videoType: trackVideoType, conference } = jitsiTrack || { };
+
+ if (trackVideoType === 'camera' && conference && isLocal()) {
+ RTCStats.sendFaceLandmarksData({
+ duration: 0,
+ faceLandmarks: muted ? 'camera-off' : 'camera-on',
+ timestamp: Date.now()
+ });
+ }
// if the videoType of the remote track has changed we expect to find it in track.videoType. grep for
// trackVideoTypeChanged.
@@ -157,18 +165,16 @@ MiddlewareRegistry.register((store: IStore) => (next: Function) => (action: AnyA
break;
}
case ADD_FACE_EXPRESSION:
- case FACE_LANDMARK_DETECTION_STOPPED: {
if (canSendFaceLandmarksRtcstatsData(state)) {
const { duration, faceExpression, timestamp } = action;
RTCStats.sendFaceLandmarksData({
- duration: duration ?? 0,
- faceLandmarks: faceExpression ?? 'detection-off',
+ duration,
+ faceLandmarks: faceExpression,
timestamp
});
}
break;
- }
case CONFERENCE_TIMESTAMP_CHANGED: {
if (canSendRtcstatsData(state)) {
const { conferenceTimestamp } = action;