diff --git a/packages/hms-video-store/src/sdk/LocalTrackManager.ts b/packages/hms-video-store/src/sdk/LocalTrackManager.ts index 939bc8ade6..a6f3b58aae 100644 --- a/packages/hms-video-store/src/sdk/LocalTrackManager.ts +++ b/packages/hms-video-store/src/sdk/LocalTrackManager.ts @@ -189,7 +189,7 @@ export class LocalTrackManager { } }); } - async getLocalScreen(partialConfig?: HMSScreenShareConfig) { + async getLocalScreen(partialConfig?: HMSScreenShareConfig, needOptimized = false) { const config = await this.getOrDefaultScreenshareConfig(partialConfig); const screenSettings = this.getScreenshareSettings(config.videoOnly); const constraints = { @@ -217,8 +217,11 @@ export class LocalTrackManager { HMSLogger.d('retrieving screenshare with ', { config }, { constraints }); // @ts-ignore [https://github.com/microsoft/TypeScript/issues/33232] stream = (await navigator.mediaDevices.getDisplayMedia(constraints)) as MediaStream; - // todo change stream logic + console.log('need optimization ', needOptimized); + // TODO remove after testing + // if (needOptimized) { await this.optimizeScreenShareConstraint(stream, constraints); + // } } catch (err) { HMSLogger.w(this.TAG, 'error in getting screenshare - ', err); const error = BuildGetMediaError(err as Error, HMSGetMediaActions.SCREEN); diff --git a/packages/hms-video-store/src/sdk/index.ts b/packages/hms-video-store/src/sdk/index.ts index 5d8de0e8ea..ce9262bc35 100644 --- a/packages/hms-video-store/src/sdk/index.ts +++ b/packages/hms-video-store/src/sdk/index.ts @@ -63,7 +63,7 @@ import { createRemotePeer } from '../notification-manager/managers/utils'; import { NotificationManager } from '../notification-manager/NotificationManager'; import { SessionStore } from '../session-store'; import { InteractivityCenter } from '../session-store/interactivity-center'; -import { InitConfig } from '../signal/init/models'; +import { InitConfig, InitFlags } from '../signal/init/models'; import { HLSRequestParams, HLSTimedMetadataParams, @@ -1345,7 +1345,8 @@ export class HMSSdk implements HMSInterface { * @returns */ private async getScreenshareTracks(onStop: () => void, config?: HMSScreenShareConfig) { - const [videoTrack, audioTrack] = await this.localTrackManager.getLocalScreen(config); + const isOptimizedScreenShare = this.transport.isFlagEnabled(InitFlags.FLAG_SCREENSHARE_OPTIMIZATION); + const [videoTrack, audioTrack] = await this.localTrackManager.getLocalScreen(config, isOptimizedScreenShare); const handleEnded = () => { this.stopEndedScreenshare(onStop); diff --git a/packages/hms-video-store/src/signal/init/models.ts b/packages/hms-video-store/src/signal/init/models.ts index 75e6b12c02..b9e7c40e45 100644 --- a/packages/hms-video-store/src/signal/init/models.ts +++ b/packages/hms-video-store/src/signal/init/models.ts @@ -60,4 +60,5 @@ export enum InitFlags { FLAG_EFFECTS_SDK_ENABLED = 'effectsSDKEnabled', FLAG_HIPAA_ENABLED = 'hipaa', FLAG_NOISE_CANCELLATION = 'noiseCancellation', + FLAG_SCREENSHARE_OPTIMIZATION = 'optimizeScreenshare', }