Skip to content

Commit

Permalink
fix: disable VB for older safari versions
Browse files Browse the repository at this point in the history
  • Loading branch information
KaustubhKumar05 authored Aug 5, 2024
1 parent 2f0ba60 commit 3f036fd
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 19 deletions.
7 changes: 1 addition & 6 deletions packages/hms-video-store/src/interfaces/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,8 @@ export interface HMSRoom {
description?: string;
max_size?: number;
large_room_optimization?: boolean;
/**
* @alpha
*/
isEffectsEnabled?: boolean;
/**
* @alpha
*/
isVBEnabled?: boolean;
effectsKey?: string;
isHipaaEnabled?: boolean;
isNoiseCancellationEnabled?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ export class HMSLocalVideoTrack extends HMSVideoTrack {
} else {
await this.setProcessedTrack();
}
this.videoHandler.updateSinks();
} catch (e) {
console.error('error in processing plugin(s)', e);
}
Expand Down
1 change: 1 addition & 0 deletions packages/hms-video-store/src/reactive-store/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export class SDKToHMS {
peerCount: sdkRoom.peerCount,
isLargeRoom: sdkRoom.large_room_optimization,
isEffectsEnabled: sdkRoom.isEffectsEnabled,
isVBEnabled: sdkRoom.isVBEnabled,
effectsKey: sdkRoom.effectsKey,
isHipaaEnabled: sdkRoom.isHipaaEnabled,
isNoiseCancellationEnabled: sdkRoom.isNoiseCancellationEnabled,
Expand Down
1 change: 1 addition & 0 deletions packages/hms-video-store/src/schema/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export interface HMSRoom {
peerCount?: number;
isLargeRoom?: boolean;
isEffectsEnabled?: boolean;
isVBEnabled?: boolean;
effectsKey?: string;
isHipaaEnabled?: boolean;
isNoiseCancellationEnabled?: boolean;
Expand Down
7 changes: 1 addition & 6 deletions packages/hms-video-store/src/sdk/models/HMSRoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,8 @@ export default class Room implements HMSRoom {
max_size?: number;
large_room_optimization?: boolean;
transcriptions?: HMSTranscriptionInfo[] = [];
/**
* @alpha
*/
isEffectsEnabled?: boolean;
/**
* @alpha
*/
isVBEnabled?: boolean;
effectsKey?: string;
isHipaaEnabled?: boolean;
isNoiseCancellationEnabled?: boolean;
Expand Down
1 change: 1 addition & 0 deletions packages/hms-video-store/src/selectors/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ export const selectSessionId = createSelector(selectRoom, room => room.sessionId
export const selectRoomStartTime = createSelector(selectRoom, room => room.startedAt);
export const selectIsLargeRoom = createSelector(selectRoom, room => !!room.isLargeRoom);
export const selectIsEffectsEnabled = createSelector(selectRoom, room => !!room.isEffectsEnabled);
export const selectIsVBEnabled = createSelector(selectRoom, room => !!room.isVBEnabled);
export const selectEffectsKey = createSelector(selectRoom, room => room.effectsKey);

export const selectTemplateAppData = (store: HMSStore) => store.templateAppData;
Expand Down
1 change: 1 addition & 0 deletions packages/hms-video-store/src/signal/init/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export enum InitFlags {
FLAG_DISABLE_VIDEO_TRACK_AUTO_UNSUBSCRIBE = 'disableVideoTrackAutoUnsubscribe',
FLAG_WHITEBOARD_ENABLED = 'whiteboardEnabled',
FLAG_EFFECTS_SDK_ENABLED = 'effectsSDKEnabled',
FLAG_VB_ENABLED = 'vb',
FLAG_HIPAA_ENABLED = 'hipaa',
FLAG_NOISE_CANCELLATION = 'noiseCancellation',
FLAG_SCALE_SCREENSHARE_BASED_ON_PIXELS = 'scaleScreenshareBasedOnPixels',
Expand Down
1 change: 1 addition & 0 deletions packages/hms-video-store/src/transport/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1062,6 +1062,7 @@ export default class HMSTransport {
if (room) {
room.effectsKey = this.initConfig.config.vb?.effectsKey;
room.isEffectsEnabled = this.isFlagEnabled(InitFlags.FLAG_EFFECTS_SDK_ENABLED);
room.isVBEnabled = this.isFlagEnabled(InitFlags.FLAG_VB_ENABLED);
room.isHipaaEnabled = this.isFlagEnabled(InitFlags.FLAG_HIPAA_ENABLED);
room.isNoiseCancellationEnabled = this.isFlagEnabled(InitFlags.FLAG_NOISE_CANCELLATION);
}
Expand Down
6 changes: 5 additions & 1 deletion packages/hms-virtual-background/src/HMSVBPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,13 @@ export class HMSVBPlugin implements HMSVideoPlugin {
return this.checkSupport().isSupported;
}

isBlurSupported(): boolean {
return 'filter' in CanvasRenderingContext2D.prototype;
}

checkSupport(): HMSPluginSupportResult {
const browserResult = {} as HMSPluginSupportResult;
if (['Chrome', 'Firefox', 'Edg', 'Edge'].some(value => navigator.userAgent.indexOf(value) !== -1)) {
if (['Chrome', 'Firefox', 'Edg', 'Edge', 'Safari'].some(value => navigator.userAgent.indexOf(value) !== -1)) {
browserResult.isSupported = true;
} else {
browserResult.isSupported = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
HMSRoomState,
selectAppData,
selectIsLocalVideoEnabled,
selectIsVBEnabled,
selectLocalPeer,
selectRoomState,
selectVideoTrackByID,
Expand Down Expand Up @@ -253,6 +254,7 @@ export const PreviewTile = ({ name, error }: { name: string; error?: boolean })

export const PreviewControls = ({ hideSettings, vbEnabled }: { hideSettings: boolean; vbEnabled: boolean }) => {
const isMobile = useMedia(cssConfig.media.md);
const isVBEnabledForUser = useHMSStore(selectIsVBEnabled);
return (
<Flex
justify={hideSettings && isMobile ? 'center' : 'between'}
Expand All @@ -263,7 +265,7 @@ export const PreviewControls = ({ hideSettings, vbEnabled }: { hideSettings: boo
>
<Flex css={{ gap: '$4' }}>
<AudioVideoToggle />
{vbEnabled ? <VBToggle /> : null}
{vbEnabled && isVBEnabledForUser ? <VBToggle /> : null}
</Flex>
<Flex align="center" gap="1">
{isMobile && <NoiseCancellation iconOnly />}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { HMSEffectsPlugin, HMSVBPlugin, HMSVirtualBackgroundTypes } from '@100mslive/hms-virtual-background';

export class VBPlugin {
private hmsPlugin?: HMSVBPlugin;
private effectsPlugin?: HMSEffectsPlugin | undefined;
private effectsPlugin?: HMSEffectsPlugin;

initialisePlugin = (effectsSDKKey?: string, onInit?: () => void) => {
if (this.getVBObject()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ export const VBPicker = ({ backgroundMedia = [] }: { backgroundMedia: VirtualBac
if (!track?.id) {
return;
}
if (!isPluginAdded) {
const vbObject = VBHandler.getVBObject();
if (!isPluginAdded && !vbObject) {
setLoadingEffects(true);
let vbObject = VBHandler.getVBObject();
if (!vbObject) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import React from 'react';
import { selectAppData, selectIsEffectsEnabled, selectIsLocalVideoEnabled, useHMSStore } from '@100mslive/react-sdk';
import {
selectAppData,
selectIsEffectsEnabled,
selectIsLocalVideoEnabled,
selectIsVBEnabled,
useHMSStore,
} from '@100mslive/react-sdk';
import { VirtualBackgroundIcon } from '@100mslive/react-icons';
import { Loading } from '../../../Loading';
import { Tooltip } from '../../../Tooltip';
Expand All @@ -12,10 +18,11 @@ export const VBToggle = () => {
const toggleVB = useSidepaneToggle(SIDE_PANE_OPTIONS.VB);
const isVBOpen = useIsSidepaneTypeOpen(SIDE_PANE_OPTIONS.VB);
const isVideoOn = useHMSStore(selectIsLocalVideoEnabled);
const isVBEnabled = useHMSStore(selectIsVBEnabled);
const isEffectsEnabled = useHMSStore(selectIsEffectsEnabled);
const loadingEffects = useHMSStore(selectAppData(APP_DATA.loadingEffects));

if (!isVideoOn || (!isEffectsEnabled && isSafari)) {
if (!isVideoOn || (!isEffectsEnabled && isSafari) || !isVBEnabled) {
return null;
}

Expand Down

0 comments on commit 3f036fd

Please sign in to comment.