@100mslive/hms-video-store 0.2.82 → 0.2.83

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/dist/common/ui-logger.d.ts +13 -13
  2. package/dist/core/IHMSActions.d.ts +266 -264
  3. package/dist/core/IHMSNotifications.d.ts +14 -15
  4. package/dist/core/IHMSStore.d.ts +54 -56
  5. package/dist/core/hmsSDKStore/HMSNotifications.d.ts +25 -25
  6. package/dist/core/hmsSDKStore/HMSPlaylist.d.ts +21 -21
  7. package/dist/core/hmsSDKStore/HMSReactiveStore.d.ts +79 -79
  8. package/dist/core/hmsSDKStore/HMSSDKActions.d.ts +157 -157
  9. package/dist/core/hmsSDKStore/adapter.d.ts +49 -49
  10. package/dist/core/hmsSDKStore/common/mapping.d.ts +7 -7
  11. package/dist/core/hmsSDKStore/internalTypes.d.ts +4 -4
  12. package/dist/core/hmsSDKStore/sdkTypes.d.ts +3 -2
  13. package/dist/core/hmsSDKStore/sdkUtils/ActionBatcher.d.ts +19 -19
  14. package/dist/core/hmsSDKStore/sdkUtils/sdkUtils.d.ts +2 -2
  15. package/dist/core/hmsSDKStore/sdkUtils/storeMergeUtils.d.ts +14 -14
  16. package/dist/core/index.d.ts +9 -7
  17. package/dist/core/schema/device-change.d.ts +13 -13
  18. package/dist/core/schema/error.d.ts +13 -13
  19. package/dist/core/schema/index.d.ts +11 -11
  20. package/dist/core/schema/message.d.ts +31 -31
  21. package/dist/core/schema/notification.d.ts +40 -40
  22. package/dist/core/schema/peer.d.ts +67 -67
  23. package/dist/core/schema/playlist.d.ts +127 -109
  24. package/dist/core/schema/requests.d.ts +31 -31
  25. package/dist/core/schema/role.d.ts +3 -3
  26. package/dist/core/schema/room.d.ts +23 -23
  27. package/dist/core/schema/schema.d.ts +29 -29
  28. package/dist/core/schema/settings.d.ts +5 -5
  29. package/dist/core/selectors/derivedSelectors.d.ts +29 -29
  30. package/dist/core/selectors/index.d.ts +5 -5
  31. package/dist/core/selectors/playlistselectors.d.ts +3 -3
  32. package/dist/core/selectors/selectorUtils.d.ts +18 -18
  33. package/dist/core/selectors/selectors.d.ts +185 -191
  34. package/dist/core/selectors/selectorsByID.d.ts +127 -128
  35. package/dist/core/selectors/selectorsByReference.d.ts +3 -3
  36. package/dist/hms-video-store.cjs.js +1 -0
  37. package/dist/hms-video-store.esm.js +1 -5376
  38. package/dist/index.d.ts +1 -1
  39. package/package.json +21 -84
  40. package/dist/hms-video-store.cjs.development.js +0 -5468
  41. package/dist/hms-video-store.cjs.development.js.map +0 -1
  42. package/dist/hms-video-store.cjs.production.min.js +0 -2
  43. package/dist/hms-video-store.cjs.production.min.js.map +0 -1
  44. package/dist/hms-video-store.esm.js.map +0 -1
  45. package/dist/index.js +0 -8
  46. package/dist/test/fakeStore.d.ts +0 -23
  47. package/dist/test/fixtures.d.ts +0 -3
  48. package/src/common/ui-logger.ts +0 -88
  49. package/src/core/IHMSActions.ts +0 -318
  50. package/src/core/IHMSNotifications.ts +0 -16
  51. package/src/core/IHMSStore.ts +0 -60
  52. package/src/core/hmsSDKStore/HMSNotifications.ts +0 -194
  53. package/src/core/hmsSDKStore/HMSPlaylist.ts +0 -78
  54. package/src/core/hmsSDKStore/HMSReactiveStore.ts +0 -271
  55. package/src/core/hmsSDKStore/HMSSDKActions.ts +0 -1156
  56. package/src/core/hmsSDKStore/adapter.ts +0 -244
  57. package/src/core/hmsSDKStore/common/mapping.ts +0 -32
  58. package/src/core/hmsSDKStore/internalTypes.ts +0 -8
  59. package/src/core/hmsSDKStore/sdkTypes.ts +0 -55
  60. package/src/core/hmsSDKStore/sdkUtils/ActionBatcher.ts +0 -63
  61. package/src/core/hmsSDKStore/sdkUtils/sdkUtils.ts +0 -5
  62. package/src/core/hmsSDKStore/sdkUtils/storeMergeUtils.ts +0 -98
  63. package/src/core/index.ts +0 -18
  64. package/src/core/schema/device-change.ts +0 -14
  65. package/src/core/schema/error.ts +0 -13
  66. package/src/core/schema/index.ts +0 -11
  67. package/src/core/schema/message.ts +0 -35
  68. package/src/core/schema/notification.ts +0 -41
  69. package/src/core/schema/peer.ts +0 -78
  70. package/src/core/schema/playlist.ts +0 -114
  71. package/src/core/schema/requests.ts +0 -36
  72. package/src/core/schema/role.ts +0 -5
  73. package/src/core/schema/room.ts +0 -26
  74. package/src/core/schema/schema.ts +0 -94
  75. package/src/core/schema/settings.ts +0 -5
  76. package/src/core/selectors/derivedSelectors.ts +0 -81
  77. package/src/core/selectors/index.ts +0 -5
  78. package/src/core/selectors/playlistselectors.ts +0 -67
  79. package/src/core/selectors/selectorUtils.ts +0 -63
  80. package/src/core/selectors/selectors.ts +0 -400
  81. package/src/core/selectors/selectorsByID.ts +0 -401
  82. package/src/core/selectors/selectorsByReference.ts +0 -45
  83. package/src/index.ts +0 -1
  84. package/src/test/fakeStore.ts +0 -272
  85. package/src/test/fixtures.ts +0 -22
  86. package/src/test/integration/.gitkeep +0 -0
  87. package/src/test/unit/HMSNotifications.test.ts +0 -123
  88. package/src/test/unit/reactiveStore.test.ts +0 -129
  89. package/src/test/unit/roleSelectors.test.ts +0 -85
  90. package/src/test/unit/selectors.test.ts +0 -316
  91. package/src/test/unit/selectorsByReference.test.ts +0 -27
  92. package/src/test/unit/storeMergeUtils.test.ts +0 -168
