fix(rn,screenshare) rework the logic for unified-plan with multi-stream
This commit is contained in:
parent
e7c5ae5936
commit
ca9f0a6788
|
@ -43,7 +43,8 @@ export const VIDEO_MUTISM_AUTHORITY = {
|
||||||
AUDIO_ONLY: 1 << 0,
|
AUDIO_ONLY: 1 << 0,
|
||||||
BACKGROUND: 1 << 1,
|
BACKGROUND: 1 << 1,
|
||||||
USER: 1 << 2,
|
USER: 1 << 2,
|
||||||
CAR_MODE: 1 << 3
|
CAR_MODE: 1 << 3,
|
||||||
|
SCREEN_SHARE: 1 << 4
|
||||||
};
|
};
|
||||||
|
|
||||||
/* eslint-enable no-bitwise */
|
/* eslint-enable no-bitwise */
|
||||||
|
|
|
@ -4,9 +4,17 @@ import { IReduxState, IStore } from '../../app/types';
|
||||||
import { setPictureInPictureEnabled } from '../../mobile/picture-in-picture/functions';
|
import { setPictureInPictureEnabled } from '../../mobile/picture-in-picture/functions';
|
||||||
import { setAudioOnly } from '../audio-only/actions';
|
import { setAudioOnly } from '../audio-only/actions';
|
||||||
import JitsiMeetJS from '../lib-jitsi-meet';
|
import JitsiMeetJS from '../lib-jitsi-meet';
|
||||||
|
import {
|
||||||
|
setScreenshareMuted,
|
||||||
|
setVideoMuted
|
||||||
|
} from '../media/actions';
|
||||||
|
import {
|
||||||
|
MEDIA_TYPE,
|
||||||
|
VIDEO_MUTISM_AUTHORITY
|
||||||
|
} from '../media/constants';
|
||||||
|
|
||||||
import { destroyLocalDesktopTrackIfExists, replaceLocalTrack } from './actions.any';
|
import { addLocalTrack, replaceLocalTrack } from './actions.any';
|
||||||
import { getLocalVideoTrack, isLocalVideoTrackDesktop } from './functions';
|
import { getLocalDesktopTrack, getTrackState, isLocalVideoTrackDesktop } from './functions.native';
|
||||||
|
|
||||||
export * from './actions.any';
|
export * from './actions.any';
|
||||||
|
|
||||||
|
@ -31,7 +39,8 @@ export function toggleScreensharing(enabled: boolean, _ignore1?: boolean, _ignor
|
||||||
_startScreenSharing(dispatch, state);
|
_startScreenSharing(dispatch, state);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dispatch(destroyLocalDesktopTrackIfExists());
|
dispatch(setScreenshareMuted(true));
|
||||||
|
dispatch(setVideoMuted(false, MEDIA_TYPE.VIDEO, VIDEO_MUTISM_AUTHORITY.SCREEN_SHARE));
|
||||||
setPictureInPictureEnabled(true);
|
setPictureInPictureEnabled(true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -47,26 +56,33 @@ export function toggleScreensharing(enabled: boolean, _ignore1?: boolean, _ignor
|
||||||
* @param {Object} state - The redux state.
|
* @param {Object} state - The redux state.
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
function _startScreenSharing(dispatch: Function, state: IReduxState) {
|
async function _startScreenSharing(dispatch: Function, state: IReduxState) {
|
||||||
setPictureInPictureEnabled(false);
|
setPictureInPictureEnabled(false);
|
||||||
|
|
||||||
JitsiMeetJS.createLocalTracks({ devices: [ 'desktop' ] })
|
try {
|
||||||
.then((tracks: any[]) => {
|
const tracks: any[] = await JitsiMeetJS.createLocalTracks({ devices: [ 'desktop' ] });
|
||||||
const track = tracks[0];
|
const track = tracks[0];
|
||||||
const currentLocalTrack = getLocalVideoTrack(state['features/base/tracks']);
|
const currentLocalDesktopTrack = getLocalDesktopTrack(getTrackState(state));
|
||||||
const currentJitsiTrack = currentLocalTrack?.jitsiTrack;
|
const currentJitsiTrack = currentLocalDesktopTrack?.jitsiTrack;
|
||||||
|
|
||||||
dispatch(replaceLocalTrack(currentJitsiTrack, track));
|
// The first time the user shares the screen we add the track and create the transceiver.
|
||||||
|
// Afterwards, we just replace the old track, so the transceiver will be reused.
|
||||||
|
if (currentJitsiTrack) {
|
||||||
|
dispatch(replaceLocalTrack(currentJitsiTrack, track));
|
||||||
|
} else {
|
||||||
|
dispatch(addLocalTrack(track));
|
||||||
|
}
|
||||||
|
|
||||||
|
dispatch(setVideoMuted(true, MEDIA_TYPE.VIDEO, VIDEO_MUTISM_AUTHORITY.SCREEN_SHARE));
|
||||||
|
|
||||||
const { enabled: audioOnly } = state['features/base/audio-only'];
|
const { enabled: audioOnly } = state['features/base/audio-only'];
|
||||||
|
|
||||||
if (audioOnly) {
|
if (audioOnly) {
|
||||||
dispatch(setAudioOnly(false));
|
dispatch(setAudioOnly(false));
|
||||||
}
|
}
|
||||||
})
|
} catch (error: any) {
|
||||||
.catch((error: any) => {
|
|
||||||
console.log('ERROR creating ScreeSharing stream ', error);
|
console.log('ERROR creating ScreeSharing stream ', error);
|
||||||
|
|
||||||
setPictureInPictureEnabled(true);
|
setPictureInPictureEnabled(true);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -313,9 +313,9 @@ export function isLocalTrackMuted(tracks: ITrack[], mediaType: MediaType) {
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
export function isLocalVideoTrackDesktop(state: IReduxState) {
|
export function isLocalVideoTrackDesktop(state: IReduxState) {
|
||||||
const videoTrack = getLocalVideoTrack(getTrackState(state));
|
const desktopTrack = getLocalDesktopTrack(getTrackState(state));
|
||||||
|
|
||||||
return videoTrack && videoTrack.videoType === VIDEO_TYPE.DESKTOP;
|
return desktopTrack !== undefined && !desktopTrack.muted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue