[RN] Use _switchCameras provided by lib-jitsi-meet

The functionality to use the react-native-webrtc custom API for fast switching
cameras was moved to JitsiLocalTrack in lib-jitsi-meet. Use that.

Ref: https://github.com/jitsi/lib-jitsi-meet/pull/444
This commit is contained in:
Saúl Ibarra Corretgé 2017-04-05 11:03:16 +02:00 committed by Lyubo Marinov
parent 8fe3dce649
commit 37157dc9e2
1 changed files with 11 additions and 16 deletions

View File

@ -2,6 +2,7 @@
import { LIB_DID_DISPOSE, LIB_DID_INIT } from '../lib-jitsi-meet'; import { LIB_DID_DISPOSE, LIB_DID_INIT } from '../lib-jitsi-meet';
import { import {
CAMERA_FACING_MODE,
MEDIA_TYPE, MEDIA_TYPE,
SET_AUDIO_MUTED, SET_AUDIO_MUTED,
SET_CAMERA_FACING_MODE, SET_CAMERA_FACING_MODE,
@ -68,29 +69,23 @@ MiddlewareRegistry.register(store => next => action => {
case TOGGLE_CAMERA_FACING_MODE: { case TOGGLE_CAMERA_FACING_MODE: {
const localTrack = _getLocalTrack(store, MEDIA_TYPE.VIDEO); const localTrack = _getLocalTrack(store, MEDIA_TYPE.VIDEO);
let jitsiTrack; let jitsiTrack;
let mediaStreamTrack;
if (localTrack if (localTrack && (jitsiTrack = localTrack.jitsiTrack)) {
&& (jitsiTrack = localTrack.jitsiTrack) // XXX MediaStreamTrack._switchCamera is a custom function
&& (mediaStreamTrack = jitsiTrack.track)) { // implemented in react-native-webrtc for video which switches
// XXX MediaStreamTrack._switchCamera a custom function implemented // between the cameras via a native WebRTC library implementation
// in react-native-webrtc for video which switches between the // without making any changes to the track.
// cameras via a native WebRTC library implementation without making jitsiTrack._switchCamera();
// any changes to the track.
// FIXME JitsiLocalTrack defines getCameraFacingMode. By calling
// _switchCamera on MediaStreamTrack without the knowledge of
// lib-jitsi-meet we are likely introducing an inconsistency in
// JitsiLocalTrack's state.
mediaStreamTrack._switchCamera();
// Don't mirror the video of the back/environment-facing camera. // Don't mirror the video of the back/environment-facing camera.
// FIXME Relies on the fact that we always open the camera in const mirror
// user-facing mode first. = jitsiTrack.getCameraFacingMode() === CAMERA_FACING_MODE.USER;
store.dispatch({ store.dispatch({
type: TRACK_UPDATED, type: TRACK_UPDATED,
track: { track: {
jitsiTrack, jitsiTrack,
mirror: !localTrack.mirror mirror
} }
}); });
} }