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

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

* code review
This commit is contained in:
Gabriel Borlea 2022-11-08 11:41:53 +02:00 committed by GitHub
parent ee544d25f8
commit f4e8f860b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 32 deletions

View File

@ -7,7 +7,6 @@ import { getBaseUrl } from '../base/util/helpers';
import { import {
addFaceExpression, addFaceExpression,
clearFaceExpressionBuffer, clearFaceExpressionBuffer,
faceLandmarkDetectionStopped,
newFaceBox newFaceBox
} from './actions'; } from './actions';
import { import {
@ -249,7 +248,6 @@ class FaceLandmarksDetector {
this.detectionInterval = null; this.detectionInterval = null;
this.imageCapture = null; this.imageCapture = null;
this.recognitionActive = false; this.recognitionActive = false;
dispatch(faceLandmarkDetectionStopped(Date.now()));
logger.log('Stop face detection'); logger.log('Stop face detection');
} }

View File

@ -49,12 +49,3 @@ export const UPDATE_FACE_COORDINATES = 'UPDATE_FACE_COORDINATES';
* } * }
*/ */
export const NEW_FACE_COORDINATES = 'NEW_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';

View File

@ -6,7 +6,6 @@ import {
ADD_FACE_EXPRESSION, ADD_FACE_EXPRESSION,
ADD_TO_FACE_EXPRESSIONS_BUFFER, ADD_TO_FACE_EXPRESSIONS_BUFFER,
CLEAR_FACE_EXPRESSIONS_BUFFER, CLEAR_FACE_EXPRESSIONS_BUFFER,
FACE_LANDMARK_DETECTION_STOPPED,
NEW_FACE_COORDINATES NEW_FACE_COORDINATES
} from './actionTypes'; } from './actionTypes';
import { FaceBox } from './types'; import { FaceBox } from './types';
@ -69,16 +68,3 @@ export function newFaceBox(faceBox: FaceBox): AnyAction {
faceBox 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
};
}

View File

@ -14,7 +14,7 @@ import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
import { TRACK_ADDED, TRACK_UPDATED } from '../base/tracks/actionTypes'; import { TRACK_ADDED, TRACK_UPDATED } from '../base/tracks/actionTypes';
import { getCurrentRoomId, isInBreakoutRoom } from '../breakout-rooms/functions'; import { getCurrentRoomId, isInBreakoutRoom } from '../breakout-rooms/functions';
import { extractFqnFromPath } from '../dynamic-branding/functions.any'; 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 RTCStats from './RTCStats';
import { import {
@ -118,8 +118,16 @@ MiddlewareRegistry.register((store: IStore) => (next: Function) => (action: AnyA
} }
case TRACK_UPDATED: { case TRACK_UPDATED: {
if (canSendRtcstatsData(state)) { if (canSendRtcstatsData(state)) {
const { videoType, jitsiTrack } = action?.track || { }; const { videoType, jitsiTrack, muted } = action?.track || { };
const { ssrc } = jitsiTrack || { }; 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 // if the videoType of the remote track has changed we expect to find it in track.videoType. grep for
// trackVideoTypeChanged. // trackVideoTypeChanged.
@ -157,18 +165,16 @@ MiddlewareRegistry.register((store: IStore) => (next: Function) => (action: AnyA
break; break;
} }
case ADD_FACE_EXPRESSION: case ADD_FACE_EXPRESSION:
case FACE_LANDMARK_DETECTION_STOPPED: {
if (canSendFaceLandmarksRtcstatsData(state)) { if (canSendFaceLandmarksRtcstatsData(state)) {
const { duration, faceExpression, timestamp } = action; const { duration, faceExpression, timestamp } = action;
RTCStats.sendFaceLandmarksData({ RTCStats.sendFaceLandmarksData({
duration: duration ?? 0, duration,
faceLandmarks: faceExpression ?? 'detection-off', faceLandmarks: faceExpression,
timestamp timestamp
}); });
} }
break; break;
}
case CONFERENCE_TIMESTAMP_CHANGED: { case CONFERENCE_TIMESTAMP_CHANGED: {
if (canSendRtcstatsData(state)) { if (canSendRtcstatsData(state)) {
const { conferenceTimestamp } = action; const { conferenceTimestamp } = action;