@@ -1,78 +0,0 @@
1
- import { SimulcastLayerDefinition } from '@100mslive/hms-video';
2
- // noinspection ES6PreferShortImport
3
- import { HMSSimulcastLayer } from '../hmsSDKStore/sdkTypes';
4
- import { HMSRoleName } from './role';
5
-
6
- export type HMSPeerID = string;
7
- export type HMSTrackID = string;
8
- export type HMSTrackSource =
9
- | 'regular'
10
- | 'screen'
11
- | 'plugin'
12
- | 'audioplaylist'
13
- | 'videoplaylist'
14
- | string;
15
- export type HMSTrackType = 'audio' | 'video';
16
- export type HMSTrackDisplaySurface = 'application' | 'browser' | 'monitor' | 'window';
17
-
18
- /**
19
- * HMSPeer stores the details of individual participants in the room
20
- */
21
- export interface HMSPeer {
22
- id: HMSPeerID;
23
- name: string;
24
- roleName?: HMSRoleName;
25
- isLocal: boolean;
26
- isStarred?: boolean;
27
- videoTrack?: HMSTrackID;
28
- audioTrack?: HMSTrackID;
29
- auxiliaryTracks: HMSTrackID[];
30
- customerUserId?: string;
31
- metadata?: string;
32
- /**
33
- * @deprecated
34
- * Use metadata field instead.
35
- */
36
- customerDescription?: string;
37
- }
38
-
39
- /**
40
- * HMS Track stores details about individual tracks of the room. This object is
41
- * not meant to be used normally for UI interfaces, as interactions with this object
42
- * should be kept to bare minimum.
43
- * enabled - tells the real track enabled status, use this to call attach/detach video
44
- * displayEnabled - can be used to give immediate feedback to the user on button click
45
- * deviceID - this is the ID of the source device for the track. This can be a dummy ID when track is on mute.
46
- * degraded - tells whether the track has been degraded(receiving lower video quality/no video) due to bad network locally
47
- */
48
- export interface HMSTrack {
49
- id: HMSTrackID;
50
- source?: HMSTrackSource;
51
- type: HMSTrackType;
52
- enabled: boolean;
53
- height?: number;
54
- width?: number;
55
- peerId?: string;
56
- deviceID?: string;
57
- plugins?: string[];
58
- displayEnabled?: boolean;
59
- volume?: number;
60
- layer?: HMSSimulcastLayer;
61
- layerDefinitions?: SimulcastLayerDefinition[];
62
- degraded?: boolean;
63
- displaySurface?: HMSTrackDisplaySurface;
64
- }
65
-
66
- /**
67
- * HMS Speaker stores the details of peers speaking at any point of time along with
68
- * their audio levels. This can be used to current speakers or highlight videotiles.
69
- *
70
- * @privateRemarks
71
- * This is a separate interface instead of being part of the HMSPeer interface as the
72
- * corresponding update is high frequency.
73
- */
74
- export interface HMSSpeaker {
75
- peerID: HMSPeerID;
76
- trackID: HMSTrackID;
77
- audioLevel: number;
78
- }
@@ -1,114 +0,0 @@
1
- import { HMSStore } from '../schema';
2
-
3
- export enum HMSPlaylistType {
4
- audio = 'audio',
5
- video = 'video',
6
- }
7
- export interface HMSPlaylistItem<T> {
8
- name: string;
9
- id: string;
10
- metadata?: T;
11
- url: string;
12
- type: HMSPlaylistType;
13
- duration?: number;
14
- playing: boolean;
15
- selected: boolean;
16
- }
17
-
18
- export interface HMSPlaylistSelection {
19
- id: string;
20
- hasPrevious: boolean;
21
- hasNext: boolean;
22
- }
23
-
24
- export interface HMSPlaylist<T> {
25
- audio: {
26
- list: Record<string, HMSPlaylistItem<T>>;
27
- selection: HMSPlaylistSelection;
28
- progress: number;
29
- volume: number;
30
- currentTime: number;
31
- playbackRate: number;
32
- };
33
- video: {
34
- list: Record<string, HMSPlaylistItem<T>>;
35
- selection: HMSPlaylistSelection;
36
- progress: number;
37
- volume: number;
38
- currentTime: number;
39
- playbackRate: number;
40
- };
41
- }
42
-
43
- export interface IHMSPlaylistActions {
44
- /**
45
- * Pass the id of the item to be played
46
- * @param {string} id - id of playlist item
47
- */
48
- play(id: string): Promise<void>;
49
- /**
50
- * Pauses current playing item
51
- */
52
- pause(): Promise<void>;
53
- /**
54
- * PlayNext
55
- */
56
- playNext(): Promise<void>;
57
- /**
58
- * PlayPrevious
59
- */
60
- playPrevious(): Promise<void>;
61
- /**
62
- * seek passing seekValue - this is relative to current position
63
- * @param {number} seekValue - number in seconds to move forwards(pass negative values to move backwards)
64
- */
65
- seek(seekValue: number): void;
66
- /**
67
- * seek passing seekValue - seekValue will be absolute
68
- * @param {number} seekValue - value in seconds of absolute position in the playlist item duration
69
- */
70
- seekTo(seekValue: number): void;
71
- /**
72
- * set volume passing volume
73
- * @param {number} volume - number between 0-100
74
- */
75
- setVolume(volume: number): void;
76
- /**
77
- * pass list to set playlist
78
- * @param {HMSPlaylistItem[]} - list of playlist items
79
- */
80
- setList<T>(list: HMSPlaylistItem<T>[]): void;
81
- /**
82
- * Stop the current playback and remove the tracks
83
- */
84
- stop(): Promise<void>;
85
- /**
86
- * set whether to autoplay next item in playlist after the current one ends
87
- * @param {boolean} autoplay
88
- */
89
- setIsAutoplayOn(autoplay: boolean): void;
90
- /**
91
- * Control the playback speed - 1.0 being normal, less than 1.0 will play it slowly
92
- * and more than 1.0 will play it faster.
93
- * @param playbackRate - value from 0.25 and 2.0
94
- */
95
- setPlaybackRate(playbackRate: number): void;
96
- }
97
-
98
- export interface HMSPlaylistSelector {
99
- list: <T>(store: HMSStore) => HMSPlaylistItem<T>[];
100
- /**
101
- * This returns playlist selection with id, hasNext, hasPrev
102
- * @returns {HMSPlaylistSelection}
103
- */
104
- selection: (store: HMSStore) => HMSPlaylistSelection;
105
- /**
106
- * This returns playlist item for corresponding Id in selection
107
- * @returns {HMSPlaylistItem}
108
- */
109
- selectedItem: <T>(store: HMSStore) => HMSPlaylistItem<T>;
110
- progress: (store: HMSStore) => number;
111
- volume: (store: HMSStore) => number;
112
- currentTime: (store: HMSStore) => number;
113
- playbackRate: (store: HMSStore) => number;
114
- }
@@ -1,36 +0,0 @@
1
- import { HMSTrackSource } from '.';
2
- import { HMSPeer, HMSPeerID, HMSTrack } from './peer';
3
- import { HMSRoleName } from './role';
4
-
5
- export interface HMSRoleChangeStoreRequest {
6
- requestedBy: HMSPeerID;
7
- roleName: HMSRoleName;
8
- token: string;
9
- }
10
-
11
- export interface HMSChangeTrackStateRequest {
12
- requestedBy: HMSPeer;
13
- track: HMSTrack;
14
- enabled: boolean;
15
- }
16
-
17
- export interface HMSChangeMultiTrackStateRequest {
18
- requestedBy: HMSPeer;
19
- tracks: HMSTrack[];
20
- enabled: boolean;
21
- type?: 'audio' | 'video';
22
- source?: HMSTrackSource;
23
- }
24
-
25
- export interface HMSChangeMultiTrackStateParams {
26
- enabled: boolean;
27
- roles?: HMSRoleName[];
28
- type?: 'audio' | 'video';
29
- source?: HMSTrackSource;
30
- }
31
-
32
- export interface HMSLeaveRoomRequest {
33
- requestedBy?: HMSPeer;
34
- reason: string;
35
- roomEnded: boolean;
36
- }
@@ -1,5 +0,0 @@
1
- import { HMSRole } from '@100mslive/hms-video';
2
-
3
- export type HMSRoleName = string;
4
-
5
- export { HMSRole };
@@ -1,26 +0,0 @@
1
- import { HMSRecording, HMSRTMP } from '@100mslive/hms-video';
2
- import { HMSPeerID } from './peer';
3
-
4
- export type HMSRoomID = string;
5
-
6
- export enum HMSRoomState {
7
- Disconnected = 'Disconnected',
8
- Preview = 'Preview',
9
- Connecting = 'Connecting',
10
- Connected = 'Connected',
11
- Reconnecting = 'Reconnecting',
12
- Failed = 'Failed',
13
- }
14
-
15
- export interface HMSRoom {
16
- id: HMSRoomID;
17
- name: string;
18
- isConnected?: boolean;
19
- peers: HMSPeerID[];
20
- localPeer: HMSPeerID;
21
- shareableLink: string;
22
- hasWaitingRoom: boolean;
23
- roomState: HMSRoomState;
24
- recording: HMSRecording;
25
- rtmp: HMSRTMP;
26
- }
@@ -1,94 +0,0 @@
1
- import { HMSPeer, HMSPeerID, HMSTrackID, HMSTrack, HMSSpeaker } from './peer';
2
- import { HMSMessage, HMSMessageID } from './message';
3
- import { HMSRoom, HMSRoomState } from './room';
4
- import { HMSMediaSettings } from './settings';
5
- import { DeviceMap } from '../hmsSDKStore/sdkTypes';
6
- import { HMSRole } from './role';
7
- import { HMSRoleChangeStoreRequest } from './requests';
8
- import { HMSException } from './error';
9
- import { HMSPlaylist } from './playlist';
10
-
11
- /*
12
- * Defines the schema of the central store. UI Components are aware of the presence
13
- * of this central store. This is the global state - the single source of immutable truth.
14
- */
15
- export interface HMSStore {
16
- room: HMSRoom;
17
- peers: Record<HMSPeerID, HMSPeer>;
18
- speakers: Record<HMSTrackID, HMSSpeaker>;
19
- tracks: Record<HMSTrackID, HMSTrack>;
20
- playlist: HMSPlaylist<any>;
21
- messages: {
22
- byID: Record<HMSMessageID, HMSMessage>;
23
- allIDs: HMSMessageID[];
24
- };
25
- settings: HMSMediaSettings;
26
- devices: DeviceMap;
27
- roles: Record<string, HMSRole>;
28
- roleChangeRequests: HMSRoleChangeStoreRequest[];
29
- errors: HMSException[]; // for the convenience of debugging and seeing any error in devtools
30
- }
31
-
32
- /**
33
- * @internal
34
- */
35
- export const createDefaultStoreState = (): HMSStore => {
36
- return {
37
- room: {
38
- id: '',
39
- isConnected: false,
40
- name: '',
41
- peers: [],
42
- shareableLink: '',
43
- localPeer: '',
44
- hasWaitingRoom: false,
45
- roomState: HMSRoomState.Disconnected,
46
- recording: {
47
- browser: {
48
- running: false,
49
- },
50
- server: {
51
- running: false,
52
- },
53
- },
54
- rtmp: {
55
- running: false,
56
- },
57
- },
58
- peers: {},
59
- tracks: {},
60
- playlist: {
61
- audio: {
62
- list: {},
63
- selection: { id: '', hasPrevious: false, hasNext: false },
64
- progress: 0,
65
- volume: 0,
66
- currentTime: 0,
67
- playbackRate: 1.0,
68
- },
69
- video: {
70
- list: {},
71
- selection: { id: '', hasPrevious: false, hasNext: false },
72
- progress: 0,
73
- volume: 0,
74
- currentTime: 0,
75
- playbackRate: 1.0,
76
- },
77
- },
78
- messages: { byID: {}, allIDs: [] },
79
- speakers: {},
80
- settings: {
81
- audioInputDeviceId: '',
82
- audioOutputDeviceId: '',
83
- videoInputDeviceId: '',
84
- },
85
- devices: {
86
- audioInput: [],
87
- audioOutput: [],
88
- videoInput: [],
89
- },
90
- roles: {},
91
- roleChangeRequests: [],
92
- errors: [],
93
- };
94
- };
@@ -1,5 +0,0 @@
1
- export interface HMSMediaSettings {
2
- audioInputDeviceId: string;
3
- videoInputDeviceId: string;
4
- audioOutputDeviceId?: string;
5
- }
@@ -1,81 +0,0 @@
1
- import { HMSPeer, HMSStore } from '../schema';
2
- import { selectLocalPeerRole, selectPeersMap, selectRolesMap, selectTracksMap } from './selectors';
3
- import { createSelector } from 'reselect';
4
- import { HMSRole } from '@100mslive/hms-video';
5
-
6
- export interface HMSPeerWithMuteStatus {
7
- peer: HMSPeer;
8
- isAudioEnabled?: boolean;
9
- }
10
-
11
- /**
12
- * @privateRemarks
13
- * this is more friendly to UI format, the object in store has only peer id and role name instead of the full objects
14
- */
15
- export interface HMSRoleChangeRequest {
16
- requestedBy: HMSPeer;
17
- role: HMSRole;
18
- token: string;
19
- }
20
-
21
- export interface HMSPublishAllowed {
22
- video: boolean;
23
- audio: boolean;
24
- screen: boolean;
25
- }
26
-
27
- export const selectPeersWithAudioStatus = createSelector(
28
- [selectPeersMap, selectTracksMap],
29
- (peersMap, tracksMap) => {
30
- const participants: HMSPeerWithMuteStatus[] = Object.values(peersMap).map(peer => {
31
- return {
32
- peer: peer,
33
- isAudioEnabled: peer.audioTrack ? tracksMap[peer.audioTrack]?.enabled : false,
34
- };
35
- });
36
- return participants;
37
- },
38
- );
39
-
40
- const selectRoleChangeStoreRequest = (store: HMSStore) => {
41
- return store.roleChangeRequests[0] || null;
42
- };
43
-
44
- /**
45
- * Select the role change request received for your local peer.
46
- */
47
- export const selectRoleChangeRequest = createSelector(
48
- [selectRoleChangeStoreRequest, selectPeersMap, selectRolesMap],
49
- (request, peersMap, rolesMap): HMSRoleChangeRequest | null => {
50
- if (!request) {
51
- return null;
52
- }
53
- return {
54
- requestedBy: peersMap[request.requestedBy],
55
- role: rolesMap[request.roleName],
56
- token: request.token,
57
- };
58
- },
59
- );
60
-
61
- /**
62
- * Select what streams is the local peer allowed to publish from video, audio and screenshare.
63
- */
64
- export const selectIsAllowedToPublish = createSelector(
65
- [selectLocalPeerRole],
66
- (role): HMSPublishAllowed => {
67
- let video = false,
68
- audio = false,
69
- screen = false;
70
- if (role?.publishParams?.allowed) {
71
- video = role.publishParams.allowed.includes('video');
72
- audio = role.publishParams.allowed.includes('audio');
73
- screen = role.publishParams.allowed.includes('screen');
74
- }
75
- return {
76
- video,
77
- audio,
78
- screen,
79
- };
80
- },
81
- );
@@ -1,5 +0,0 @@
1
- export * from './selectors';
2
- export * from './playlistselectors';
3
- export * from './selectorsByID';
4
- export * from './derivedSelectors';
5
- export * from './selectorsByReference';
@@ -1,67 +0,0 @@
1
- import { createSelector } from 'reselect';
2
- import { HMSPlaylistType, HMSStore, HMSPlaylistSelector } from '../schema';
3
-
4
- /**
5
- * @internal
6
- */
7
- const selectPlaylistMap = (type: HMSPlaylistType = HMSPlaylistType.audio) => (store: HMSStore) =>
8
- store.playlist[type].list;
9
-
10
- const selectPlaylistSelection = (type: HMSPlaylistType = HMSPlaylistType.audio) => (
11
- store: HMSStore,
12
- ) => store.playlist[type].selection;
13
-
14
- const selectPlaylistProgress = (type: HMSPlaylistType = HMSPlaylistType.audio) => (
15
- store: HMSStore,
16
- ) => store.playlist[type].progress;
17
-
18
- const selectPlaylistCurrentTime = (type: HMSPlaylistType = HMSPlaylistType.audio) => (
19
- store: HMSStore,
20
- ) => store.playlist[type].currentTime;
21
-
22
- const selectPlaylistPlaybackRate = (type: HMSPlaylistType = HMSPlaylistType.audio) => (
23
- store: HMSStore,
24
- ) => store.playlist[type].playbackRate;
25
-
26
- const selectPlaylistVolume = (type: HMSPlaylistType = HMSPlaylistType.audio) => (store: HMSStore) =>
27
- store.playlist[type].volume;
28
-
29
- /**
30
- * Select an array of playlist items.
31
- */
32
- const selectPlaylist = (type: HMSPlaylistType = HMSPlaylistType.audio) =>
33
- createSelector(selectPlaylistMap(type), storePlaylist => {
34
- return Object.values(storePlaylist);
35
- });
36
-
37
- const selectPlaylistSelectedItem = (type: HMSPlaylistType = HMSPlaylistType.audio) =>
38
- createSelector(
39
- selectPlaylistMap(type),
40
- selectPlaylistSelection(type),
41
- (storePlaylist, currentSelection) => {
42
- if (!currentSelection.id) {
43
- return;
44
- }
45
- return storePlaylist[currentSelection.id];
46
- },
47
- );
48
-
49
- export const selectAudioPlaylist: HMSPlaylistSelector = {
50
- selection: selectPlaylistSelection(HMSPlaylistType.audio),
51
- progress: selectPlaylistProgress(HMSPlaylistType.audio),
52
- currentTime: selectPlaylistCurrentTime(HMSPlaylistType.audio),
53
- playbackRate: selectPlaylistPlaybackRate(HMSPlaylistType.audio),
54
- volume: selectPlaylistVolume(HMSPlaylistType.audio),
55
- list: selectPlaylist(HMSPlaylistType.audio),
56
- selectedItem: <any>selectPlaylistSelectedItem(HMSPlaylistType.audio),
57
- };
58
-
59
- export const selectVideoPlaylist: HMSPlaylistSelector = {
60
- selection: selectPlaylistSelection(HMSPlaylistType.video),
61
- progress: selectPlaylistProgress(HMSPlaylistType.video),
62
- currentTime: selectPlaylistCurrentTime(HMSPlaylistType.video),
63
- playbackRate: selectPlaylistPlaybackRate(HMSPlaylistType.video),
64
- volume: selectPlaylistVolume(HMSPlaylistType.video),
65
- list: selectPlaylist(HMSPlaylistType.video),
66
- selectedItem: <any>selectPlaylistSelectedItem(HMSPlaylistType.video),
67
- };
@@ -1,63 +0,0 @@
1
- import { HMSPeer, HMSStore, HMSTrack, HMSTrackID } from '../schema';
2
-
3
- type trackCheck = (track: HMSTrack | undefined) => boolean | undefined;
4
-
5
- export function getPeerTracksByCondition(
6
- tracks: Record<HMSTrackID, HMSTrack>,
7
- peer: HMSPeer | null,
8
- trackCheckFn: trackCheck = isScreenShare,
9
- ) {
10
- let videoTrack = undefined;
11
- let audioTrack = undefined;
12
- if (peer) {
13
- for (let trackID of peer.auxiliaryTracks) {
14
- const track = tracks[trackID];
15
- if (trackCheckFn(track)) {
16
- audioTrack = isAudio(track) ? track : audioTrack;
17
- videoTrack = isVideo(track) ? track : videoTrack;
18
- }
19
- }
20
- }
21
- return { video: videoTrack, audio: audioTrack };
22
- }
23
-
24
- export function isAudio(track: HMSTrack | undefined) {
25
- return track && track.type === 'audio';
26
- }
27
-
28
- export function isVideo(track: HMSTrack | undefined) {
29
- return track && track.type === 'video';
30
- }
31
-
32
- export function isScreenShare(track: HMSTrack | undefined) {
33
- return track && track.source === 'screen';
34
- }
35
-
36
- export function isAudioPlaylist(track: HMSTrack | undefined) {
37
- return track && track.source === 'audioplaylist';
38
- }
39
-
40
- export function isVideoPlaylist(track: HMSTrack | undefined) {
41
- return track && track.source === 'videoplaylist';
42
- }
43
-
44
- export function isDegraded(track: HMSTrack | undefined) {
45
- return Boolean(track?.degraded);
46
- }
47
-
48
- export function isTrackEnabled(store: HMSStore, trackID?: string) {
49
- if (trackID && store.tracks[trackID]) {
50
- return store.tracks[trackID].enabled;
51
- }
52
- return false;
53
- }
54
-
55
- /**
56
- * Should UI show the video track as enabled
57
- */
58
- export function isTrackDisplayEnabled(store: HMSStore, trackID?: string) {
59
- if (trackID && store.tracks[trackID]) {
60
- return store.tracks[trackID].displayEnabled;
61
- }
62
- return false;
63
- }