From 9389b818acab0ca99468e04591429b168679303b Mon Sep 17 00:00:00 2001 From: hdz-666 <93115614+hdz-666@users.noreply.github.com> Date: Tue, 29 Oct 2024 13:48:59 +0530 Subject: [PATCH 01/20] fix: add new change for exception --- .../hms-video-store/src/error/HMSException.ts | 20 +++++++++++++++++++ packages/hms-video-store/src/error/utils.ts | 1 + 2 files changed, 21 insertions(+) diff --git a/packages/hms-video-store/src/error/HMSException.ts b/packages/hms-video-store/src/error/HMSException.ts index 03c6afa687..1f0567f41c 100644 --- a/packages/hms-video-store/src/error/HMSException.ts +++ b/packages/hms-video-store/src/error/HMSException.ts @@ -13,6 +13,7 @@ export class HMSException extends Error implements IAnalyticsPropertiesProvider public message: string, public description: string, public isTerminal: boolean = false, + public deviceType: string = '', ) { super(message); @@ -29,6 +30,7 @@ export class HMSException extends Error implements IAnalyticsPropertiesProvider error_description: this.description, action: this.action, is_terminal: this.isTerminal, + device_type: this.deviceType, }; } @@ -36,7 +38,25 @@ export class HMSException extends Error implements IAnalyticsPropertiesProvider this.nativeError = error; } + //add method to set HMSGetMediaActions as deviceType + addDeviceType(deviceType: string) { + this.deviceType = deviceType; + } + toString() { + //add deviceType to the string representation of the error + if (this.deviceType) { + return `{ + code: ${this.code}; + name: ${this.name}; + action: ${this.action}; + message: ${this.message}; + description: ${this.description}; + isTerminal: ${this.isTerminal}; + nativeError: ${this.nativeError?.message}; + deviceType: ${this.deviceType}; + }`; + } return `{ code: ${this.code}; name: ${this.name}; diff --git a/packages/hms-video-store/src/error/utils.ts b/packages/hms-video-store/src/error/utils.ts index 42dea262ce..16b31937a6 100644 --- a/packages/hms-video-store/src/error/utils.ts +++ b/packages/hms-video-store/src/error/utils.ts @@ -73,5 +73,6 @@ function convertMediaErrorToHMSException(err: Error, deviceInfo = ''): HMSExcept export function BuildGetMediaError(err: Error, deviceInfo: string): HMSException { const exception = convertMediaErrorToHMSException(err, deviceInfo); exception.addNativeError(err); + exception.addDeviceType(deviceInfo); return exception; } From 08ff473ac0a7d91da5ed7aefda93068de3d4391f Mon Sep 17 00:00:00 2001 From: hdz-666 <93115614+hdz-666@users.noreply.github.com> Date: Tue, 29 Oct 2024 14:18:47 +0530 Subject: [PATCH 02/20] fix: add new changes for exceptions --- packages/hms-video-store/src/error/HMSException.ts | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/packages/hms-video-store/src/error/HMSException.ts b/packages/hms-video-store/src/error/HMSException.ts index 1f0567f41c..1b1f77b719 100644 --- a/packages/hms-video-store/src/error/HMSException.ts +++ b/packages/hms-video-store/src/error/HMSException.ts @@ -44,9 +44,7 @@ export class HMSException extends Error implements IAnalyticsPropertiesProvider } toString() { - //add deviceType to the string representation of the error - if (this.deviceType) { - return `{ + return `{ code: ${this.code}; name: ${this.name}; action: ${this.action}; @@ -56,15 +54,5 @@ export class HMSException extends Error implements IAnalyticsPropertiesProvider nativeError: ${this.nativeError?.message}; deviceType: ${this.deviceType}; }`; - } - return `{ - code: ${this.code}; - name: ${this.name}; - action: ${this.action}; - message: ${this.message}; - description: ${this.description}; - isTerminal: ${this.isTerminal}; - nativeError: ${this.nativeError?.message}; - }`; } } From f3ba7db28e1a5f7243711e2eecd38645cc4c7099 Mon Sep 17 00:00:00 2001 From: hdz-666 <93115614+hdz-666@users.noreply.github.com> Date: Tue, 29 Oct 2024 14:50:59 +0530 Subject: [PATCH 03/20] fix: console error object modified --- packages/hms-video-store/src/error/utils.ts | 13 +++++++++---- .../hms-video-store/src/reactive-store/adapter.ts | 13 +++++++++++++ packages/hms-video-store/src/schema/error.ts | 1 + 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/packages/hms-video-store/src/error/utils.ts b/packages/hms-video-store/src/error/utils.ts index 16b31937a6..370f1202fd 100644 --- a/packages/hms-video-store/src/error/utils.ts +++ b/packages/hms-video-store/src/error/utils.ts @@ -13,13 +13,18 @@ export enum HMSGetMediaActions { function getDefaultError(error: string, deviceInfo: string) { const message = error.toLowerCase(); + let exception = ErrorFactory.TracksErrors.GenericTrack(HMSAction.TRACK, error); + if (message.includes('device not found')) { - return ErrorFactory.TracksErrors.DeviceNotAvailable(HMSAction.TRACK, deviceInfo, error); + exception = ErrorFactory.TracksErrors.DeviceNotAvailable(HMSAction.TRACK, deviceInfo, error); } else if (message.includes('permission denied')) { - return ErrorFactory.TracksErrors.CantAccessCaptureDevice(HMSAction.TRACK, deviceInfo, error); - } else { - return ErrorFactory.TracksErrors.GenericTrack(HMSAction.TRACK, error); + exception = ErrorFactory.TracksErrors.CantAccessCaptureDevice(HMSAction.TRACK, deviceInfo, error); + } + if (deviceInfo) { + exception.addDeviceType(deviceInfo); } + + return exception; } /** diff --git a/packages/hms-video-store/src/reactive-store/adapter.ts b/packages/hms-video-store/src/reactive-store/adapter.ts index c765a4c8b3..8f2fa0ed0b 100644 --- a/packages/hms-video-store/src/reactive-store/adapter.ts +++ b/packages/hms-video-store/src/reactive-store/adapter.ts @@ -204,6 +204,19 @@ export class SDKToHMS { } static convertException(sdkException: sdkTypes.HMSException): HMSException { + if (sdkException.deviceType) { + return { + code: sdkException.code, + action: sdkException.action, + name: sdkException.name, + message: sdkException.message, + description: sdkException.description, + isTerminal: sdkException.isTerminal, + nativeError: sdkException.nativeError, + deviceType: sdkException.deviceType, + timestamp: new Date(), + }; + } return { code: sdkException.code, action: sdkException.action, diff --git a/packages/hms-video-store/src/schema/error.ts b/packages/hms-video-store/src/schema/error.ts index 7a19a4a7a0..285565d740 100644 --- a/packages/hms-video-store/src/schema/error.ts +++ b/packages/hms-video-store/src/schema/error.ts @@ -10,4 +10,5 @@ export interface HMSException { isTerminal: boolean; timestamp: Date; nativeError?: Error; + deviceType?: string; } From 7f1e659d99ee72e343dddb8e75af65fcddf6127e Mon Sep 17 00:00:00 2001 From: hdz-666 <93115614+hdz-666@users.noreply.github.com> Date: Wed, 30 Oct 2024 12:29:26 +0530 Subject: [PATCH 04/20] fix: reactive store comments --- packages/hms-video-store/src/error/utils.ts | 3 --- .../src/reactive-store/adapter.ts | 21 ++++++------------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/packages/hms-video-store/src/error/utils.ts b/packages/hms-video-store/src/error/utils.ts index 370f1202fd..f1c70d113c 100644 --- a/packages/hms-video-store/src/error/utils.ts +++ b/packages/hms-video-store/src/error/utils.ts @@ -20,9 +20,6 @@ function getDefaultError(error: string, deviceInfo: string) { } else if (message.includes('permission denied')) { exception = ErrorFactory.TracksErrors.CantAccessCaptureDevice(HMSAction.TRACK, deviceInfo, error); } - if (deviceInfo) { - exception.addDeviceType(deviceInfo); - } return exception; } diff --git a/packages/hms-video-store/src/reactive-store/adapter.ts b/packages/hms-video-store/src/reactive-store/adapter.ts index 8f2fa0ed0b..90d0217311 100644 --- a/packages/hms-video-store/src/reactive-store/adapter.ts +++ b/packages/hms-video-store/src/reactive-store/adapter.ts @@ -204,20 +204,7 @@ export class SDKToHMS { } static convertException(sdkException: sdkTypes.HMSException): HMSException { - if (sdkException.deviceType) { - return { - code: sdkException.code, - action: sdkException.action, - name: sdkException.name, - message: sdkException.message, - description: sdkException.description, - isTerminal: sdkException.isTerminal, - nativeError: sdkException.nativeError, - deviceType: sdkException.deviceType, - timestamp: new Date(), - }; - } - return { + const exp = { code: sdkException.code, action: sdkException.action, name: sdkException.name, @@ -226,7 +213,11 @@ export class SDKToHMS { isTerminal: sdkException.isTerminal, nativeError: sdkException.nativeError, timestamp: new Date(), - }; + } as HMSException; + if (sdkException.deviceType) { + exp.deviceType = sdkException.deviceType; + } + return exp; } static convertDeviceChangeUpdate(sdkDeviceChangeEvent: sdkTypes.HMSDeviceChangeEvent): HMSDeviceChangeEvent { From 75d9fa4578f0264cc950d3c69f50f33060cec6d4 Mon Sep 17 00:00:00 2001 From: hdz-666 <93115614+hdz-666@users.noreply.github.com> Date: Wed, 30 Oct 2024 13:23:04 +0530 Subject: [PATCH 05/20] fix: add new changes for metadata --- packages/hms-video-store/src/error/HMSException.ts | 10 +++++----- packages/hms-video-store/src/error/utils.ts | 3 ++- packages/hms-video-store/src/reactive-store/adapter.ts | 4 ++-- packages/hms-video-store/src/schema/error.ts | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/packages/hms-video-store/src/error/HMSException.ts b/packages/hms-video-store/src/error/HMSException.ts index 1b1f77b719..7e26f282e5 100644 --- a/packages/hms-video-store/src/error/HMSException.ts +++ b/packages/hms-video-store/src/error/HMSException.ts @@ -13,7 +13,7 @@ export class HMSException extends Error implements IAnalyticsPropertiesProvider public message: string, public description: string, public isTerminal: boolean = false, - public deviceType: string = '', + public metadata: Record = {}, ) { super(message); @@ -30,7 +30,7 @@ export class HMSException extends Error implements IAnalyticsPropertiesProvider error_description: this.description, action: this.action, is_terminal: this.isTerminal, - device_type: this.deviceType, + metadata: this.metadata, }; } @@ -39,8 +39,8 @@ export class HMSException extends Error implements IAnalyticsPropertiesProvider } //add method to set HMSGetMediaActions as deviceType - addDeviceType(deviceType: string) { - this.deviceType = deviceType; + addMetadata(metadata: Record) { + this.metadata = metadata; } toString() { @@ -52,7 +52,7 @@ export class HMSException extends Error implements IAnalyticsPropertiesProvider description: ${this.description}; isTerminal: ${this.isTerminal}; nativeError: ${this.nativeError?.message}; - deviceType: ${this.deviceType}; + metadata: ${this.metadata}; }`; } } diff --git a/packages/hms-video-store/src/error/utils.ts b/packages/hms-video-store/src/error/utils.ts index f1c70d113c..8cdd6b7a1b 100644 --- a/packages/hms-video-store/src/error/utils.ts +++ b/packages/hms-video-store/src/error/utils.ts @@ -75,6 +75,7 @@ function convertMediaErrorToHMSException(err: Error, deviceInfo = ''): HMSExcept export function BuildGetMediaError(err: Error, deviceInfo: string): HMSException { const exception = convertMediaErrorToHMSException(err, deviceInfo); exception.addNativeError(err); - exception.addDeviceType(deviceInfo); + const device = { deviceType: deviceInfo }; + exception.addMetadata(device); return exception; } diff --git a/packages/hms-video-store/src/reactive-store/adapter.ts b/packages/hms-video-store/src/reactive-store/adapter.ts index 90d0217311..ad2b46ff8e 100644 --- a/packages/hms-video-store/src/reactive-store/adapter.ts +++ b/packages/hms-video-store/src/reactive-store/adapter.ts @@ -214,8 +214,8 @@ export class SDKToHMS { nativeError: sdkException.nativeError, timestamp: new Date(), } as HMSException; - if (sdkException.deviceType) { - exp.deviceType = sdkException.deviceType; + if (sdkException.metadata) { + exp.metadata = sdkException.metadata; } return exp; } diff --git a/packages/hms-video-store/src/schema/error.ts b/packages/hms-video-store/src/schema/error.ts index 285565d740..acb2b40eed 100644 --- a/packages/hms-video-store/src/schema/error.ts +++ b/packages/hms-video-store/src/schema/error.ts @@ -10,5 +10,5 @@ export interface HMSException { isTerminal: boolean; timestamp: Date; nativeError?: Error; - deviceType?: string; + metadata?: Record; } From 8362233118f48a1a0618f85ee3a9871a1329c90a Mon Sep 17 00:00:00 2001 From: hdz-666 <93115614+hdz-666@users.noreply.github.com> Date: Wed, 30 Oct 2024 13:23:04 +0530 Subject: [PATCH 06/20] fix: add new changes for metadata --- .../src/device-manager/DeviceManager.ts | 5 +- .../src/diagnostics/ConnectivityCheck.ts | 10 ++-- .../hms-video-store/src/error/ErrorFactory.ts | 53 ++++++++++++------- .../hms-video-store/src/error/HMSException.ts | 38 ++++++++++--- packages/hms-video-store/src/error/utils.ts | 7 ++- .../src/media/tracks/HMSAudioTrack.ts | 4 +- .../src/media/tracks/HMSTrack.ts | 4 +- .../src/media/tracks/HMSTrackKind.ts | 4 ++ .../src/media/tracks/HMSTrackType.ts | 2 + .../src/media/tracks/HMSVideoTrack.ts | 4 +- .../hms-video-store/src/media/tracks/index.ts | 2 +- .../managers/TrackManager.ts | 18 +++---- .../src/reactive-store/adapter.ts | 6 ++- packages/hms-video-store/src/schema/error.ts | 15 +++++- .../src/sdk/LocalTrackManager.ts | 23 ++++---- packages/hms-video-store/src/sdk/index.ts | 8 +-- .../hms-video-store/src/sdk/store/Store.ts | 6 +-- packages/hms-video-store/src/utils/media.ts | 9 ++-- packages/hms-video-store/src/utils/track.ts | 7 +-- 19 files changed, 145 insertions(+), 80 deletions(-) create mode 100644 packages/hms-video-store/src/media/tracks/HMSTrackKind.ts diff --git a/packages/hms-video-store/src/device-manager/DeviceManager.ts b/packages/hms-video-store/src/device-manager/DeviceManager.ts index 41ef7972b7..2e463a204c 100644 --- a/packages/hms-video-store/src/device-manager/DeviceManager.ts +++ b/packages/hms-video-store/src/device-manager/DeviceManager.ts @@ -7,6 +7,7 @@ import { DeviceMap, HMSDeviceChangeEvent, SelectedDevices } from '../interfaces' import { getAudioDeviceCategory, HMSAudioDeviceCategory, isIOS } from '../internal'; import { HMSAudioTrackSettingsBuilder, HMSVideoTrackSettingsBuilder } from '../media/settings'; import { HMSLocalAudioTrack, HMSLocalTrack, HMSLocalVideoTrack } from '../media/tracks'; +import { HMSTrackType } from '../media/tracks/HMSTrackType'; import { Store } from '../sdk/store'; import HMSLogger from '../utils/logger'; import { debounce } from '../utils/timer-utils'; @@ -325,7 +326,7 @@ export class DeviceManager implements HMSDeviceManager { this.eventBus.analytics.publish( AnalyticsEventFactory.deviceChange({ selection: { audioInput: newSelection }, - error: ErrorFactory.TracksErrors.SelectedDeviceMissing('audio'), + error: ErrorFactory.TracksErrors.SelectedDeviceMissing(HMSTrackType.AUDIO), devices: this.getDevices(), type: 'audioInput', }), @@ -383,7 +384,7 @@ export class DeviceManager implements HMSDeviceManager { this.eventBus.analytics.publish( AnalyticsEventFactory.deviceChange({ selection: { videoInput: newSelection }, - error: ErrorFactory.TracksErrors.SelectedDeviceMissing('video'), + error: ErrorFactory.TracksErrors.SelectedDeviceMissing(HMSTrackType.VIDEO), devices: this.getDevices(), type: 'video', }), diff --git a/packages/hms-video-store/src/diagnostics/ConnectivityCheck.ts b/packages/hms-video-store/src/diagnostics/ConnectivityCheck.ts index ca5a2353bd..5ef8e147ca 100644 --- a/packages/hms-video-store/src/diagnostics/ConnectivityCheck.ts +++ b/packages/hms-video-store/src/diagnostics/ConnectivityCheck.ts @@ -8,7 +8,7 @@ import { HMSException, HMSRoom, HMSTrack, - HMSTrackType, + HMSTrackKind, HMSTrackUpdate, HMSUpdateListener, } from '../internal'; @@ -108,10 +108,10 @@ export class ConnectivityCheck implements HMSDiagnosticsConnectivityListener { onMediaPublished(track: HMSTrack): void { switch (track.type) { - case HMSTrackType.AUDIO: + case HMSTrackKind.AUDIO: this.isAudioTrackPublished = true; break; - case HMSTrackType.VIDEO: + case HMSTrackKind.VIDEO: this.isVideoTrackPublished = true; break; default: @@ -156,10 +156,10 @@ export class ConnectivityCheck implements HMSDiagnosticsConnectivityListener { this.sdkListener.onTrackUpdate(type, track, peer); if (peer.isLocal && type === HMSTrackUpdate.TRACK_ADDED) { switch (track.type) { - case HMSTrackType.AUDIO: + case HMSTrackKind.AUDIO: this.isAudioTrackCaptured = true; break; - case HMSTrackType.VIDEO: + case HMSTrackKind.VIDEO: this.isVideoTrackCaptured = true; break; default: diff --git a/packages/hms-video-store/src/error/ErrorFactory.ts b/packages/hms-video-store/src/error/ErrorFactory.ts index 7345d26749..fa48202ba9 100644 --- a/packages/hms-video-store/src/error/ErrorFactory.ts +++ b/packages/hms-video-store/src/error/ErrorFactory.ts @@ -7,7 +7,8 @@ import { ErrorCodes } from './ErrorCodes'; import { HMSAction } from './HMSAction'; -import { HMSException } from './HMSException'; +import { HMSException, HMSTrackException } from './HMSException'; +import { HMSTrackType } from '../media/tracks/HMSTrackType'; import { HMSSignalMethod } from '../signal/jsonrpc/models'; const terminalActions: (HMSSignalMethod | HMSAction)[] = [ @@ -98,52 +99,56 @@ export const ErrorFactory = { TracksErrors: { GenericTrack(action: HMSAction, description = '') { - return new HMSException( + return new HMSTrackException( ErrorCodes.TracksErrors.GENERIC_TRACK, 'GenericTrack', action, `[TRACK]: ${description}`, `[TRACK]: ${description}`, + HMSTrackType.AV, ); }, - CantAccessCaptureDevice(action: HMSAction, deviceInfo: string, description = '') { - return new HMSException( + return new HMSTrackException( ErrorCodes.TracksErrors.CANT_ACCESS_CAPTURE_DEVICE, 'CantAccessCaptureDevice', action, `User denied permission to access capture device - ${deviceInfo}`, description, + deviceInfo as HMSTrackType, ); }, DeviceNotAvailable(action: HMSAction, deviceInfo: string, description = '') { - return new HMSException( + return new HMSTrackException( ErrorCodes.TracksErrors.DEVICE_NOT_AVAILABLE, 'DeviceNotAvailable', action, `[TRACK]: Capture device is no longer available - ${deviceInfo}`, description, + deviceInfo as HMSTrackType, ); }, DeviceInUse(action: HMSAction, deviceInfo: string, description = '') { - return new HMSException( + return new HMSTrackException( ErrorCodes.TracksErrors.DEVICE_IN_USE, 'DeviceInUse', action, `[TRACK]: Capture device is in use by another application - ${deviceInfo}`, description, + deviceInfo as HMSTrackType, ); }, DeviceLostMidway(action: HMSAction, deviceInfo: string, description = '') { - return new HMSException( + return new HMSTrackException( ErrorCodes.TracksErrors.DEVICE_LOST_MIDWAY, 'DeviceLostMidway', action, `Lost access to capture device midway - ${deviceInfo}`, description, + deviceInfo as HMSTrackType, ); }, @@ -152,113 +157,123 @@ export const ErrorFactory = { description = '', message = `There is no media to return. Please select either video or audio or both.`, ) { - return new HMSException( + return new HMSTrackException( ErrorCodes.TracksErrors.NOTHING_TO_RETURN, 'NothingToReturn', action, message, description, + HMSTrackType.AV, ); }, InvalidVideoSettings(action: HMSAction, description = '') { - return new HMSException( + return new HMSTrackException( ErrorCodes.TracksErrors.INVALID_VIDEO_SETTINGS, 'InvalidVideoSettings', action, `Cannot enable simulcast when no video settings are provided`, description, + HMSTrackType.VIDEO, ); }, AutoplayBlocked(action: HMSAction, description = '') { - return new HMSException( + return new HMSTrackException( ErrorCodes.TracksErrors.AUTOPLAY_ERROR, 'AutoplayBlocked', action, "Autoplay blocked because the user didn't interact with the document first", description, + HMSTrackType.AUDIO, ); }, CodecChangeNotPermitted(action: HMSAction, description = '') { - return new HMSException( + return new HMSTrackException( ErrorCodes.TracksErrors.CODEC_CHANGE_NOT_PERMITTED, 'CodecChangeNotPermitted', action, `Codec can't be changed mid call.`, description, + HMSTrackType.AV, ); }, OverConstrained(action: HMSAction, deviceInfo: string, description = '') { - return new HMSException( + return new HMSTrackException( ErrorCodes.TracksErrors.OVER_CONSTRAINED, 'OverConstrained', action, `[TRACK]: Requested constraints cannot be satisfied with the device hardware - ${deviceInfo}`, description, + deviceInfo as HMSTrackType, ); }, NoAudioDetected(action: HMSAction, description = 'Please check the mic or use another audio input') { - return new HMSException( + return new HMSTrackException( ErrorCodes.TracksErrors.NO_AUDIO_DETECTED, 'NoAudioDetected', action, 'No audio input detected from microphone', description, + HMSTrackType.AUDIO, ); }, SystemDeniedPermission(action: HMSAction, deviceInfo: string, description = '') { - return new HMSException( + return new HMSTrackException( ErrorCodes.TracksErrors.SYSTEM_DENIED_PERMISSION, 'SystemDeniedPermission', action, `Operating System denied permission to access capture device - ${deviceInfo}`, description, + deviceInfo as HMSTrackType, ); }, CurrentTabNotShared() { - return new HMSException( + return new HMSTrackException( ErrorCodes.TracksErrors.CURRENT_TAB_NOT_SHARED, 'CurrentTabNotShared', HMSAction.TRACK, 'The app requires you to share the current tab', 'You must screen share the current tab in order to proceed', + HMSTrackType.SCREEN, ); }, AudioPlaybackError(description: string) { - return new HMSException( + return new HMSTrackException( ErrorCodes.TracksErrors.AUDIO_PLAYBACK_ERROR, 'Audio playback error', HMSAction.TRACK, description, description, + HMSTrackType.AUDIO, ); }, SelectedDeviceMissing(deviceType: string) { - return new HMSException( + return new HMSTrackException( ErrorCodes.TracksErrors.SELECTED_DEVICE_MISSING, 'SelectedDeviceMissing', HMSAction.TRACK, `Could not detect selected ${deviceType} device`, `Please check connection to the ${deviceType} device`, - false, + deviceType as HMSTrackType, ); }, NoDataInTrack(description: string) { - return new HMSException( + return new HMSTrackException( ErrorCodes.TracksErrors.NO_DATA, 'Track does not have any data', HMSAction.TRACK, description, 'This could possibily due to another application taking priority over the access to camera or microphone or due to an incoming call', + HMSTrackType.AV, ); }, }, diff --git a/packages/hms-video-store/src/error/HMSException.ts b/packages/hms-video-store/src/error/HMSException.ts index 1b1f77b719..ea1cf2e779 100644 --- a/packages/hms-video-store/src/error/HMSException.ts +++ b/packages/hms-video-store/src/error/HMSException.ts @@ -1,5 +1,6 @@ import { HMSAction } from './HMSAction'; import { IAnalyticsPropertiesProvider } from '../analytics/IAnalyticsPropertiesProvider'; +import { HMSTrackType } from '../media/tracks/HMSTrackType'; import { HMSSignalMethod } from '../signal/jsonrpc/models'; export class HMSException extends Error implements IAnalyticsPropertiesProvider { @@ -13,7 +14,6 @@ export class HMSException extends Error implements IAnalyticsPropertiesProvider public message: string, public description: string, public isTerminal: boolean = false, - public deviceType: string = '', ) { super(message); @@ -30,7 +30,6 @@ export class HMSException extends Error implements IAnalyticsPropertiesProvider error_description: this.description, action: this.action, is_terminal: this.isTerminal, - device_type: this.deviceType, }; } @@ -38,9 +37,36 @@ export class HMSException extends Error implements IAnalyticsPropertiesProvider this.nativeError = error; } - //add method to set HMSGetMediaActions as deviceType - addDeviceType(deviceType: string) { - this.deviceType = deviceType; + toString() { + return `{ + code: ${this.code}; + name: ${this.name}; + action: ${this.action}; + message: ${this.message}; + description: ${this.description}; + isTerminal: ${this.isTerminal}; + nativeError: ${this.nativeError?.message}; + }`; + } +} + +export class HMSTrackException extends HMSException { + constructor( + code: number, + name: string, + action: HMSAction | HMSSignalMethod, + message: string, + description: string, + public trackType: HMSTrackType, + ) { + super(code, name, action, message, description, false); + } + + toAnalyticsProperties() { + return { + ...super.toAnalyticsProperties(), + track_type: this.trackType, + }; } toString() { @@ -52,7 +78,7 @@ export class HMSException extends Error implements IAnalyticsPropertiesProvider description: ${this.description}; isTerminal: ${this.isTerminal}; nativeError: ${this.nativeError?.message}; - deviceType: ${this.deviceType}; + trackType: ${this.trackType}; }`; } } diff --git a/packages/hms-video-store/src/error/utils.ts b/packages/hms-video-store/src/error/utils.ts index f1c70d113c..a5084d8191 100644 --- a/packages/hms-video-store/src/error/utils.ts +++ b/packages/hms-video-store/src/error/utils.ts @@ -1,7 +1,7 @@ import adapter from 'webrtc-adapter'; import { ErrorFactory } from './ErrorFactory'; import { HMSAction } from './HMSAction'; -import { HMSException } from './HMSException'; +import { HMSTrackException } from './HMSException'; export enum HMSGetMediaActions { UNKNOWN = 'unknown(video or audio)', @@ -33,7 +33,7 @@ function getDefaultError(error: string, deviceInfo: string) { * System blocked - NotAllowedError - Permission denied by system */ // eslint-disable-next-line complexity -function convertMediaErrorToHMSException(err: Error, deviceInfo = ''): HMSException { +function convertMediaErrorToHMSException(err: Error, deviceInfo = ''): HMSTrackException { /** * Note: Adapter detects all chromium browsers as 'chrome' */ @@ -72,9 +72,8 @@ function convertMediaErrorToHMSException(err: Error, deviceInfo = ''): HMSExcept } } -export function BuildGetMediaError(err: Error, deviceInfo: string): HMSException { +export function BuildGetMediaError(err: Error, deviceInfo: string): HMSTrackException { const exception = convertMediaErrorToHMSException(err, deviceInfo); exception.addNativeError(err); - exception.addDeviceType(deviceInfo); return exception; } diff --git a/packages/hms-video-store/src/media/tracks/HMSAudioTrack.ts b/packages/hms-video-store/src/media/tracks/HMSAudioTrack.ts index 58fe7bc171..3ae665c463 100644 --- a/packages/hms-video-store/src/media/tracks/HMSAudioTrack.ts +++ b/packages/hms-video-store/src/media/tracks/HMSAudioTrack.ts @@ -1,11 +1,11 @@ import { HMSTrack, HMSTrackSource } from './HMSTrack'; -import { HMSTrackType } from './HMSTrackType'; +import { HMSTrackKind } from './HMSTrackKind'; import HMSLogger from '../../utils/logger'; import { isFirefox } from '../../utils/support'; import { HMSMediaStream, HMSRemoteStream } from '../streams'; export class HMSAudioTrack extends HMSTrack { - readonly type: HMSTrackType = HMSTrackType.AUDIO; + readonly type: HMSTrackKind = HMSTrackKind.AUDIO; private audioElement: HTMLAudioElement | null = null; private outputDevice?: MediaDeviceInfo; diff --git a/packages/hms-video-store/src/media/tracks/HMSTrack.ts b/packages/hms-video-store/src/media/tracks/HMSTrack.ts index 208d021ba4..7318713027 100644 --- a/packages/hms-video-store/src/media/tracks/HMSTrack.ts +++ b/packages/hms-video-store/src/media/tracks/HMSTrack.ts @@ -1,4 +1,4 @@ -import { HMSTrackType } from './HMSTrackType'; +import { HMSTrackKind } from './HMSTrackKind'; import AnalyticsEventFactory from '../../analytics/AnalyticsEventFactory'; import { stringifyMediaStreamTrack } from '../../utils/json'; import HMSLogger from '../../utils/logger'; @@ -44,7 +44,7 @@ export abstract class HMSTrack { */ private firstTrackId?: string; - abstract readonly type: HMSTrackType; + abstract readonly type: HMSTrackKind; public get enabled(): boolean { return this.nativeTrack.enabled; diff --git a/packages/hms-video-store/src/media/tracks/HMSTrackKind.ts b/packages/hms-video-store/src/media/tracks/HMSTrackKind.ts new file mode 100644 index 0000000000..26f1591f6f --- /dev/null +++ b/packages/hms-video-store/src/media/tracks/HMSTrackKind.ts @@ -0,0 +1,4 @@ +export enum HMSTrackKind { + AUDIO = 'audio', + VIDEO = 'video', +} diff --git a/packages/hms-video-store/src/media/tracks/HMSTrackType.ts b/packages/hms-video-store/src/media/tracks/HMSTrackType.ts index 6ec803f442..47e26ad9e6 100644 --- a/packages/hms-video-store/src/media/tracks/HMSTrackType.ts +++ b/packages/hms-video-store/src/media/tracks/HMSTrackType.ts @@ -1,4 +1,6 @@ export enum HMSTrackType { AUDIO = 'audio', VIDEO = 'video', + AV = 'audio, video', + SCREEN = 'screen', } diff --git a/packages/hms-video-store/src/media/tracks/HMSVideoTrack.ts b/packages/hms-video-store/src/media/tracks/HMSVideoTrack.ts index 8e577d4579..450b083e0f 100644 --- a/packages/hms-video-store/src/media/tracks/HMSVideoTrack.ts +++ b/packages/hms-video-store/src/media/tracks/HMSVideoTrack.ts @@ -1,12 +1,12 @@ import { HMSTrack, HMSTrackSource } from './HMSTrack'; -import { HMSTrackType } from './HMSTrackType'; +import { HMSTrackKind } from './HMSTrackKind'; import { VideoElementManager } from './VideoElementManager'; import HMSLogger from '../../utils/logger'; import { isSafari } from '../../utils/support'; import { HMSMediaStream } from '../streams'; export class HMSVideoTrack extends HMSTrack { - readonly type: HMSTrackType = HMSTrackType.VIDEO; + readonly type: HMSTrackKind = HMSTrackKind.VIDEO; private sinkCount = 0; videoHandler!: VideoElementManager; diff --git a/packages/hms-video-store/src/media/tracks/index.ts b/packages/hms-video-store/src/media/tracks/index.ts index 4472cee462..d71fdd5807 100644 --- a/packages/hms-video-store/src/media/tracks/index.ts +++ b/packages/hms-video-store/src/media/tracks/index.ts @@ -13,4 +13,4 @@ export * from './HMSRemoteAudioTrack'; export * from './HMSVideoTrack'; export * from './HMSLocalVideoTrack'; export * from './HMSRemoteVideoTrack'; -export * from './HMSTrackType'; +export * from './HMSTrackKind'; diff --git a/packages/hms-video-store/src/notification-manager/managers/TrackManager.ts b/packages/hms-video-store/src/notification-manager/managers/TrackManager.ts index d3feeba285..b909a90cbb 100644 --- a/packages/hms-video-store/src/notification-manager/managers/TrackManager.ts +++ b/packages/hms-video-store/src/notification-manager/managers/TrackManager.ts @@ -2,7 +2,7 @@ import { createRemotePeer } from './utils'; import { VideoTrackLayerUpdate } from '../../connection/channel-messages'; import { EventBus } from '../../events/EventBus'; import { HMSRemotePeer, HMSTrackUpdate, HMSUpdateListener } from '../../interfaces'; -import { HMSRemoteAudioTrack, HMSRemoteTrack, HMSRemoteVideoTrack, HMSTrackType } from '../../media/tracks'; +import { HMSRemoteAudioTrack, HMSRemoteTrack, HMSRemoteVideoTrack, HMSTrackKind } from '../../media/tracks'; import { HMSPeer } from '../../sdk/models/peer'; import { Store } from '../../sdk/store'; import HMSLogger from '../../utils/logger'; @@ -72,7 +72,7 @@ export class TrackManager { } // emit this event here as peer will already be removed(if left the room) by the time this event is received - track.type === HMSTrackType.AUDIO && this.eventBus.audioTrackRemoved.publish(track as HMSRemoteAudioTrack); + track.type === HMSTrackKind.AUDIO && this.eventBus.audioTrackRemoved.publish(track as HMSRemoteAudioTrack); this.store.removeTrack(track); const hmsPeer = this.store.getPeerById(trackStateEntry.peerId); if (!hmsPeer) { @@ -112,7 +112,7 @@ export class TrackManager { this.listener?.onTrackUpdate(HMSTrackUpdate.TRACK_REMOVED, track, hmsPeer); // emit this event here as peer will already be removed(if left the room) by the time this event is received - track.type === HMSTrackType.AUDIO && this.eventBus.audioTrackRemoved.publish(track as HMSRemoteAudioTrack); + track.type === HMSTrackKind.AUDIO && this.eventBus.audioTrackRemoved.publish(track as HMSRemoteAudioTrack); } } @@ -201,7 +201,7 @@ export class TrackManager { * Don't call onTrackUpdate for audio elements immediately because the operations(eg: setVolume) performed * on onTrackUpdate can be overriden in AudioSinkManager when audio element is created **/ - track.type === HMSTrackType.AUDIO + track.type === HMSTrackKind.AUDIO ? this.eventBus.audioTrackAdded.publish({ track: track as HMSRemoteAudioTrack, peer: hmsPeer as HMSRemotePeer }) : this.listener?.onTrackUpdate(HMSTrackUpdate.TRACK_ADDED, track, hmsPeer); this.tracksToProcess.delete(track.trackId); @@ -227,10 +227,10 @@ export class TrackManager { hmsPeer.auxiliaryTracks.splice(auxiliaryTrackIndex, 1); HMSLogger.d(this.TAG, 'auxiliary track removed', `${track}`); } else { - if (track.type === HMSTrackType.AUDIO && hmsPeer.audioTrack === track) { + if (track.type === HMSTrackKind.AUDIO && hmsPeer.audioTrack === track) { hmsPeer.audioTrack = undefined; HMSLogger.d(this.TAG, 'audio track removed', `${track}`); - } else if (track.type === HMSTrackType.VIDEO && hmsPeer.videoTrack === track) { + } else if (track.type === HMSTrackKind.VIDEO && hmsPeer.videoTrack === track) { hmsPeer.videoTrack = undefined; HMSLogger.d(this.TAG, 'video track removed', `${track}`); } @@ -238,7 +238,7 @@ export class TrackManager { } private addAudioTrack(hmsPeer: HMSPeer, track: HMSRemoteTrack) { - if (track.type !== HMSTrackType.AUDIO) { + if (track.type !== HMSTrackKind.AUDIO) { return; } if (track.source === 'regular' && (!hmsPeer.audioTrack || hmsPeer.audioTrack?.trackId === track.trackId)) { @@ -251,7 +251,7 @@ export class TrackManager { } addVideoTrack(hmsPeer: HMSPeer, track: HMSRemoteTrack) { - if (track.type !== HMSTrackType.VIDEO) { + if (track.type !== HMSTrackKind.VIDEO) { return; } const remoteTrack = track as HMSRemoteVideoTrack; @@ -285,7 +285,7 @@ export class TrackManager { let eventType; if (currentTrackState.mute !== trackState.mute) { eventType = trackState.mute ? HMSTrackUpdate.TRACK_MUTED : HMSTrackUpdate.TRACK_UNMUTED; - track.type === HMSTrackType.AUDIO && + track.type === HMSTrackKind.AUDIO && this.eventBus.audioTrackUpdate.publish({ track: track as HMSRemoteAudioTrack, enabled: !trackState.mute }); } else if (currentTrackState.description !== trackState.description) { eventType = HMSTrackUpdate.TRACK_DESCRIPTION_CHANGED; diff --git a/packages/hms-video-store/src/reactive-store/adapter.ts b/packages/hms-video-store/src/reactive-store/adapter.ts index 90d0217311..e33a7013a8 100644 --- a/packages/hms-video-store/src/reactive-store/adapter.ts +++ b/packages/hms-video-store/src/reactive-store/adapter.ts @@ -24,6 +24,7 @@ import { HMSRoom, HMSScreenVideoTrack, HMSTrack, + HMSTrackException, HMSTrackFacingMode, HMSVideoTrack, } from '../schema'; @@ -214,8 +215,9 @@ export class SDKToHMS { nativeError: sdkException.nativeError, timestamp: new Date(), } as HMSException; - if (sdkException.deviceType) { - exp.deviceType = sdkException.deviceType; + if (sdkException instanceof sdkTypes.HMSTrackException) { + (exp as HMSTrackException).trackType = sdkException.trackType; + return exp as HMSTrackException; } return exp; } diff --git a/packages/hms-video-store/src/schema/error.ts b/packages/hms-video-store/src/schema/error.ts index 285565d740..dc9731adbb 100644 --- a/packages/hms-video-store/src/schema/error.ts +++ b/packages/hms-video-store/src/schema/error.ts @@ -1,3 +1,5 @@ +import { HMSTrackType } from '../media/tracks/HMSTrackType'; + /** * any mid call error notification will be in this format */ @@ -10,5 +12,16 @@ export interface HMSException { isTerminal: boolean; timestamp: Date; nativeError?: Error; - deviceType?: string; +} + +export interface HMSTrackException { + code: number; + action: string; + name: string; + message: string; + description: string; + isTerminal: boolean; + timestamp: Date; + nativeError?: Error; + trackType: HMSTrackType; } diff --git a/packages/hms-video-store/src/sdk/LocalTrackManager.ts b/packages/hms-video-store/src/sdk/LocalTrackManager.ts index 64c0251a7e..94851e3552 100644 --- a/packages/hms-video-store/src/sdk/LocalTrackManager.ts +++ b/packages/hms-video-store/src/sdk/LocalTrackManager.ts @@ -7,7 +7,7 @@ import { ErrorCodes } from '../error/ErrorCodes'; import { ErrorFactory } from '../error/ErrorFactory'; import { HMSAction } from '../error/HMSAction'; import { HMSException } from '../error/HMSException'; -import { BuildGetMediaError, HMSGetMediaActions } from '../error/utils'; +import { BuildGetMediaError } from '../error/utils'; import { EventBus } from '../events/EventBus'; import { HMSAudioCodec, @@ -17,7 +17,7 @@ import { ScreenCaptureHandleConfig, } from '../interfaces'; import InitialSettings from '../interfaces/settings'; -import { HMSLocalAudioTrack, HMSLocalTrack, HMSLocalVideoTrack, HMSTrackType } from '../internal'; +import { HMSLocalAudioTrack, HMSLocalTrack, HMSLocalVideoTrack, HMSTrackKind } from '../internal'; import { HMSAudioTrackSettings, HMSAudioTrackSettingsBuilder, @@ -27,6 +27,7 @@ import { HMSVideoTrackSettingsBuilder, } from '../media/settings'; import { HMSLocalStream } from '../media/streams/HMSLocalStream'; +import { HMSTrackType } from '../media/tracks/HMSTrackType'; import ITransportObserver from '../transport/ITransportObserver'; import HMSLogger from '../utils/logger'; import { HMSAudioContextHandler } from '../utils/media'; @@ -236,7 +237,7 @@ export class LocalTrackManager { } } catch (err) { HMSLogger.w(this.TAG, 'error in getting screenshare - ', err); - const error = BuildGetMediaError(err as Error, HMSGetMediaActions.SCREEN); + const error = BuildGetMediaError(err as Error, HMSTrackType.SCREEN); this.eventBus.analytics.publish( AnalyticsEventFactory.publish({ error: error as Error, @@ -478,17 +479,17 @@ export class LocalTrackManager { } } - getErrorType(videoError: boolean, audioError: boolean): HMSGetMediaActions { + getErrorType(videoError: boolean, audioError: boolean): HMSTrackType { if (videoError && audioError) { - return HMSGetMediaActions.AV; + return HMSTrackType.AV; } if (videoError) { - return HMSGetMediaActions.VIDEO; + return HMSTrackType.VIDEO; } if (audioError) { - return HMSGetMediaActions.AUDIO; + return HMSTrackType.AUDIO; } - return HMSGetMediaActions.UNKNOWN; + return HMSTrackType.AV; } private getEmptyTracks(fetchTrackOptions: IFetchAVTrackOptions) { @@ -505,14 +506,14 @@ export class LocalTrackManager { private async updateCurrentLocalTrackSettings(trackSettings: HMSTrackSettings | null) { const localTracks = this.store.getLocalPeerTracks(); - const videoTrack = localTracks.find(t => t.type === HMSTrackType.VIDEO && t.source === 'regular') as + const videoTrack = localTracks.find(t => t.type === HMSTrackKind.VIDEO && t.source === 'regular') as | HMSLocalVideoTrack | undefined; - const audioTrack = localTracks.find(t => t.type === HMSTrackType.AUDIO && t.source === 'regular') as + const audioTrack = localTracks.find(t => t.type === HMSTrackKind.AUDIO && t.source === 'regular') as | HMSLocalAudioTrack | undefined; - const screenVideoTrack = localTracks.find(t => t.type === HMSTrackType.VIDEO && t.source === 'screen') as + const screenVideoTrack = localTracks.find(t => t.type === HMSTrackKind.VIDEO && t.source === 'screen') as | HMSLocalVideoTrack | undefined; diff --git a/packages/hms-video-store/src/sdk/index.ts b/packages/hms-video-store/src/sdk/index.ts index dd1b933a63..ac8abab2d4 100644 --- a/packages/hms-video-store/src/sdk/index.ts +++ b/packages/hms-video-store/src/sdk/index.ts @@ -60,8 +60,8 @@ import { HMSLocalTrack, HMSLocalVideoTrack, HMSRemoteTrack, + HMSTrackKind, HMSTrackSource, - HMSTrackType, HMSVideoTrack, } from '../media/tracks'; import { @@ -1241,7 +1241,7 @@ export class HMSSdk implements HMSInterface { } async changeTrackState(forRemoteTrack: HMSRemoteTrack, enabled: boolean) { - if (forRemoteTrack.type === HMSTrackType.VIDEO && forRemoteTrack.source !== 'regular') { + if (forRemoteTrack.type === HMSTrackKind.VIDEO && forRemoteTrack.source !== 'regular') { HMSLogger.w(this.TAG, `Muting non-regular video tracks is currently not supported`); return; } @@ -1376,11 +1376,11 @@ export class HMSSdk implements HMSInterface { private setLocalPeerTrack(track: HMSLocalTrack) { track.peerId = this.localPeer?.peerId; switch (track.type) { - case HMSTrackType.AUDIO: + case HMSTrackKind.AUDIO: this.localPeer!.audioTrack = track as HMSLocalAudioTrack; break; - case HMSTrackType.VIDEO: + case HMSTrackKind.VIDEO: this.localPeer!.videoTrack = track as HMSLocalVideoTrack; break; } diff --git a/packages/hms-video-store/src/sdk/store/Store.ts b/packages/hms-video-store/src/sdk/store/Store.ts index c08e55bbe8..889958e6a5 100644 --- a/packages/hms-video-store/src/sdk/store/Store.ts +++ b/packages/hms-video-store/src/sdk/store/Store.ts @@ -27,8 +27,8 @@ import { HMSRemoteAudioTrack, HMSRemoteVideoTrack, HMSTrack, + HMSTrackKind, HMSTrackSource, - HMSTrackType, HMSVideoTrack, } from '../../media/tracks'; import { @@ -145,7 +145,7 @@ class Store { } getVideoTracks() { - return this.getTracks().filter(track => track.type === HMSTrackType.VIDEO) as HMSVideoTrack[]; + return this.getTracks().filter(track => track.type === HMSTrackKind.VIDEO) as HMSVideoTrack[]; } getRemoteVideoTracks() { @@ -153,7 +153,7 @@ class Store { } getAudioTracks() { - return this.getTracks().filter(track => track.type === HMSTrackType.AUDIO) as HMSAudioTrack[]; + return this.getTracks().filter(track => track.type === HMSTrackKind.AUDIO) as HMSAudioTrack[]; } getPeerTracks(peerId?: string) { diff --git a/packages/hms-video-store/src/utils/media.ts b/packages/hms-video-store/src/utils/media.ts index 025fc7a4bb..d3ad525593 100644 --- a/packages/hms-video-store/src/utils/media.ts +++ b/packages/hms-video-store/src/utils/media.ts @@ -1,12 +1,13 @@ import HMSLogger from './logger'; -import { BuildGetMediaError, HMSGetMediaActions } from '../error/utils'; +import { BuildGetMediaError } from '../error/utils'; +import { HMSTrackType } from '../media/tracks/HMSTrackType'; export async function getLocalStream(constraints: MediaStreamConstraints): Promise { try { const stream = await navigator.mediaDevices.getUserMedia(constraints); return stream; } catch (err) { - throw BuildGetMediaError(err as Error, HMSGetMediaActions.AV); + throw BuildGetMediaError(err as Error, HMSTrackType.AV); } } @@ -16,7 +17,7 @@ export async function getLocalScreen(constraints: MediaStreamConstraints['video' const stream = await navigator.mediaDevices.getDisplayMedia({ video: constraints, audio: false }); return stream; } catch (err) { - throw BuildGetMediaError(err as Error, HMSGetMediaActions.SCREEN); + throw BuildGetMediaError(err as Error, HMSTrackType.SCREEN); } } @@ -37,7 +38,7 @@ export async function getLocalDevices(): Promise { devices.forEach(device => deviceGroups[device.kind].push(device)); return deviceGroups; } catch (err) { - throw BuildGetMediaError(err as Error, HMSGetMediaActions.AV); + throw BuildGetMediaError(err as Error, HMSTrackType.AV); } } diff --git a/packages/hms-video-store/src/utils/track.ts b/packages/hms-video-store/src/utils/track.ts index fea545dd08..3121c66f5b 100644 --- a/packages/hms-video-store/src/utils/track.ts +++ b/packages/hms-video-store/src/utils/track.ts @@ -1,5 +1,6 @@ -import { BuildGetMediaError, HMSGetMediaActions } from '../error/utils'; +import { BuildGetMediaError } from '../error/utils'; import { HMSAudioTrackSettings, HMSVideoTrackSettings } from '../media/settings'; +import { HMSTrackType } from '../media/tracks/HMSTrackType'; export async function getAudioTrack(settings: HMSAudioTrackSettings): Promise { try { @@ -8,7 +9,7 @@ export async function getAudioTrack(settings: HMSAudioTrackSettings): Promise Date: Wed, 30 Oct 2024 17:04:09 +0530 Subject: [PATCH 07/20] fix: test for jest --- packages/hms-video-store/src/sdk/LocalTrackManager.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/hms-video-store/src/sdk/LocalTrackManager.test.ts b/packages/hms-video-store/src/sdk/LocalTrackManager.test.ts index e1788ae25e..a2637bdb1e 100644 --- a/packages/hms-video-store/src/sdk/LocalTrackManager.test.ts +++ b/packages/hms-video-store/src/sdk/LocalTrackManager.test.ts @@ -5,7 +5,7 @@ import { AnalyticsTimer } from '../analytics/AnalyticsTimer'; import { DeviceManager } from '../device-manager'; import { HMSException } from '../error/HMSException'; import { EventBus } from '../events/EventBus'; -import { HMSLocalVideoTrack, HMSPeerType, HMSTrackType } from '../internal'; +import { HMSLocalVideoTrack, HMSPeerType, HMSTrackKind } from '../internal'; import { HMSLocalStream } from '../media/streams/HMSLocalStream'; import { HMSTrack } from '../media/tracks'; import { PolicyParams } from '../notification-manager'; @@ -457,7 +457,7 @@ describe('LocalTrackManager', () => { const constraints = mockGetUserMedia.mock.calls[0][0]; expect(constraints).toHaveProperty('video', false); expect(tracksToPublish).toHaveLength(1); - expect(tracksToPublish[0]).toHaveProperty('type', HMSTrackType.AUDIO); + expect(tracksToPublish[0]).toHaveProperty('type', HMSTrackKind.AUDIO); }); it("doesn't fetch tracks if already present", async () => { From 401e68367cef4aa03dff89e65716c6fe97ee9cc8 Mon Sep 17 00:00:00 2001 From: hdz-666 <93115614+hdz-666@users.noreply.github.com> Date: Thu, 31 Oct 2024 11:36:43 +0530 Subject: [PATCH 08/20] fix: remove refactor for track kind and exception --- .../src/device-manager/DeviceManager.ts | 6 ++-- .../src/diagnostics/ConnectivityCheck.ts | 10 +++--- .../hms-video-store/src/error/ErrorFactory.ts | 34 +++++++++---------- .../hms-video-store/src/error/HMSException.ts | 4 +-- .../src/media/tracks/HMSAudioTrack.ts | 4 +-- .../src/media/tracks/HMSTrack.ts | 4 +-- .../src/media/tracks/HMSTrackExceptionType.ts | 6 ++++ .../src/media/tracks/HMSTrackKind.ts | 4 --- .../src/media/tracks/HMSTrackType.ts | 2 -- .../src/media/tracks/HMSVideoTrack.ts | 4 +-- .../hms-video-store/src/media/tracks/index.ts | 2 +- .../managers/TrackManager.ts | 18 +++++----- packages/hms-video-store/src/schema/error.ts | 4 +-- .../src/sdk/LocalTrackManager.test.ts | 4 +-- .../src/sdk/LocalTrackManager.ts | 22 ++++++------ packages/hms-video-store/src/sdk/index.ts | 8 ++--- .../hms-video-store/src/sdk/store/Store.ts | 6 ++-- packages/hms-video-store/src/utils/media.ts | 8 ++--- packages/hms-video-store/src/utils/track.ts | 6 ++-- 19 files changed, 78 insertions(+), 78 deletions(-) create mode 100644 packages/hms-video-store/src/media/tracks/HMSTrackExceptionType.ts delete mode 100644 packages/hms-video-store/src/media/tracks/HMSTrackKind.ts diff --git a/packages/hms-video-store/src/device-manager/DeviceManager.ts b/packages/hms-video-store/src/device-manager/DeviceManager.ts index 2e463a204c..32f21f6eae 100644 --- a/packages/hms-video-store/src/device-manager/DeviceManager.ts +++ b/packages/hms-video-store/src/device-manager/DeviceManager.ts @@ -7,7 +7,7 @@ import { DeviceMap, HMSDeviceChangeEvent, SelectedDevices } from '../interfaces' import { getAudioDeviceCategory, HMSAudioDeviceCategory, isIOS } from '../internal'; import { HMSAudioTrackSettingsBuilder, HMSVideoTrackSettingsBuilder } from '../media/settings'; import { HMSLocalAudioTrack, HMSLocalTrack, HMSLocalVideoTrack } from '../media/tracks'; -import { HMSTrackType } from '../media/tracks/HMSTrackType'; +import { HMSTrackExceptionType } from '../media/tracks/HMSTrackExceptionType'; import { Store } from '../sdk/store'; import HMSLogger from '../utils/logger'; import { debounce } from '../utils/timer-utils'; @@ -326,7 +326,7 @@ export class DeviceManager implements HMSDeviceManager { this.eventBus.analytics.publish( AnalyticsEventFactory.deviceChange({ selection: { audioInput: newSelection }, - error: ErrorFactory.TracksErrors.SelectedDeviceMissing(HMSTrackType.AUDIO), + error: ErrorFactory.TracksErrors.SelectedDeviceMissing(HMSTrackExceptionType.AUDIO), devices: this.getDevices(), type: 'audioInput', }), @@ -384,7 +384,7 @@ export class DeviceManager implements HMSDeviceManager { this.eventBus.analytics.publish( AnalyticsEventFactory.deviceChange({ selection: { videoInput: newSelection }, - error: ErrorFactory.TracksErrors.SelectedDeviceMissing(HMSTrackType.VIDEO), + error: ErrorFactory.TracksErrors.SelectedDeviceMissing(HMSTrackExceptionType.VIDEO), devices: this.getDevices(), type: 'video', }), diff --git a/packages/hms-video-store/src/diagnostics/ConnectivityCheck.ts b/packages/hms-video-store/src/diagnostics/ConnectivityCheck.ts index 5ef8e147ca..ca5a2353bd 100644 --- a/packages/hms-video-store/src/diagnostics/ConnectivityCheck.ts +++ b/packages/hms-video-store/src/diagnostics/ConnectivityCheck.ts @@ -8,7 +8,7 @@ import { HMSException, HMSRoom, HMSTrack, - HMSTrackKind, + HMSTrackType, HMSTrackUpdate, HMSUpdateListener, } from '../internal'; @@ -108,10 +108,10 @@ export class ConnectivityCheck implements HMSDiagnosticsConnectivityListener { onMediaPublished(track: HMSTrack): void { switch (track.type) { - case HMSTrackKind.AUDIO: + case HMSTrackType.AUDIO: this.isAudioTrackPublished = true; break; - case HMSTrackKind.VIDEO: + case HMSTrackType.VIDEO: this.isVideoTrackPublished = true; break; default: @@ -156,10 +156,10 @@ export class ConnectivityCheck implements HMSDiagnosticsConnectivityListener { this.sdkListener.onTrackUpdate(type, track, peer); if (peer.isLocal && type === HMSTrackUpdate.TRACK_ADDED) { switch (track.type) { - case HMSTrackKind.AUDIO: + case HMSTrackType.AUDIO: this.isAudioTrackCaptured = true; break; - case HMSTrackKind.VIDEO: + case HMSTrackType.VIDEO: this.isVideoTrackCaptured = true; break; default: diff --git a/packages/hms-video-store/src/error/ErrorFactory.ts b/packages/hms-video-store/src/error/ErrorFactory.ts index fa48202ba9..fdc381f8a5 100644 --- a/packages/hms-video-store/src/error/ErrorFactory.ts +++ b/packages/hms-video-store/src/error/ErrorFactory.ts @@ -8,7 +8,7 @@ import { ErrorCodes } from './ErrorCodes'; import { HMSAction } from './HMSAction'; import { HMSException, HMSTrackException } from './HMSException'; -import { HMSTrackType } from '../media/tracks/HMSTrackType'; +import { HMSTrackExceptionType } from '../media/tracks/HMSTrackExceptionType'; import { HMSSignalMethod } from '../signal/jsonrpc/models'; const terminalActions: (HMSSignalMethod | HMSAction)[] = [ @@ -105,7 +105,7 @@ export const ErrorFactory = { action, `[TRACK]: ${description}`, `[TRACK]: ${description}`, - HMSTrackType.AV, + HMSTrackExceptionType.AV, ); }, CantAccessCaptureDevice(action: HMSAction, deviceInfo: string, description = '') { @@ -115,7 +115,7 @@ export const ErrorFactory = { action, `User denied permission to access capture device - ${deviceInfo}`, description, - deviceInfo as HMSTrackType, + deviceInfo as HMSTrackExceptionType, ); }, @@ -126,7 +126,7 @@ export const ErrorFactory = { action, `[TRACK]: Capture device is no longer available - ${deviceInfo}`, description, - deviceInfo as HMSTrackType, + deviceInfo as HMSTrackExceptionType, ); }, @@ -137,7 +137,7 @@ export const ErrorFactory = { action, `[TRACK]: Capture device is in use by another application - ${deviceInfo}`, description, - deviceInfo as HMSTrackType, + deviceInfo as HMSTrackExceptionType, ); }, @@ -148,7 +148,7 @@ export const ErrorFactory = { action, `Lost access to capture device midway - ${deviceInfo}`, description, - deviceInfo as HMSTrackType, + deviceInfo as HMSTrackExceptionType, ); }, @@ -163,7 +163,7 @@ export const ErrorFactory = { action, message, description, - HMSTrackType.AV, + HMSTrackExceptionType.AV, ); }, @@ -174,7 +174,7 @@ export const ErrorFactory = { action, `Cannot enable simulcast when no video settings are provided`, description, - HMSTrackType.VIDEO, + HMSTrackExceptionType.VIDEO, ); }, @@ -185,7 +185,7 @@ export const ErrorFactory = { action, "Autoplay blocked because the user didn't interact with the document first", description, - HMSTrackType.AUDIO, + HMSTrackExceptionType.AUDIO, ); }, @@ -196,7 +196,7 @@ export const ErrorFactory = { action, `Codec can't be changed mid call.`, description, - HMSTrackType.AV, + HMSTrackExceptionType.AV, ); }, @@ -207,7 +207,7 @@ export const ErrorFactory = { action, `[TRACK]: Requested constraints cannot be satisfied with the device hardware - ${deviceInfo}`, description, - deviceInfo as HMSTrackType, + deviceInfo as HMSTrackExceptionType, ); }, @@ -218,7 +218,7 @@ export const ErrorFactory = { action, 'No audio input detected from microphone', description, - HMSTrackType.AUDIO, + HMSTrackExceptionType.AUDIO, ); }, @@ -229,7 +229,7 @@ export const ErrorFactory = { action, `Operating System denied permission to access capture device - ${deviceInfo}`, description, - deviceInfo as HMSTrackType, + deviceInfo as HMSTrackExceptionType, ); }, @@ -240,7 +240,7 @@ export const ErrorFactory = { HMSAction.TRACK, 'The app requires you to share the current tab', 'You must screen share the current tab in order to proceed', - HMSTrackType.SCREEN, + HMSTrackExceptionType.SCREEN, ); }, @@ -251,7 +251,7 @@ export const ErrorFactory = { HMSAction.TRACK, description, description, - HMSTrackType.AUDIO, + HMSTrackExceptionType.AUDIO, ); }, @@ -262,7 +262,7 @@ export const ErrorFactory = { HMSAction.TRACK, `Could not detect selected ${deviceType} device`, `Please check connection to the ${deviceType} device`, - deviceType as HMSTrackType, + deviceType as HMSTrackExceptionType, ); }, @@ -273,7 +273,7 @@ export const ErrorFactory = { HMSAction.TRACK, description, 'This could possibily due to another application taking priority over the access to camera or microphone or due to an incoming call', - HMSTrackType.AV, + HMSTrackExceptionType.AV, ); }, }, diff --git a/packages/hms-video-store/src/error/HMSException.ts b/packages/hms-video-store/src/error/HMSException.ts index ea1cf2e779..e2ef942eca 100644 --- a/packages/hms-video-store/src/error/HMSException.ts +++ b/packages/hms-video-store/src/error/HMSException.ts @@ -1,6 +1,6 @@ import { HMSAction } from './HMSAction'; import { IAnalyticsPropertiesProvider } from '../analytics/IAnalyticsPropertiesProvider'; -import { HMSTrackType } from '../media/tracks/HMSTrackType'; +import { HMSTrackExceptionType } from '../media/tracks/HMSTrackExceptionType'; import { HMSSignalMethod } from '../signal/jsonrpc/models'; export class HMSException extends Error implements IAnalyticsPropertiesProvider { @@ -57,7 +57,7 @@ export class HMSTrackException extends HMSException { action: HMSAction | HMSSignalMethod, message: string, description: string, - public trackType: HMSTrackType, + public trackType: HMSTrackExceptionType, ) { super(code, name, action, message, description, false); } diff --git a/packages/hms-video-store/src/media/tracks/HMSAudioTrack.ts b/packages/hms-video-store/src/media/tracks/HMSAudioTrack.ts index 3ae665c463..58fe7bc171 100644 --- a/packages/hms-video-store/src/media/tracks/HMSAudioTrack.ts +++ b/packages/hms-video-store/src/media/tracks/HMSAudioTrack.ts @@ -1,11 +1,11 @@ import { HMSTrack, HMSTrackSource } from './HMSTrack'; -import { HMSTrackKind } from './HMSTrackKind'; +import { HMSTrackType } from './HMSTrackType'; import HMSLogger from '../../utils/logger'; import { isFirefox } from '../../utils/support'; import { HMSMediaStream, HMSRemoteStream } from '../streams'; export class HMSAudioTrack extends HMSTrack { - readonly type: HMSTrackKind = HMSTrackKind.AUDIO; + readonly type: HMSTrackType = HMSTrackType.AUDIO; private audioElement: HTMLAudioElement | null = null; private outputDevice?: MediaDeviceInfo; diff --git a/packages/hms-video-store/src/media/tracks/HMSTrack.ts b/packages/hms-video-store/src/media/tracks/HMSTrack.ts index 7318713027..208d021ba4 100644 --- a/packages/hms-video-store/src/media/tracks/HMSTrack.ts +++ b/packages/hms-video-store/src/media/tracks/HMSTrack.ts @@ -1,4 +1,4 @@ -import { HMSTrackKind } from './HMSTrackKind'; +import { HMSTrackType } from './HMSTrackType'; import AnalyticsEventFactory from '../../analytics/AnalyticsEventFactory'; import { stringifyMediaStreamTrack } from '../../utils/json'; import HMSLogger from '../../utils/logger'; @@ -44,7 +44,7 @@ export abstract class HMSTrack { */ private firstTrackId?: string; - abstract readonly type: HMSTrackKind; + abstract readonly type: HMSTrackType; public get enabled(): boolean { return this.nativeTrack.enabled; diff --git a/packages/hms-video-store/src/media/tracks/HMSTrackExceptionType.ts b/packages/hms-video-store/src/media/tracks/HMSTrackExceptionType.ts new file mode 100644 index 0000000000..799c3389c1 --- /dev/null +++ b/packages/hms-video-store/src/media/tracks/HMSTrackExceptionType.ts @@ -0,0 +1,6 @@ +export enum HMSTrackExceptionType { + AUDIO = 'audio', + VIDEO = 'video', + AV = 'audio, video', + SCREEN = 'screen', +} diff --git a/packages/hms-video-store/src/media/tracks/HMSTrackKind.ts b/packages/hms-video-store/src/media/tracks/HMSTrackKind.ts deleted file mode 100644 index 26f1591f6f..0000000000 --- a/packages/hms-video-store/src/media/tracks/HMSTrackKind.ts +++ /dev/null @@ -1,4 +0,0 @@ -export enum HMSTrackKind { - AUDIO = 'audio', - VIDEO = 'video', -} diff --git a/packages/hms-video-store/src/media/tracks/HMSTrackType.ts b/packages/hms-video-store/src/media/tracks/HMSTrackType.ts index 47e26ad9e6..6ec803f442 100644 --- a/packages/hms-video-store/src/media/tracks/HMSTrackType.ts +++ b/packages/hms-video-store/src/media/tracks/HMSTrackType.ts @@ -1,6 +1,4 @@ export enum HMSTrackType { AUDIO = 'audio', VIDEO = 'video', - AV = 'audio, video', - SCREEN = 'screen', } diff --git a/packages/hms-video-store/src/media/tracks/HMSVideoTrack.ts b/packages/hms-video-store/src/media/tracks/HMSVideoTrack.ts index 450b083e0f..8e577d4579 100644 --- a/packages/hms-video-store/src/media/tracks/HMSVideoTrack.ts +++ b/packages/hms-video-store/src/media/tracks/HMSVideoTrack.ts @@ -1,12 +1,12 @@ import { HMSTrack, HMSTrackSource } from './HMSTrack'; -import { HMSTrackKind } from './HMSTrackKind'; +import { HMSTrackType } from './HMSTrackType'; import { VideoElementManager } from './VideoElementManager'; import HMSLogger from '../../utils/logger'; import { isSafari } from '../../utils/support'; import { HMSMediaStream } from '../streams'; export class HMSVideoTrack extends HMSTrack { - readonly type: HMSTrackKind = HMSTrackKind.VIDEO; + readonly type: HMSTrackType = HMSTrackType.VIDEO; private sinkCount = 0; videoHandler!: VideoElementManager; diff --git a/packages/hms-video-store/src/media/tracks/index.ts b/packages/hms-video-store/src/media/tracks/index.ts index d71fdd5807..4472cee462 100644 --- a/packages/hms-video-store/src/media/tracks/index.ts +++ b/packages/hms-video-store/src/media/tracks/index.ts @@ -13,4 +13,4 @@ export * from './HMSRemoteAudioTrack'; export * from './HMSVideoTrack'; export * from './HMSLocalVideoTrack'; export * from './HMSRemoteVideoTrack'; -export * from './HMSTrackKind'; +export * from './HMSTrackType'; diff --git a/packages/hms-video-store/src/notification-manager/managers/TrackManager.ts b/packages/hms-video-store/src/notification-manager/managers/TrackManager.ts index b909a90cbb..d3feeba285 100644 --- a/packages/hms-video-store/src/notification-manager/managers/TrackManager.ts +++ b/packages/hms-video-store/src/notification-manager/managers/TrackManager.ts @@ -2,7 +2,7 @@ import { createRemotePeer } from './utils'; import { VideoTrackLayerUpdate } from '../../connection/channel-messages'; import { EventBus } from '../../events/EventBus'; import { HMSRemotePeer, HMSTrackUpdate, HMSUpdateListener } from '../../interfaces'; -import { HMSRemoteAudioTrack, HMSRemoteTrack, HMSRemoteVideoTrack, HMSTrackKind } from '../../media/tracks'; +import { HMSRemoteAudioTrack, HMSRemoteTrack, HMSRemoteVideoTrack, HMSTrackType } from '../../media/tracks'; import { HMSPeer } from '../../sdk/models/peer'; import { Store } from '../../sdk/store'; import HMSLogger from '../../utils/logger'; @@ -72,7 +72,7 @@ export class TrackManager { } // emit this event here as peer will already be removed(if left the room) by the time this event is received - track.type === HMSTrackKind.AUDIO && this.eventBus.audioTrackRemoved.publish(track as HMSRemoteAudioTrack); + track.type === HMSTrackType.AUDIO && this.eventBus.audioTrackRemoved.publish(track as HMSRemoteAudioTrack); this.store.removeTrack(track); const hmsPeer = this.store.getPeerById(trackStateEntry.peerId); if (!hmsPeer) { @@ -112,7 +112,7 @@ export class TrackManager { this.listener?.onTrackUpdate(HMSTrackUpdate.TRACK_REMOVED, track, hmsPeer); // emit this event here as peer will already be removed(if left the room) by the time this event is received - track.type === HMSTrackKind.AUDIO && this.eventBus.audioTrackRemoved.publish(track as HMSRemoteAudioTrack); + track.type === HMSTrackType.AUDIO && this.eventBus.audioTrackRemoved.publish(track as HMSRemoteAudioTrack); } } @@ -201,7 +201,7 @@ export class TrackManager { * Don't call onTrackUpdate for audio elements immediately because the operations(eg: setVolume) performed * on onTrackUpdate can be overriden in AudioSinkManager when audio element is created **/ - track.type === HMSTrackKind.AUDIO + track.type === HMSTrackType.AUDIO ? this.eventBus.audioTrackAdded.publish({ track: track as HMSRemoteAudioTrack, peer: hmsPeer as HMSRemotePeer }) : this.listener?.onTrackUpdate(HMSTrackUpdate.TRACK_ADDED, track, hmsPeer); this.tracksToProcess.delete(track.trackId); @@ -227,10 +227,10 @@ export class TrackManager { hmsPeer.auxiliaryTracks.splice(auxiliaryTrackIndex, 1); HMSLogger.d(this.TAG, 'auxiliary track removed', `${track}`); } else { - if (track.type === HMSTrackKind.AUDIO && hmsPeer.audioTrack === track) { + if (track.type === HMSTrackType.AUDIO && hmsPeer.audioTrack === track) { hmsPeer.audioTrack = undefined; HMSLogger.d(this.TAG, 'audio track removed', `${track}`); - } else if (track.type === HMSTrackKind.VIDEO && hmsPeer.videoTrack === track) { + } else if (track.type === HMSTrackType.VIDEO && hmsPeer.videoTrack === track) { hmsPeer.videoTrack = undefined; HMSLogger.d(this.TAG, 'video track removed', `${track}`); } @@ -238,7 +238,7 @@ export class TrackManager { } private addAudioTrack(hmsPeer: HMSPeer, track: HMSRemoteTrack) { - if (track.type !== HMSTrackKind.AUDIO) { + if (track.type !== HMSTrackType.AUDIO) { return; } if (track.source === 'regular' && (!hmsPeer.audioTrack || hmsPeer.audioTrack?.trackId === track.trackId)) { @@ -251,7 +251,7 @@ export class TrackManager { } addVideoTrack(hmsPeer: HMSPeer, track: HMSRemoteTrack) { - if (track.type !== HMSTrackKind.VIDEO) { + if (track.type !== HMSTrackType.VIDEO) { return; } const remoteTrack = track as HMSRemoteVideoTrack; @@ -285,7 +285,7 @@ export class TrackManager { let eventType; if (currentTrackState.mute !== trackState.mute) { eventType = trackState.mute ? HMSTrackUpdate.TRACK_MUTED : HMSTrackUpdate.TRACK_UNMUTED; - track.type === HMSTrackKind.AUDIO && + track.type === HMSTrackType.AUDIO && this.eventBus.audioTrackUpdate.publish({ track: track as HMSRemoteAudioTrack, enabled: !trackState.mute }); } else if (currentTrackState.description !== trackState.description) { eventType = HMSTrackUpdate.TRACK_DESCRIPTION_CHANGED; diff --git a/packages/hms-video-store/src/schema/error.ts b/packages/hms-video-store/src/schema/error.ts index dc9731adbb..c2ea1c4a24 100644 --- a/packages/hms-video-store/src/schema/error.ts +++ b/packages/hms-video-store/src/schema/error.ts @@ -1,4 +1,4 @@ -import { HMSTrackType } from '../media/tracks/HMSTrackType'; +import { HMSTrackExceptionType } from '../media/tracks/HMSTrackExceptionType'; /** * any mid call error notification will be in this format @@ -23,5 +23,5 @@ export interface HMSTrackException { isTerminal: boolean; timestamp: Date; nativeError?: Error; - trackType: HMSTrackType; + trackType: HMSTrackExceptionType; } diff --git a/packages/hms-video-store/src/sdk/LocalTrackManager.test.ts b/packages/hms-video-store/src/sdk/LocalTrackManager.test.ts index a2637bdb1e..e1788ae25e 100644 --- a/packages/hms-video-store/src/sdk/LocalTrackManager.test.ts +++ b/packages/hms-video-store/src/sdk/LocalTrackManager.test.ts @@ -5,7 +5,7 @@ import { AnalyticsTimer } from '../analytics/AnalyticsTimer'; import { DeviceManager } from '../device-manager'; import { HMSException } from '../error/HMSException'; import { EventBus } from '../events/EventBus'; -import { HMSLocalVideoTrack, HMSPeerType, HMSTrackKind } from '../internal'; +import { HMSLocalVideoTrack, HMSPeerType, HMSTrackType } from '../internal'; import { HMSLocalStream } from '../media/streams/HMSLocalStream'; import { HMSTrack } from '../media/tracks'; import { PolicyParams } from '../notification-manager'; @@ -457,7 +457,7 @@ describe('LocalTrackManager', () => { const constraints = mockGetUserMedia.mock.calls[0][0]; expect(constraints).toHaveProperty('video', false); expect(tracksToPublish).toHaveLength(1); - expect(tracksToPublish[0]).toHaveProperty('type', HMSTrackKind.AUDIO); + expect(tracksToPublish[0]).toHaveProperty('type', HMSTrackType.AUDIO); }); it("doesn't fetch tracks if already present", async () => { diff --git a/packages/hms-video-store/src/sdk/LocalTrackManager.ts b/packages/hms-video-store/src/sdk/LocalTrackManager.ts index 94851e3552..7ac384215b 100644 --- a/packages/hms-video-store/src/sdk/LocalTrackManager.ts +++ b/packages/hms-video-store/src/sdk/LocalTrackManager.ts @@ -17,7 +17,7 @@ import { ScreenCaptureHandleConfig, } from '../interfaces'; import InitialSettings from '../interfaces/settings'; -import { HMSLocalAudioTrack, HMSLocalTrack, HMSLocalVideoTrack, HMSTrackKind } from '../internal'; +import { HMSLocalAudioTrack, HMSLocalTrack, HMSLocalVideoTrack, HMSTrackType } from '../internal'; import { HMSAudioTrackSettings, HMSAudioTrackSettingsBuilder, @@ -27,7 +27,7 @@ import { HMSVideoTrackSettingsBuilder, } from '../media/settings'; import { HMSLocalStream } from '../media/streams/HMSLocalStream'; -import { HMSTrackType } from '../media/tracks/HMSTrackType'; +import { HMSTrackExceptionType } from '../media/tracks/HMSTrackExceptionType'; import ITransportObserver from '../transport/ITransportObserver'; import HMSLogger from '../utils/logger'; import { HMSAudioContextHandler } from '../utils/media'; @@ -237,7 +237,7 @@ export class LocalTrackManager { } } catch (err) { HMSLogger.w(this.TAG, 'error in getting screenshare - ', err); - const error = BuildGetMediaError(err as Error, HMSTrackType.SCREEN); + const error = BuildGetMediaError(err as Error, HMSTrackExceptionType.SCREEN); this.eventBus.analytics.publish( AnalyticsEventFactory.publish({ error: error as Error, @@ -479,17 +479,17 @@ export class LocalTrackManager { } } - getErrorType(videoError: boolean, audioError: boolean): HMSTrackType { + getErrorType(videoError: boolean, audioError: boolean): HMSTrackExceptionType { if (videoError && audioError) { - return HMSTrackType.AV; + return HMSTrackExceptionType.AV; } if (videoError) { - return HMSTrackType.VIDEO; + return HMSTrackExceptionType.VIDEO; } if (audioError) { - return HMSTrackType.AUDIO; + return HMSTrackExceptionType.AUDIO; } - return HMSTrackType.AV; + return HMSTrackExceptionType.AV; } private getEmptyTracks(fetchTrackOptions: IFetchAVTrackOptions) { @@ -506,14 +506,14 @@ export class LocalTrackManager { private async updateCurrentLocalTrackSettings(trackSettings: HMSTrackSettings | null) { const localTracks = this.store.getLocalPeerTracks(); - const videoTrack = localTracks.find(t => t.type === HMSTrackKind.VIDEO && t.source === 'regular') as + const videoTrack = localTracks.find(t => t.type === HMSTrackType.VIDEO && t.source === 'regular') as | HMSLocalVideoTrack | undefined; - const audioTrack = localTracks.find(t => t.type === HMSTrackKind.AUDIO && t.source === 'regular') as + const audioTrack = localTracks.find(t => t.type === HMSTrackType.AUDIO && t.source === 'regular') as | HMSLocalAudioTrack | undefined; - const screenVideoTrack = localTracks.find(t => t.type === HMSTrackKind.VIDEO && t.source === 'screen') as + const screenVideoTrack = localTracks.find(t => t.type === HMSTrackType.VIDEO && t.source === 'screen') as | HMSLocalVideoTrack | undefined; diff --git a/packages/hms-video-store/src/sdk/index.ts b/packages/hms-video-store/src/sdk/index.ts index ac8abab2d4..dd1b933a63 100644 --- a/packages/hms-video-store/src/sdk/index.ts +++ b/packages/hms-video-store/src/sdk/index.ts @@ -60,8 +60,8 @@ import { HMSLocalTrack, HMSLocalVideoTrack, HMSRemoteTrack, - HMSTrackKind, HMSTrackSource, + HMSTrackType, HMSVideoTrack, } from '../media/tracks'; import { @@ -1241,7 +1241,7 @@ export class HMSSdk implements HMSInterface { } async changeTrackState(forRemoteTrack: HMSRemoteTrack, enabled: boolean) { - if (forRemoteTrack.type === HMSTrackKind.VIDEO && forRemoteTrack.source !== 'regular') { + if (forRemoteTrack.type === HMSTrackType.VIDEO && forRemoteTrack.source !== 'regular') { HMSLogger.w(this.TAG, `Muting non-regular video tracks is currently not supported`); return; } @@ -1376,11 +1376,11 @@ export class HMSSdk implements HMSInterface { private setLocalPeerTrack(track: HMSLocalTrack) { track.peerId = this.localPeer?.peerId; switch (track.type) { - case HMSTrackKind.AUDIO: + case HMSTrackType.AUDIO: this.localPeer!.audioTrack = track as HMSLocalAudioTrack; break; - case HMSTrackKind.VIDEO: + case HMSTrackType.VIDEO: this.localPeer!.videoTrack = track as HMSLocalVideoTrack; break; } diff --git a/packages/hms-video-store/src/sdk/store/Store.ts b/packages/hms-video-store/src/sdk/store/Store.ts index 889958e6a5..c08e55bbe8 100644 --- a/packages/hms-video-store/src/sdk/store/Store.ts +++ b/packages/hms-video-store/src/sdk/store/Store.ts @@ -27,8 +27,8 @@ import { HMSRemoteAudioTrack, HMSRemoteVideoTrack, HMSTrack, - HMSTrackKind, HMSTrackSource, + HMSTrackType, HMSVideoTrack, } from '../../media/tracks'; import { @@ -145,7 +145,7 @@ class Store { } getVideoTracks() { - return this.getTracks().filter(track => track.type === HMSTrackKind.VIDEO) as HMSVideoTrack[]; + return this.getTracks().filter(track => track.type === HMSTrackType.VIDEO) as HMSVideoTrack[]; } getRemoteVideoTracks() { @@ -153,7 +153,7 @@ class Store { } getAudioTracks() { - return this.getTracks().filter(track => track.type === HMSTrackKind.AUDIO) as HMSAudioTrack[]; + return this.getTracks().filter(track => track.type === HMSTrackType.AUDIO) as HMSAudioTrack[]; } getPeerTracks(peerId?: string) { diff --git a/packages/hms-video-store/src/utils/media.ts b/packages/hms-video-store/src/utils/media.ts index d3ad525593..a7ba51faa0 100644 --- a/packages/hms-video-store/src/utils/media.ts +++ b/packages/hms-video-store/src/utils/media.ts @@ -1,13 +1,13 @@ import HMSLogger from './logger'; import { BuildGetMediaError } from '../error/utils'; -import { HMSTrackType } from '../media/tracks/HMSTrackType'; +import { HMSTrackExceptionType } from '../media/tracks/HMSTrackExceptionType'; export async function getLocalStream(constraints: MediaStreamConstraints): Promise { try { const stream = await navigator.mediaDevices.getUserMedia(constraints); return stream; } catch (err) { - throw BuildGetMediaError(err as Error, HMSTrackType.AV); + throw BuildGetMediaError(err as Error, HMSTrackExceptionType.AV); } } @@ -17,7 +17,7 @@ export async function getLocalScreen(constraints: MediaStreamConstraints['video' const stream = await navigator.mediaDevices.getDisplayMedia({ video: constraints, audio: false }); return stream; } catch (err) { - throw BuildGetMediaError(err as Error, HMSTrackType.SCREEN); + throw BuildGetMediaError(err as Error, HMSTrackExceptionType.SCREEN); } } @@ -38,7 +38,7 @@ export async function getLocalDevices(): Promise { devices.forEach(device => deviceGroups[device.kind].push(device)); return deviceGroups; } catch (err) { - throw BuildGetMediaError(err as Error, HMSTrackType.AV); + throw BuildGetMediaError(err as Error, HMSTrackExceptionType.AV); } } diff --git a/packages/hms-video-store/src/utils/track.ts b/packages/hms-video-store/src/utils/track.ts index 3121c66f5b..66fad1eb0a 100644 --- a/packages/hms-video-store/src/utils/track.ts +++ b/packages/hms-video-store/src/utils/track.ts @@ -1,6 +1,6 @@ import { BuildGetMediaError } from '../error/utils'; import { HMSAudioTrackSettings, HMSVideoTrackSettings } from '../media/settings'; -import { HMSTrackType } from '../media/tracks/HMSTrackType'; +import { HMSTrackExceptionType } from '../media/tracks/HMSTrackExceptionType'; export async function getAudioTrack(settings: HMSAudioTrackSettings): Promise { try { @@ -9,7 +9,7 @@ export async function getAudioTrack(settings: HMSAudioTrackSettings): Promise Date: Thu, 31 Oct 2024 12:11:48 +0530 Subject: [PATCH 09/20] fix: remove refactor for track kind and exception --- .../src/device-manager/DeviceManager.ts | 6 ++-- .../hms-video-store/src/error/ErrorFactory.ts | 34 +++++++++---------- .../hms-video-store/src/error/HMSException.ts | 4 +-- ...nType.ts => HMSTrackExceptionTrackType.ts} | 2 +- packages/hms-video-store/src/schema/error.ts | 4 +-- .../src/sdk/LocalTrackManager.ts | 14 ++++---- packages/hms-video-store/src/utils/media.ts | 8 ++--- packages/hms-video-store/src/utils/track.ts | 6 ++-- 8 files changed, 39 insertions(+), 39 deletions(-) rename packages/hms-video-store/src/media/tracks/{HMSTrackExceptionType.ts => HMSTrackExceptionTrackType.ts} (67%) diff --git a/packages/hms-video-store/src/device-manager/DeviceManager.ts b/packages/hms-video-store/src/device-manager/DeviceManager.ts index 32f21f6eae..fd7bfcf9f3 100644 --- a/packages/hms-video-store/src/device-manager/DeviceManager.ts +++ b/packages/hms-video-store/src/device-manager/DeviceManager.ts @@ -7,7 +7,7 @@ import { DeviceMap, HMSDeviceChangeEvent, SelectedDevices } from '../interfaces' import { getAudioDeviceCategory, HMSAudioDeviceCategory, isIOS } from '../internal'; import { HMSAudioTrackSettingsBuilder, HMSVideoTrackSettingsBuilder } from '../media/settings'; import { HMSLocalAudioTrack, HMSLocalTrack, HMSLocalVideoTrack } from '../media/tracks'; -import { HMSTrackExceptionType } from '../media/tracks/HMSTrackExceptionType'; +import { HMSTrackExceptionTrackType } from '../media/tracks/HMSTrackExceptionTrackType'; import { Store } from '../sdk/store'; import HMSLogger from '../utils/logger'; import { debounce } from '../utils/timer-utils'; @@ -326,7 +326,7 @@ export class DeviceManager implements HMSDeviceManager { this.eventBus.analytics.publish( AnalyticsEventFactory.deviceChange({ selection: { audioInput: newSelection }, - error: ErrorFactory.TracksErrors.SelectedDeviceMissing(HMSTrackExceptionType.AUDIO), + error: ErrorFactory.TracksErrors.SelectedDeviceMissing(HMSTrackExceptionTrackType.AUDIO), devices: this.getDevices(), type: 'audioInput', }), @@ -384,7 +384,7 @@ export class DeviceManager implements HMSDeviceManager { this.eventBus.analytics.publish( AnalyticsEventFactory.deviceChange({ selection: { videoInput: newSelection }, - error: ErrorFactory.TracksErrors.SelectedDeviceMissing(HMSTrackExceptionType.VIDEO), + error: ErrorFactory.TracksErrors.SelectedDeviceMissing(HMSTrackExceptionTrackType.VIDEO), devices: this.getDevices(), type: 'video', }), diff --git a/packages/hms-video-store/src/error/ErrorFactory.ts b/packages/hms-video-store/src/error/ErrorFactory.ts index fdc381f8a5..a1493d989c 100644 --- a/packages/hms-video-store/src/error/ErrorFactory.ts +++ b/packages/hms-video-store/src/error/ErrorFactory.ts @@ -8,7 +8,7 @@ import { ErrorCodes } from './ErrorCodes'; import { HMSAction } from './HMSAction'; import { HMSException, HMSTrackException } from './HMSException'; -import { HMSTrackExceptionType } from '../media/tracks/HMSTrackExceptionType'; +import { HMSTrackExceptionTrackType } from '../media/tracks/HMSTrackExceptionTrackType'; import { HMSSignalMethod } from '../signal/jsonrpc/models'; const terminalActions: (HMSSignalMethod | HMSAction)[] = [ @@ -105,7 +105,7 @@ export const ErrorFactory = { action, `[TRACK]: ${description}`, `[TRACK]: ${description}`, - HMSTrackExceptionType.AV, + HMSTrackExceptionTrackType.AV, ); }, CantAccessCaptureDevice(action: HMSAction, deviceInfo: string, description = '') { @@ -115,7 +115,7 @@ export const ErrorFactory = { action, `User denied permission to access capture device - ${deviceInfo}`, description, - deviceInfo as HMSTrackExceptionType, + deviceInfo as HMSTrackExceptionTrackType, ); }, @@ -126,7 +126,7 @@ export const ErrorFactory = { action, `[TRACK]: Capture device is no longer available - ${deviceInfo}`, description, - deviceInfo as HMSTrackExceptionType, + deviceInfo as HMSTrackExceptionTrackType, ); }, @@ -137,7 +137,7 @@ export const ErrorFactory = { action, `[TRACK]: Capture device is in use by another application - ${deviceInfo}`, description, - deviceInfo as HMSTrackExceptionType, + deviceInfo as HMSTrackExceptionTrackType, ); }, @@ -148,7 +148,7 @@ export const ErrorFactory = { action, `Lost access to capture device midway - ${deviceInfo}`, description, - deviceInfo as HMSTrackExceptionType, + deviceInfo as HMSTrackExceptionTrackType, ); }, @@ -163,7 +163,7 @@ export const ErrorFactory = { action, message, description, - HMSTrackExceptionType.AV, + HMSTrackExceptionTrackType.AV, ); }, @@ -174,7 +174,7 @@ export const ErrorFactory = { action, `Cannot enable simulcast when no video settings are provided`, description, - HMSTrackExceptionType.VIDEO, + HMSTrackExceptionTrackType.VIDEO, ); }, @@ -185,7 +185,7 @@ export const ErrorFactory = { action, "Autoplay blocked because the user didn't interact with the document first", description, - HMSTrackExceptionType.AUDIO, + HMSTrackExceptionTrackType.AUDIO, ); }, @@ -196,7 +196,7 @@ export const ErrorFactory = { action, `Codec can't be changed mid call.`, description, - HMSTrackExceptionType.AV, + HMSTrackExceptionTrackType.AV, ); }, @@ -207,7 +207,7 @@ export const ErrorFactory = { action, `[TRACK]: Requested constraints cannot be satisfied with the device hardware - ${deviceInfo}`, description, - deviceInfo as HMSTrackExceptionType, + deviceInfo as HMSTrackExceptionTrackType, ); }, @@ -218,7 +218,7 @@ export const ErrorFactory = { action, 'No audio input detected from microphone', description, - HMSTrackExceptionType.AUDIO, + HMSTrackExceptionTrackType.AUDIO, ); }, @@ -229,7 +229,7 @@ export const ErrorFactory = { action, `Operating System denied permission to access capture device - ${deviceInfo}`, description, - deviceInfo as HMSTrackExceptionType, + deviceInfo as HMSTrackExceptionTrackType, ); }, @@ -240,7 +240,7 @@ export const ErrorFactory = { HMSAction.TRACK, 'The app requires you to share the current tab', 'You must screen share the current tab in order to proceed', - HMSTrackExceptionType.SCREEN, + HMSTrackExceptionTrackType.SCREEN, ); }, @@ -251,7 +251,7 @@ export const ErrorFactory = { HMSAction.TRACK, description, description, - HMSTrackExceptionType.AUDIO, + HMSTrackExceptionTrackType.AUDIO, ); }, @@ -262,7 +262,7 @@ export const ErrorFactory = { HMSAction.TRACK, `Could not detect selected ${deviceType} device`, `Please check connection to the ${deviceType} device`, - deviceType as HMSTrackExceptionType, + deviceType as HMSTrackExceptionTrackType, ); }, @@ -273,7 +273,7 @@ export const ErrorFactory = { HMSAction.TRACK, description, 'This could possibily due to another application taking priority over the access to camera or microphone or due to an incoming call', - HMSTrackExceptionType.AV, + HMSTrackExceptionTrackType.AV, ); }, }, diff --git a/packages/hms-video-store/src/error/HMSException.ts b/packages/hms-video-store/src/error/HMSException.ts index e2ef942eca..9adf1eee07 100644 --- a/packages/hms-video-store/src/error/HMSException.ts +++ b/packages/hms-video-store/src/error/HMSException.ts @@ -1,6 +1,6 @@ import { HMSAction } from './HMSAction'; import { IAnalyticsPropertiesProvider } from '../analytics/IAnalyticsPropertiesProvider'; -import { HMSTrackExceptionType } from '../media/tracks/HMSTrackExceptionType'; +import { HMSTrackExceptionTrackType } from '../media/tracks/HMSTrackExceptionTrackType'; import { HMSSignalMethod } from '../signal/jsonrpc/models'; export class HMSException extends Error implements IAnalyticsPropertiesProvider { @@ -57,7 +57,7 @@ export class HMSTrackException extends HMSException { action: HMSAction | HMSSignalMethod, message: string, description: string, - public trackType: HMSTrackExceptionType, + public trackType: HMSTrackExceptionTrackType, ) { super(code, name, action, message, description, false); } diff --git a/packages/hms-video-store/src/media/tracks/HMSTrackExceptionType.ts b/packages/hms-video-store/src/media/tracks/HMSTrackExceptionTrackType.ts similarity index 67% rename from packages/hms-video-store/src/media/tracks/HMSTrackExceptionType.ts rename to packages/hms-video-store/src/media/tracks/HMSTrackExceptionTrackType.ts index 799c3389c1..fb498efc7a 100644 --- a/packages/hms-video-store/src/media/tracks/HMSTrackExceptionType.ts +++ b/packages/hms-video-store/src/media/tracks/HMSTrackExceptionTrackType.ts @@ -1,4 +1,4 @@ -export enum HMSTrackExceptionType { +export enum HMSTrackExceptionTrackType { AUDIO = 'audio', VIDEO = 'video', AV = 'audio, video', diff --git a/packages/hms-video-store/src/schema/error.ts b/packages/hms-video-store/src/schema/error.ts index c2ea1c4a24..7f71cf349c 100644 --- a/packages/hms-video-store/src/schema/error.ts +++ b/packages/hms-video-store/src/schema/error.ts @@ -1,4 +1,4 @@ -import { HMSTrackExceptionType } from '../media/tracks/HMSTrackExceptionType'; +import { HMSTrackExceptionTrackType } from '../media/tracks/HMSTrackExceptionTrackType'; /** * any mid call error notification will be in this format @@ -23,5 +23,5 @@ export interface HMSTrackException { isTerminal: boolean; timestamp: Date; nativeError?: Error; - trackType: HMSTrackExceptionType; + trackType: HMSTrackExceptionTrackType; } diff --git a/packages/hms-video-store/src/sdk/LocalTrackManager.ts b/packages/hms-video-store/src/sdk/LocalTrackManager.ts index 7ac384215b..a1039e426f 100644 --- a/packages/hms-video-store/src/sdk/LocalTrackManager.ts +++ b/packages/hms-video-store/src/sdk/LocalTrackManager.ts @@ -27,7 +27,7 @@ import { HMSVideoTrackSettingsBuilder, } from '../media/settings'; import { HMSLocalStream } from '../media/streams/HMSLocalStream'; -import { HMSTrackExceptionType } from '../media/tracks/HMSTrackExceptionType'; +import { HMSTrackExceptionTrackType } from '../media/tracks/HMSTrackExceptionTrackType'; import ITransportObserver from '../transport/ITransportObserver'; import HMSLogger from '../utils/logger'; import { HMSAudioContextHandler } from '../utils/media'; @@ -237,7 +237,7 @@ export class LocalTrackManager { } } catch (err) { HMSLogger.w(this.TAG, 'error in getting screenshare - ', err); - const error = BuildGetMediaError(err as Error, HMSTrackExceptionType.SCREEN); + const error = BuildGetMediaError(err as Error, HMSTrackExceptionTrackType.SCREEN); this.eventBus.analytics.publish( AnalyticsEventFactory.publish({ error: error as Error, @@ -479,17 +479,17 @@ export class LocalTrackManager { } } - getErrorType(videoError: boolean, audioError: boolean): HMSTrackExceptionType { + getErrorType(videoError: boolean, audioError: boolean): HMSTrackExceptionTrackType { if (videoError && audioError) { - return HMSTrackExceptionType.AV; + return HMSTrackExceptionTrackType.AV; } if (videoError) { - return HMSTrackExceptionType.VIDEO; + return HMSTrackExceptionTrackType.VIDEO; } if (audioError) { - return HMSTrackExceptionType.AUDIO; + return HMSTrackExceptionTrackType.AUDIO; } - return HMSTrackExceptionType.AV; + return HMSTrackExceptionTrackType.AV; } private getEmptyTracks(fetchTrackOptions: IFetchAVTrackOptions) { diff --git a/packages/hms-video-store/src/utils/media.ts b/packages/hms-video-store/src/utils/media.ts index a7ba51faa0..1aaa5ddcbc 100644 --- a/packages/hms-video-store/src/utils/media.ts +++ b/packages/hms-video-store/src/utils/media.ts @@ -1,13 +1,13 @@ import HMSLogger from './logger'; import { BuildGetMediaError } from '../error/utils'; -import { HMSTrackExceptionType } from '../media/tracks/HMSTrackExceptionType'; +import { HMSTrackExceptionTrackType } from '../media/tracks/HMSTrackExceptionTrackType'; export async function getLocalStream(constraints: MediaStreamConstraints): Promise { try { const stream = await navigator.mediaDevices.getUserMedia(constraints); return stream; } catch (err) { - throw BuildGetMediaError(err as Error, HMSTrackExceptionType.AV); + throw BuildGetMediaError(err as Error, HMSTrackExceptionTrackType.AV); } } @@ -17,7 +17,7 @@ export async function getLocalScreen(constraints: MediaStreamConstraints['video' const stream = await navigator.mediaDevices.getDisplayMedia({ video: constraints, audio: false }); return stream; } catch (err) { - throw BuildGetMediaError(err as Error, HMSTrackExceptionType.SCREEN); + throw BuildGetMediaError(err as Error, HMSTrackExceptionTrackType.SCREEN); } } @@ -38,7 +38,7 @@ export async function getLocalDevices(): Promise { devices.forEach(device => deviceGroups[device.kind].push(device)); return deviceGroups; } catch (err) { - throw BuildGetMediaError(err as Error, HMSTrackExceptionType.AV); + throw BuildGetMediaError(err as Error, HMSTrackExceptionTrackType.AV); } } diff --git a/packages/hms-video-store/src/utils/track.ts b/packages/hms-video-store/src/utils/track.ts index 66fad1eb0a..6af65ce30f 100644 --- a/packages/hms-video-store/src/utils/track.ts +++ b/packages/hms-video-store/src/utils/track.ts @@ -1,6 +1,6 @@ import { BuildGetMediaError } from '../error/utils'; import { HMSAudioTrackSettings, HMSVideoTrackSettings } from '../media/settings'; -import { HMSTrackExceptionType } from '../media/tracks/HMSTrackExceptionType'; +import { HMSTrackExceptionTrackType } from '../media/tracks/HMSTrackExceptionTrackType'; export async function getAudioTrack(settings: HMSAudioTrackSettings): Promise { try { @@ -9,7 +9,7 @@ export async function getAudioTrack(settings: HMSAudioTrackSettings): Promise Date: Thu, 31 Oct 2024 12:31:16 +0530 Subject: [PATCH 10/20] fix: move track exception to new file --- .../hms-video-store/src/error/ErrorFactory.ts | 3 +- .../hms-video-store/src/error/HMSException.ts | 34 ----------------- .../src/error/HMSTrackException.ts | 37 +++++++++++++++++++ packages/hms-video-store/src/error/utils.ts | 2 +- 4 files changed, 40 insertions(+), 36 deletions(-) create mode 100644 packages/hms-video-store/src/error/HMSTrackException.ts diff --git a/packages/hms-video-store/src/error/ErrorFactory.ts b/packages/hms-video-store/src/error/ErrorFactory.ts index a1493d989c..e76f7c9332 100644 --- a/packages/hms-video-store/src/error/ErrorFactory.ts +++ b/packages/hms-video-store/src/error/ErrorFactory.ts @@ -7,7 +7,8 @@ import { ErrorCodes } from './ErrorCodes'; import { HMSAction } from './HMSAction'; -import { HMSException, HMSTrackException } from './HMSException'; +import { HMSException } from './HMSException'; +import { HMSTrackException } from './HMSTrackException'; import { HMSTrackExceptionTrackType } from '../media/tracks/HMSTrackExceptionTrackType'; import { HMSSignalMethod } from '../signal/jsonrpc/models'; diff --git a/packages/hms-video-store/src/error/HMSException.ts b/packages/hms-video-store/src/error/HMSException.ts index 9adf1eee07..88513d117d 100644 --- a/packages/hms-video-store/src/error/HMSException.ts +++ b/packages/hms-video-store/src/error/HMSException.ts @@ -1,6 +1,5 @@ import { HMSAction } from './HMSAction'; import { IAnalyticsPropertiesProvider } from '../analytics/IAnalyticsPropertiesProvider'; -import { HMSTrackExceptionTrackType } from '../media/tracks/HMSTrackExceptionTrackType'; import { HMSSignalMethod } from '../signal/jsonrpc/models'; export class HMSException extends Error implements IAnalyticsPropertiesProvider { @@ -49,36 +48,3 @@ export class HMSException extends Error implements IAnalyticsPropertiesProvider }`; } } - -export class HMSTrackException extends HMSException { - constructor( - code: number, - name: string, - action: HMSAction | HMSSignalMethod, - message: string, - description: string, - public trackType: HMSTrackExceptionTrackType, - ) { - super(code, name, action, message, description, false); - } - - toAnalyticsProperties() { - return { - ...super.toAnalyticsProperties(), - track_type: this.trackType, - }; - } - - toString() { - return `{ - code: ${this.code}; - name: ${this.name}; - action: ${this.action}; - message: ${this.message}; - description: ${this.description}; - isTerminal: ${this.isTerminal}; - nativeError: ${this.nativeError?.message}; - trackType: ${this.trackType}; - }`; - } -} diff --git a/packages/hms-video-store/src/error/HMSTrackException.ts b/packages/hms-video-store/src/error/HMSTrackException.ts new file mode 100644 index 0000000000..f8dde88983 --- /dev/null +++ b/packages/hms-video-store/src/error/HMSTrackException.ts @@ -0,0 +1,37 @@ +import { HMSAction } from './HMSAction'; +import { HMSException } from './HMSException'; +import { HMSTrackExceptionTrackType } from '../media/tracks/HMSTrackExceptionTrackType'; +import { HMSSignalMethod } from '../signal/jsonrpc/models'; + +export class HMSTrackException extends HMSException { + constructor( + code: number, + name: string, + action: HMSAction | HMSSignalMethod, + message: string, + description: string, + public trackType: HMSTrackExceptionTrackType, + ) { + super(code, name, action, message, description, false); + } + + toAnalyticsProperties() { + return { + ...super.toAnalyticsProperties(), + track_type: this.trackType, + }; + } + + toString() { + return `{ + code: ${this.code}; + name: ${this.name}; + action: ${this.action}; + message: ${this.message}; + description: ${this.description}; + isTerminal: ${this.isTerminal}; + nativeError: ${this.nativeError?.message}; + trackType: ${this.trackType}; + }`; + } +} diff --git a/packages/hms-video-store/src/error/utils.ts b/packages/hms-video-store/src/error/utils.ts index a5084d8191..36c5efbbbf 100644 --- a/packages/hms-video-store/src/error/utils.ts +++ b/packages/hms-video-store/src/error/utils.ts @@ -1,7 +1,7 @@ import adapter from 'webrtc-adapter'; import { ErrorFactory } from './ErrorFactory'; import { HMSAction } from './HMSAction'; -import { HMSTrackException } from './HMSException'; +import { HMSTrackException } from './HMSTrackException'; export enum HMSGetMediaActions { UNKNOWN = 'unknown(video or audio)', From 69978027f3527cb0376f7f393021f5cb391ef5d6 Mon Sep 17 00:00:00 2001 From: hdz-666 <93115614+hdz-666@users.noreply.github.com> Date: Thu, 31 Oct 2024 12:32:43 +0530 Subject: [PATCH 11/20] fix: introduce HMSTrackException --- packages/hms-video-store/src/internal.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/hms-video-store/src/internal.ts b/packages/hms-video-store/src/internal.ts index 22ad33d6c9..dda7d2ba85 100644 --- a/packages/hms-video-store/src/internal.ts +++ b/packages/hms-video-store/src/internal.ts @@ -11,6 +11,7 @@ export * from './utils/media'; export * from './utils/device-error'; export * from './utils/support'; export * from './error/HMSException'; +export * from './error/HMSTrackException'; export * from './interfaces'; export * from './rtc-stats'; export * from './plugins'; From 67ed174b4860ad9f2c25c5b0ac74f7eddd3d9e37 Mon Sep 17 00:00:00 2001 From: hdz-666 <93115614+hdz-666@users.noreply.github.com> Date: Thu, 31 Oct 2024 15:35:32 +0530 Subject: [PATCH 12/20] fix: add error handling on prebuilt side --- packages/hms-video-store/src/error/HMSTrackException.ts | 8 ++++---- packages/hms-video-store/src/reactive-store/adapter.ts | 7 ++++--- packages/hms-video-store/src/schema/notification.ts | 4 ++-- packages/roomkit-react/src/Diagnostics/AudioTest.tsx | 4 ++-- packages/roomkit-react/src/Diagnostics/VideoTest.tsx | 3 ++- .../components/Notifications/PermissionErrorModal.tsx | 6 +++--- 6 files changed, 17 insertions(+), 15 deletions(-) diff --git a/packages/hms-video-store/src/error/HMSTrackException.ts b/packages/hms-video-store/src/error/HMSTrackException.ts index f8dde88983..1a8f9c666b 100644 --- a/packages/hms-video-store/src/error/HMSTrackException.ts +++ b/packages/hms-video-store/src/error/HMSTrackException.ts @@ -5,11 +5,11 @@ import { HMSSignalMethod } from '../signal/jsonrpc/models'; export class HMSTrackException extends HMSException { constructor( - code: number, - name: string, + public readonly code: number, + public name: string, action: HMSAction | HMSSignalMethod, - message: string, - description: string, + public message: string, + public description: string, public trackType: HMSTrackExceptionTrackType, ) { super(code, name, action, message, description, false); diff --git a/packages/hms-video-store/src/reactive-store/adapter.ts b/packages/hms-video-store/src/reactive-store/adapter.ts index e33a7013a8..b6c4ea7b29 100644 --- a/packages/hms-video-store/src/reactive-store/adapter.ts +++ b/packages/hms-video-store/src/reactive-store/adapter.ts @@ -204,7 +204,8 @@ export class SDKToHMS { }; } - static convertException(sdkException: sdkTypes.HMSException): HMSException { + static convertException(sdkException: sdkTypes.HMSException): HMSException | HMSTrackException { + const isTrackException = 'trackType' in sdkException; const exp = { code: sdkException.code, action: sdkException.action, @@ -215,8 +216,8 @@ export class SDKToHMS { nativeError: sdkException.nativeError, timestamp: new Date(), } as HMSException; - if (sdkException instanceof sdkTypes.HMSTrackException) { - (exp as HMSTrackException).trackType = sdkException.trackType; + if (isTrackException) { + (exp as HMSTrackException).trackType = (sdkException as sdkTypes.HMSTrackException)?.trackType; return exp as HMSTrackException; } return exp; diff --git a/packages/hms-video-store/src/schema/notification.ts b/packages/hms-video-store/src/schema/notification.ts index eb7fe063c5..2b985158d3 100644 --- a/packages/hms-video-store/src/schema/notification.ts +++ b/packages/hms-video-store/src/schema/notification.ts @@ -1,5 +1,5 @@ import { HMSDeviceChangeEvent } from './device-change'; -import { HMSException } from './error'; +import { HMSException, HMSTrackException } from './error'; import { HMSMessage } from './message'; import { HMSPeer, HMSTrack } from './peer'; import { HMSPlaylistItem } from './playlist'; @@ -44,7 +44,7 @@ export interface HMSMessageNotification extends BaseNotification { } export interface HMSExceptionNotification extends BaseNotification { type: HMSNotificationTypes.ERROR; - data: HMSException; + data: HMSException | HMSTrackException; } export interface HMSChangeTrackStateRequestNotification extends BaseNotification { type: HMSNotificationTypes.CHANGE_TRACK_STATE_REQUEST; diff --git a/packages/roomkit-react/src/Diagnostics/AudioTest.tsx b/packages/roomkit-react/src/Diagnostics/AudioTest.tsx index 5a197ea130..d70eda7490 100644 --- a/packages/roomkit-react/src/Diagnostics/AudioTest.tsx +++ b/packages/roomkit-react/src/Diagnostics/AudioTest.tsx @@ -1,7 +1,7 @@ /* eslint-disable react/prop-types */ import React, { useCallback, useEffect, useState } from 'react'; import { - HMSException, + HMSTrackException, selectDevices, selectLocalAudioTrackID, selectLocalMediaSettings, @@ -182,7 +182,7 @@ export const AudioTest = () => { - + ); }; diff --git a/packages/roomkit-react/src/Diagnostics/VideoTest.tsx b/packages/roomkit-react/src/Diagnostics/VideoTest.tsx index 03b261551e..d3f2023e3f 100644 --- a/packages/roomkit-react/src/Diagnostics/VideoTest.tsx +++ b/packages/roomkit-react/src/Diagnostics/VideoTest.tsx @@ -1,6 +1,7 @@ import React, { useEffect, useState } from 'react'; import { HMSException, + HMSTrackException, selectDevices, selectLocalMediaSettings, selectLocalVideoTrackID, @@ -66,7 +67,7 @@ export const VideoTest = () => { - + ); }; diff --git a/packages/roomkit-react/src/Prebuilt/components/Notifications/PermissionErrorModal.tsx b/packages/roomkit-react/src/Prebuilt/components/Notifications/PermissionErrorModal.tsx index 982fa900a5..b001797aaa 100644 --- a/packages/roomkit-react/src/Prebuilt/components/Notifications/PermissionErrorModal.tsx +++ b/packages/roomkit-react/src/Prebuilt/components/Notifications/PermissionErrorModal.tsx @@ -1,6 +1,6 @@ import React, { useEffect, useState } from 'react'; import { useMedia } from 'react-use'; -import { HMSException, HMSNotificationTypes, useHMSNotifications } from '@100mslive/react-sdk'; +import { HMSNotificationTypes, HMSTrackException, useHMSNotifications } from '@100mslive/react-sdk'; import { Button, config as cssConfig, Dialog, Flex, Text } from '../../..'; // @ts-ignore: No implicit Any import androidPermissionAlert from '../../images/android-perm-1.png'; @@ -11,10 +11,10 @@ import { isAndroid, isIOS } from '../../common/constants'; export function PermissionErrorNotificationModal() { const notification = useHMSNotifications(HMSNotificationTypes.ERROR); - return ; + return ; } -export const PermissionErrorModal = ({ error }: { error?: HMSException }) => { +export const PermissionErrorModal = ({ error }: { error?: HMSTrackException }) => { const [deviceType, setDeviceType] = useState(''); const [isSystemError, setIsSystemError] = useState(false); const isMobile = useMedia(cssConfig.media.md); From aac70ed1958f1fa8c56a1d524a002aa3b219d992 Mon Sep 17 00:00:00 2001 From: hdz-666 <93115614+hdz-666@users.noreply.github.com> Date: Thu, 31 Oct 2024 15:41:49 +0530 Subject: [PATCH 13/20] fix: export exception type enum --- packages/hms-video-store/src/index.ts | 2 ++ .../components/Notifications/PermissionErrorModal.tsx | 11 +++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/hms-video-store/src/index.ts b/packages/hms-video-store/src/index.ts index e26beb60ef..8d44ae20d5 100644 --- a/packages/hms-video-store/src/index.ts +++ b/packages/hms-video-store/src/index.ts @@ -78,3 +78,5 @@ export type { } from './internal'; export * from './diagnostics'; export { DomainCategory } from './analytics/AnalyticsEventDomains'; + +export { HMSTrackExceptionTrackType } from './media/tracks/HMSTrackExceptionTrackType'; diff --git a/packages/roomkit-react/src/Prebuilt/components/Notifications/PermissionErrorModal.tsx b/packages/roomkit-react/src/Prebuilt/components/Notifications/PermissionErrorModal.tsx index b001797aaa..67a099a5c9 100644 --- a/packages/roomkit-react/src/Prebuilt/components/Notifications/PermissionErrorModal.tsx +++ b/packages/roomkit-react/src/Prebuilt/components/Notifications/PermissionErrorModal.tsx @@ -1,5 +1,6 @@ import React, { useEffect, useState } from 'react'; import { useMedia } from 'react-use'; +import { HMSTrackExceptionTrackType } from '@100mslive/hms-video-store'; import { HMSNotificationTypes, HMSTrackException, useHMSNotifications } from '@100mslive/react-sdk'; import { Button, config as cssConfig, Dialog, Flex, Text } from '../../..'; // @ts-ignore: No implicit Any @@ -27,10 +28,12 @@ export const PermissionErrorModal = ({ error }: { error?: HMSTrackException }) = return; } const errorMessage = error?.message; - const hasAudio = errorMessage.includes('audio'); - const hasVideo = errorMessage.includes('video'); - const hasScreen = errorMessage.includes('screen'); - if (hasAudio && hasVideo) { + const errorTrackExceptionType = error?.trackType; + const hasAudio = errorTrackExceptionType === HMSTrackExceptionTrackType.AUDIO; + const hasVideo = errorMessage === HMSTrackExceptionTrackType.VIDEO; + const hasAudioVideo = errorMessage === HMSTrackExceptionTrackType.AV; + const hasScreen = errorMessage === HMSTrackExceptionTrackType.AV; + if (hasAudioVideo) { setDeviceType('camera and microphone'); } else if (hasAudio) { setDeviceType('microphone'); From b56471132e423ad498d5358d1fbf69f29f9e5d15 Mon Sep 17 00:00:00 2001 From: hdz-666 <93115614+hdz-666@users.noreply.github.com> Date: Thu, 31 Oct 2024 15:45:54 +0530 Subject: [PATCH 14/20] fix: add new changes for permission --- .../components/Notifications/PermissionErrorModal.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/roomkit-react/src/Prebuilt/components/Notifications/PermissionErrorModal.tsx b/packages/roomkit-react/src/Prebuilt/components/Notifications/PermissionErrorModal.tsx index 67a099a5c9..bd31a98f59 100644 --- a/packages/roomkit-react/src/Prebuilt/components/Notifications/PermissionErrorModal.tsx +++ b/packages/roomkit-react/src/Prebuilt/components/Notifications/PermissionErrorModal.tsx @@ -1,7 +1,11 @@ import React, { useEffect, useState } from 'react'; import { useMedia } from 'react-use'; -import { HMSTrackExceptionTrackType } from '@100mslive/hms-video-store'; -import { HMSNotificationTypes, HMSTrackException, useHMSNotifications } from '@100mslive/react-sdk'; +import { + HMSNotificationTypes, + HMSTrackException, + HMSTrackExceptionTrackType, + useHMSNotifications, +} from '@100mslive/react-sdk'; import { Button, config as cssConfig, Dialog, Flex, Text } from '../../..'; // @ts-ignore: No implicit Any import androidPermissionAlert from '../../images/android-perm-1.png'; From d445df00b5fb458be4647094df3a36f1c24ba349 Mon Sep 17 00:00:00 2001 From: hdz-666 <93115614+hdz-666@users.noreply.github.com> Date: Thu, 31 Oct 2024 15:51:29 +0530 Subject: [PATCH 15/20] fix: add new changes for trackexception aV renamed to audio video --- packages/hms-video-store/src/error/ErrorFactory.ts | 8 ++++---- .../src/media/tracks/HMSTrackExceptionTrackType.ts | 2 +- packages/hms-video-store/src/sdk/LocalTrackManager.ts | 4 ++-- packages/hms-video-store/src/utils/media.ts | 4 ++-- .../components/Notifications/PermissionErrorModal.tsx | 8 ++++---- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/hms-video-store/src/error/ErrorFactory.ts b/packages/hms-video-store/src/error/ErrorFactory.ts index e76f7c9332..c4b258c4a8 100644 --- a/packages/hms-video-store/src/error/ErrorFactory.ts +++ b/packages/hms-video-store/src/error/ErrorFactory.ts @@ -106,7 +106,7 @@ export const ErrorFactory = { action, `[TRACK]: ${description}`, `[TRACK]: ${description}`, - HMSTrackExceptionTrackType.AV, + HMSTrackExceptionTrackType.AUDIO_VIDEO, ); }, CantAccessCaptureDevice(action: HMSAction, deviceInfo: string, description = '') { @@ -164,7 +164,7 @@ export const ErrorFactory = { action, message, description, - HMSTrackExceptionTrackType.AV, + HMSTrackExceptionTrackType.AUDIO_VIDEO, ); }, @@ -197,7 +197,7 @@ export const ErrorFactory = { action, `Codec can't be changed mid call.`, description, - HMSTrackExceptionTrackType.AV, + HMSTrackExceptionTrackType.AUDIO_VIDEO, ); }, @@ -274,7 +274,7 @@ export const ErrorFactory = { HMSAction.TRACK, description, 'This could possibily due to another application taking priority over the access to camera or microphone or due to an incoming call', - HMSTrackExceptionTrackType.AV, + HMSTrackExceptionTrackType.AUDIO_VIDEO, ); }, }, diff --git a/packages/hms-video-store/src/media/tracks/HMSTrackExceptionTrackType.ts b/packages/hms-video-store/src/media/tracks/HMSTrackExceptionTrackType.ts index fb498efc7a..5bca9518b2 100644 --- a/packages/hms-video-store/src/media/tracks/HMSTrackExceptionTrackType.ts +++ b/packages/hms-video-store/src/media/tracks/HMSTrackExceptionTrackType.ts @@ -1,6 +1,6 @@ export enum HMSTrackExceptionTrackType { AUDIO = 'audio', VIDEO = 'video', - AV = 'audio, video', + AUDIO_VIDEO = 'audio, video', SCREEN = 'screen', } diff --git a/packages/hms-video-store/src/sdk/LocalTrackManager.ts b/packages/hms-video-store/src/sdk/LocalTrackManager.ts index a1039e426f..70103137db 100644 --- a/packages/hms-video-store/src/sdk/LocalTrackManager.ts +++ b/packages/hms-video-store/src/sdk/LocalTrackManager.ts @@ -481,7 +481,7 @@ export class LocalTrackManager { getErrorType(videoError: boolean, audioError: boolean): HMSTrackExceptionTrackType { if (videoError && audioError) { - return HMSTrackExceptionTrackType.AV; + return HMSTrackExceptionTrackType.AUDIO_VIDEO; } if (videoError) { return HMSTrackExceptionTrackType.VIDEO; @@ -489,7 +489,7 @@ export class LocalTrackManager { if (audioError) { return HMSTrackExceptionTrackType.AUDIO; } - return HMSTrackExceptionTrackType.AV; + return HMSTrackExceptionTrackType.AUDIO_VIDEO; } private getEmptyTracks(fetchTrackOptions: IFetchAVTrackOptions) { diff --git a/packages/hms-video-store/src/utils/media.ts b/packages/hms-video-store/src/utils/media.ts index 1aaa5ddcbc..05d60e443f 100644 --- a/packages/hms-video-store/src/utils/media.ts +++ b/packages/hms-video-store/src/utils/media.ts @@ -7,7 +7,7 @@ export async function getLocalStream(constraints: MediaStreamConstraints): Promi const stream = await navigator.mediaDevices.getUserMedia(constraints); return stream; } catch (err) { - throw BuildGetMediaError(err as Error, HMSTrackExceptionTrackType.AV); + throw BuildGetMediaError(err as Error, HMSTrackExceptionTrackType.AUDIO_VIDEO); } } @@ -38,7 +38,7 @@ export async function getLocalDevices(): Promise { devices.forEach(device => deviceGroups[device.kind].push(device)); return deviceGroups; } catch (err) { - throw BuildGetMediaError(err as Error, HMSTrackExceptionTrackType.AV); + throw BuildGetMediaError(err as Error, HMSTrackExceptionTrackType.AUDIO_VIDEO); } } diff --git a/packages/roomkit-react/src/Prebuilt/components/Notifications/PermissionErrorModal.tsx b/packages/roomkit-react/src/Prebuilt/components/Notifications/PermissionErrorModal.tsx index bd31a98f59..2b1b9459c1 100644 --- a/packages/roomkit-react/src/Prebuilt/components/Notifications/PermissionErrorModal.tsx +++ b/packages/roomkit-react/src/Prebuilt/components/Notifications/PermissionErrorModal.tsx @@ -31,12 +31,12 @@ export const PermissionErrorModal = ({ error }: { error?: HMSTrackException }) = ) { return; } - const errorMessage = error?.message; const errorTrackExceptionType = error?.trackType; + console.log(error); const hasAudio = errorTrackExceptionType === HMSTrackExceptionTrackType.AUDIO; - const hasVideo = errorMessage === HMSTrackExceptionTrackType.VIDEO; - const hasAudioVideo = errorMessage === HMSTrackExceptionTrackType.AV; - const hasScreen = errorMessage === HMSTrackExceptionTrackType.AV; + const hasVideo = errorTrackExceptionType === HMSTrackExceptionTrackType.VIDEO; + const hasAudioVideo = errorTrackExceptionType === HMSTrackExceptionTrackType.AUDIO_VIDEO; + const hasScreen = errorTrackExceptionType === HMSTrackExceptionTrackType.SCREEN; if (hasAudioVideo) { setDeviceType('camera and microphone'); } else if (hasAudio) { From 9516e7550c74aae202edf2324aa4fb2fcc2991a5 Mon Sep 17 00:00:00 2001 From: hdz-666 <93115614+hdz-666@users.noreply.github.com> Date: Thu, 31 Oct 2024 15:51:59 +0530 Subject: [PATCH 16/20] fix: add new changes for trackexception aV renamed to audio video --- .../Prebuilt/components/Notifications/PermissionErrorModal.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/roomkit-react/src/Prebuilt/components/Notifications/PermissionErrorModal.tsx b/packages/roomkit-react/src/Prebuilt/components/Notifications/PermissionErrorModal.tsx index 2b1b9459c1..0a69f67e1f 100644 --- a/packages/roomkit-react/src/Prebuilt/components/Notifications/PermissionErrorModal.tsx +++ b/packages/roomkit-react/src/Prebuilt/components/Notifications/PermissionErrorModal.tsx @@ -32,7 +32,6 @@ export const PermissionErrorModal = ({ error }: { error?: HMSTrackException }) = return; } const errorTrackExceptionType = error?.trackType; - console.log(error); const hasAudio = errorTrackExceptionType === HMSTrackExceptionTrackType.AUDIO; const hasVideo = errorTrackExceptionType === HMSTrackExceptionTrackType.VIDEO; const hasAudioVideo = errorTrackExceptionType === HMSTrackExceptionTrackType.AUDIO_VIDEO; From 582b8c5f1ca6015a255cbcd58368584e41812e3d Mon Sep 17 00:00:00 2001 From: hdz-666 <93115614+hdz-666@users.noreply.github.com> Date: Thu, 31 Oct 2024 15:58:07 +0530 Subject: [PATCH 17/20] fix: add new changes for error code handling --- .../Notifications/DeviceInUseError.tsx | 17 ++++++++++++----- .../Notifications/PermissionErrorModal.tsx | 8 +++++--- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/packages/roomkit-react/src/Prebuilt/components/Notifications/DeviceInUseError.tsx b/packages/roomkit-react/src/Prebuilt/components/Notifications/DeviceInUseError.tsx index 3249d845ca..4dcceb3821 100644 --- a/packages/roomkit-react/src/Prebuilt/components/Notifications/DeviceInUseError.tsx +++ b/packages/roomkit-react/src/Prebuilt/components/Notifications/DeviceInUseError.tsx @@ -1,5 +1,10 @@ import React, { useEffect, useState } from 'react'; -import { HMSNotificationTypes, useHMSNotifications } from '@100mslive/react-sdk'; +import { + HMSNotificationTypes, + HMSTrackException, + HMSTrackExceptionTrackType, + useHMSNotifications, +} from '@100mslive/react-sdk'; import { Button, Dialog, Text } from '../../..'; // @ts-ignore: No implicit Any import { DialogContent, DialogRow } from '../../primitives/DialogContent'; @@ -24,6 +29,11 @@ export function DeviceInUseError() { if (!error || error.code !== 3003) { return; } + const errorTrackExceptionType = (error as HMSTrackException)?.trackType; + const hasAudio = errorTrackExceptionType === HMSTrackExceptionTrackType.AUDIO; + const hasVideo = errorTrackExceptionType === HMSTrackExceptionTrackType.VIDEO; + const hasAudioVideo = errorTrackExceptionType === HMSTrackExceptionTrackType.AUDIO_VIDEO; + const hasScreen = errorTrackExceptionType === HMSTrackExceptionTrackType.SCREEN; const errorMessage = error?.message; ToastManager.addToast({ @@ -35,10 +45,7 @@ export function DeviceInUseError() { ), }); - const hasAudio = errorMessage.includes('audio'); - const hasVideo = errorMessage.includes('video'); - const hasScreen = errorMessage.includes('screen'); - if (hasAudio && hasVideo) { + if (hasAudioVideo) { setDeviceType('camera and microphone'); } else if (hasAudio) { setDeviceType('microphone'); diff --git a/packages/roomkit-react/src/Prebuilt/components/Notifications/PermissionErrorModal.tsx b/packages/roomkit-react/src/Prebuilt/components/Notifications/PermissionErrorModal.tsx index 0a69f67e1f..f78de865d7 100644 --- a/packages/roomkit-react/src/Prebuilt/components/Notifications/PermissionErrorModal.tsx +++ b/packages/roomkit-react/src/Prebuilt/components/Notifications/PermissionErrorModal.tsx @@ -1,6 +1,7 @@ import React, { useEffect, useState } from 'react'; import { useMedia } from 'react-use'; import { + HMSException, HMSNotificationTypes, HMSTrackException, HMSTrackExceptionTrackType, @@ -16,10 +17,10 @@ import { isAndroid, isIOS } from '../../common/constants'; export function PermissionErrorNotificationModal() { const notification = useHMSNotifications(HMSNotificationTypes.ERROR); - return ; + return ; } -export const PermissionErrorModal = ({ error }: { error?: HMSTrackException }) => { +export const PermissionErrorModal = ({ error }: { error?: HMSTrackException | HMSException }) => { const [deviceType, setDeviceType] = useState(''); const [isSystemError, setIsSystemError] = useState(false); const isMobile = useMedia(cssConfig.media.md); @@ -31,7 +32,8 @@ export const PermissionErrorModal = ({ error }: { error?: HMSTrackException }) = ) { return; } - const errorTrackExceptionType = error?.trackType; + + const errorTrackExceptionType = (error as HMSTrackException)?.trackType; const hasAudio = errorTrackExceptionType === HMSTrackExceptionTrackType.AUDIO; const hasVideo = errorTrackExceptionType === HMSTrackExceptionTrackType.VIDEO; const hasAudioVideo = errorTrackExceptionType === HMSTrackExceptionTrackType.AUDIO_VIDEO; From edaa044435fe485a11c629af2caa9a7135dce793 Mon Sep 17 00:00:00 2001 From: raviteja83 Date: Thu, 31 Oct 2024 16:50:39 +0530 Subject: [PATCH 18/20] fix: extend interface: --- packages/hms-video-store/src/schema/error.ts | 10 +--------- packages/hms-video-store/src/schema/notification.ts | 4 ++-- .../components/Notifications/PermissionErrorModal.tsx | 2 +- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/packages/hms-video-store/src/schema/error.ts b/packages/hms-video-store/src/schema/error.ts index 7f71cf349c..ca9dcb4572 100644 --- a/packages/hms-video-store/src/schema/error.ts +++ b/packages/hms-video-store/src/schema/error.ts @@ -14,14 +14,6 @@ export interface HMSException { nativeError?: Error; } -export interface HMSTrackException { - code: number; - action: string; - name: string; - message: string; - description: string; - isTerminal: boolean; - timestamp: Date; - nativeError?: Error; +export interface HMSTrackException extends HMSException { trackType: HMSTrackExceptionTrackType; } diff --git a/packages/hms-video-store/src/schema/notification.ts b/packages/hms-video-store/src/schema/notification.ts index 2b985158d3..eb7fe063c5 100644 --- a/packages/hms-video-store/src/schema/notification.ts +++ b/packages/hms-video-store/src/schema/notification.ts @@ -1,5 +1,5 @@ import { HMSDeviceChangeEvent } from './device-change'; -import { HMSException, HMSTrackException } from './error'; +import { HMSException } from './error'; import { HMSMessage } from './message'; import { HMSPeer, HMSTrack } from './peer'; import { HMSPlaylistItem } from './playlist'; @@ -44,7 +44,7 @@ export interface HMSMessageNotification extends BaseNotification { } export interface HMSExceptionNotification extends BaseNotification { type: HMSNotificationTypes.ERROR; - data: HMSException | HMSTrackException; + data: HMSException; } export interface HMSChangeTrackStateRequestNotification extends BaseNotification { type: HMSNotificationTypes.CHANGE_TRACK_STATE_REQUEST; diff --git a/packages/roomkit-react/src/Prebuilt/components/Notifications/PermissionErrorModal.tsx b/packages/roomkit-react/src/Prebuilt/components/Notifications/PermissionErrorModal.tsx index f78de865d7..c605dd5b3e 100644 --- a/packages/roomkit-react/src/Prebuilt/components/Notifications/PermissionErrorModal.tsx +++ b/packages/roomkit-react/src/Prebuilt/components/Notifications/PermissionErrorModal.tsx @@ -20,7 +20,7 @@ export function PermissionErrorNotificationModal() { return ; } -export const PermissionErrorModal = ({ error }: { error?: HMSTrackException | HMSException }) => { +export const PermissionErrorModal = ({ error }: { error?: HMSException }) => { const [deviceType, setDeviceType] = useState(''); const [isSystemError, setIsSystemError] = useState(false); const isMobile = useMedia(cssConfig.media.md); From bd53e27f21c161d838e7b9cdccd75de819d572d0 Mon Sep 17 00:00:00 2001 From: hdz-666 <93115614+hdz-666@users.noreply.github.com> Date: Thu, 31 Oct 2024 16:54:15 +0530 Subject: [PATCH 19/20] fix: add hms exception back --- packages/roomkit-react/src/Diagnostics/AudioTest.tsx | 4 ++-- packages/roomkit-react/src/Diagnostics/VideoTest.tsx | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/roomkit-react/src/Diagnostics/AudioTest.tsx b/packages/roomkit-react/src/Diagnostics/AudioTest.tsx index d70eda7490..5a197ea130 100644 --- a/packages/roomkit-react/src/Diagnostics/AudioTest.tsx +++ b/packages/roomkit-react/src/Diagnostics/AudioTest.tsx @@ -1,7 +1,7 @@ /* eslint-disable react/prop-types */ import React, { useCallback, useEffect, useState } from 'react'; import { - HMSTrackException, + HMSException, selectDevices, selectLocalAudioTrackID, selectLocalMediaSettings, @@ -182,7 +182,7 @@ export const AudioTest = () => { - + ); }; diff --git a/packages/roomkit-react/src/Diagnostics/VideoTest.tsx b/packages/roomkit-react/src/Diagnostics/VideoTest.tsx index d3f2023e3f..97d1720839 100644 --- a/packages/roomkit-react/src/Diagnostics/VideoTest.tsx +++ b/packages/roomkit-react/src/Diagnostics/VideoTest.tsx @@ -1,7 +1,6 @@ import React, { useEffect, useState } from 'react'; import { HMSException, - HMSTrackException, selectDevices, selectLocalMediaSettings, selectLocalVideoTrackID, @@ -67,7 +66,7 @@ export const VideoTest = () => { - + ); }; From ef56f34650ff4fb051c73d686df1ee00144f5b94 Mon Sep 17 00:00:00 2001 From: hdz-666 <93115614+hdz-666@users.noreply.github.com> Date: Thu, 31 Oct 2024 17:10:37 +0530 Subject: [PATCH 20/20] fix: add audio video --- packages/roomkit-react/src/Diagnostics/VideoTest.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/roomkit-react/src/Diagnostics/VideoTest.tsx b/packages/roomkit-react/src/Diagnostics/VideoTest.tsx index 97d1720839..03b261551e 100644 --- a/packages/roomkit-react/src/Diagnostics/VideoTest.tsx +++ b/packages/roomkit-react/src/Diagnostics/VideoTest.tsx @@ -66,7 +66,7 @@ export const VideoTest = () => { - + ); };