Skip to content

Commit

Permalink
fix: add init flag check
Browse files Browse the repository at this point in the history
  • Loading branch information
amar-1995 committed Mar 20, 2024
1 parent a16fa91 commit b63b454
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
7 changes: 5 additions & 2 deletions packages/hms-video-store/src/sdk/LocalTrackManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions packages/hms-video-store/src/sdk/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
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 @@ -60,4 +60,5 @@ export enum InitFlags {
FLAG_EFFECTS_SDK_ENABLED = 'effectsSDKEnabled',
FLAG_HIPAA_ENABLED = 'hipaa',
FLAG_NOISE_CANCELLATION = 'noiseCancellation',
FLAG_SCREENSHARE_OPTIMIZATION = 'optimizeScreenshare',
}

0 comments on commit b63b454

Please sign in to comment.