2022-10-20 09:11:27 +00:00
|
|
|
import { IReduxState } from '../app/types';
|
2022-09-29 11:45:34 +00:00
|
|
|
import { getMultipleVideoSendingSupportFeatureFlag } from '../base/config/functions.any';
|
|
|
|
import { isWindows } from '../base/environment/environment';
|
2021-07-07 08:07:30 +00:00
|
|
|
import { isMobileBrowser } from '../base/environment/utils';
|
2021-04-12 07:37:39 +00:00
|
|
|
import { browser } from '../base/lib-jitsi-meet';
|
2022-09-29 11:45:34 +00:00
|
|
|
import { VIDEO_TYPE } from '../base/media/constants';
|
|
|
|
import { getLocalDesktopTrack, getLocalVideoTrack } from '../base/tracks/functions';
|
2021-04-12 07:37:39 +00:00
|
|
|
|
2021-07-07 08:07:30 +00:00
|
|
|
/**
|
|
|
|
* Is the current screen sharing session audio only.
|
|
|
|
*
|
2022-10-20 09:11:27 +00:00
|
|
|
* @param {IReduxState} state - The state of the application.
|
2021-07-07 08:07:30 +00:00
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2022-10-20 09:11:27 +00:00
|
|
|
export function isAudioOnlySharing(state: IReduxState) {
|
2021-07-07 08:07:30 +00:00
|
|
|
return isScreenAudioShared(state) && !isScreenVideoShared(state);
|
|
|
|
}
|
2021-04-12 07:37:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* State of audio sharing.
|
|
|
|
*
|
2022-10-20 09:11:27 +00:00
|
|
|
* @param {IReduxState} state - The state of the application.
|
2021-04-12 07:37:39 +00:00
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2022-10-20 09:11:27 +00:00
|
|
|
export function isScreenAudioShared(state: IReduxState) {
|
2021-04-12 07:37:39 +00:00
|
|
|
return state['features/screen-share'].isSharingAudio;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-04-28 14:06:41 +00:00
|
|
|
* Returns the visibility of the audio only screen share button. Currently only chrome browser and electron on
|
|
|
|
* windows supports this functionality.
|
2021-04-12 07:37:39 +00:00
|
|
|
*
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
export function isScreenAudioSupported() {
|
2021-07-07 08:07:30 +00:00
|
|
|
return (!isMobileBrowser() && browser.isChrome()) || (browser.isElectron() && isWindows());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Is any screen media currently being shared, audio or video.
|
|
|
|
*
|
2022-10-20 09:11:27 +00:00
|
|
|
* @param {IReduxState} state - The state of the application.
|
2021-07-07 08:07:30 +00:00
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2022-10-20 09:11:27 +00:00
|
|
|
export function isScreenMediaShared(state: IReduxState) {
|
2021-07-07 08:07:30 +00:00
|
|
|
return isScreenAudioShared(state) || isScreenVideoShared(state);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Is screen sharing currently active.
|
|
|
|
*
|
2022-10-20 09:11:27 +00:00
|
|
|
* @param {IReduxState} state - The state of the application.
|
2021-07-07 08:07:30 +00:00
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2022-10-20 09:11:27 +00:00
|
|
|
export function isScreenVideoShared(state: IReduxState) {
|
2022-03-15 17:24:49 +00:00
|
|
|
const tracks = state['features/base/tracks'];
|
|
|
|
const localScreenshare = getLocalDesktopTrack(tracks);
|
|
|
|
|
2022-08-01 21:03:53 +00:00
|
|
|
if (getMultipleVideoSendingSupportFeatureFlag(state)) {
|
2022-09-29 11:45:34 +00:00
|
|
|
return localScreenshare?.jitsiTrack && !localScreenshare.jitsiTrack.isMuted();
|
2022-03-15 17:24:49 +00:00
|
|
|
}
|
|
|
|
const localVideo = getLocalVideoTrack(tracks);
|
2021-07-07 08:07:30 +00:00
|
|
|
|
|
|
|
// $FlowFixMe - No support for optional chain method calls in flow atm.
|
|
|
|
return localVideo?.jitsiTrack?.getVideoType() === VIDEO_TYPE.DESKTOP;
|
2021-04-12 07:37:39 +00:00
|
|
|
}
|