@100mslive/hms-video-store 0.3.4 → 0.4.0
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.
- package/dist/core/IHMSActions.d.ts +19 -1
- package/dist/core/hmsSDKStore/HMSSDKActions.d.ts +2 -1
- package/dist/core/hmsSDKStore/common/mapping.d.ts +10 -6
- package/dist/core/hmsSDKStore/sdkTypes.d.ts +2 -2
- package/dist/core/index.d.ts +1 -1
- package/dist/core/schema/device-change.d.ts +1 -0
- package/dist/core/schema/notification.d.ts +2 -3
- package/dist/core/schema/peer.d.ts +2 -2
- package/dist/core/schema/room.d.ts +2 -1
- package/dist/core/selectors/selectorsByID.d.ts +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +2 -2
- package/package.json +3 -3
- package/src/core/IHMSActions.ts +20 -0
- package/src/core/hmsSDKStore/HMSSDKActions.ts +27 -18
- package/src/core/hmsSDKStore/common/mapping.ts +5 -15
- package/src/core/hmsSDKStore/sdkTypes.ts +2 -0
- package/src/core/index.ts +0 -5
- package/src/core/schema/device-change.ts +2 -0
- package/src/core/schema/notification.ts +1 -2
- package/src/core/schema/peer.ts +2 -3
- package/src/core/schema/room.ts +2 -1
- package/src/test/unit/HMSNotifications.test.ts +0 -5
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.4.0",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"main": "dist/index.cjs.js",
|
|
5
5
|
"module": "dist/index.js",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"author": "100ms",
|
|
42
42
|
"sideEffects": false,
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@100mslive/hms-video": "0.
|
|
44
|
+
"@100mslive/hms-video": "0.3.0",
|
|
45
45
|
"eventemitter2": "^6.4.5",
|
|
46
46
|
"immer": "^9.0.6",
|
|
47
47
|
"reselect": "4.0.0",
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"url": "https://github.com/100mslive/hms-video-store/issues"
|
|
67
67
|
},
|
|
68
68
|
"homepage": "https://github.com/100mslive/hms-video-store#readme",
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "8400a49ebabd0846321deefd63d103f20d2962bd"
|
|
70
70
|
}
|
package/src/core/IHMSActions.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
HMSVideoPlugin,
|
|
8
8
|
HMSAudioPlugin,
|
|
9
9
|
HMSPluginSupportResult,
|
|
10
|
+
HLSTimedMetadata,
|
|
10
11
|
} from '@100mslive/hms-video';
|
|
11
12
|
import {
|
|
12
13
|
HMSMessageID,
|
|
@@ -315,6 +316,25 @@ export interface IHMSActions {
|
|
|
315
316
|
*/
|
|
316
317
|
stopHLSStreaming(params?: HLSConfig): Promise<void>;
|
|
317
318
|
|
|
319
|
+
/**
|
|
320
|
+
* @alpha
|
|
321
|
+
* Used to define date range metadata in a media playlist.
|
|
322
|
+
* This api adds EXT-X-DATERANGE tags to the media playlist.
|
|
323
|
+
* It is useful for defining timed metadata for interstitial regions such as advertisements,
|
|
324
|
+
* but can be used to define any timed metadata needed by your stream.
|
|
325
|
+
* usage (e.g)
|
|
326
|
+
* const metadataList = [{
|
|
327
|
+
* payload: "some string 1",
|
|
328
|
+
* duration: 2
|
|
329
|
+
* },
|
|
330
|
+
* {
|
|
331
|
+
* payload: "some string 2",
|
|
332
|
+
* duration: 3
|
|
333
|
+
* }]
|
|
334
|
+
* sendHLSTimedMetadata(metadataList);
|
|
335
|
+
*/
|
|
336
|
+
sendHLSTimedMetadata(metadataList: HLSTimedMetadata[]): Promise<void>;
|
|
337
|
+
|
|
318
338
|
/**
|
|
319
339
|
* If you want to update the name of peer.
|
|
320
340
|
*/
|
|
@@ -66,7 +66,7 @@ import { HMSNotifications } from './HMSNotifications';
|
|
|
66
66
|
import { NamedSetState } from './internalTypes';
|
|
67
67
|
import { isRemoteTrack } from './sdkUtils/sdkUtils';
|
|
68
68
|
import { HMSPlaylist } from './HMSPlaylist';
|
|
69
|
-
import {
|
|
69
|
+
import { PEER_NOTIFICATION_TYPES, TRACK_NOTIFICATION_TYPES } from './common/mapping';
|
|
70
70
|
|
|
71
71
|
// import { ActionBatcher } from './sdkUtils/ActionBatcher';
|
|
72
72
|
|
|
@@ -376,10 +376,13 @@ export class HMSSDKActions implements IHMSActions {
|
|
|
376
376
|
|
|
377
377
|
async detachVideo(trackID: string, videoElement: HTMLVideoElement) {
|
|
378
378
|
const sdkTrack = this.hmsSDKTracks[trackID];
|
|
379
|
-
if (sdkTrack
|
|
380
|
-
|
|
379
|
+
if (sdkTrack?.type === 'video') {
|
|
380
|
+
(sdkTrack as SDKHMSVideoTrack).removeSink(videoElement);
|
|
381
381
|
this.updateVideoLayer(trackID, 'detachVideo');
|
|
382
382
|
} else {
|
|
383
|
+
if (videoElement) {
|
|
384
|
+
videoElement.srcObject = null; // so chrome can clean up
|
|
385
|
+
}
|
|
383
386
|
this.logPossibleInconsistency('no video track found to remove sink');
|
|
384
387
|
}
|
|
385
388
|
}
|
|
@@ -550,6 +553,9 @@ export class HMSSDKActions implements IHMSActions {
|
|
|
550
553
|
await this.sdk.stopHLSStreaming(params);
|
|
551
554
|
}
|
|
552
555
|
|
|
556
|
+
async sendHLSTimedMetadata(metadataList: sdkTypes.HLSTimedMetadata[]): Promise<void> {
|
|
557
|
+
await this.sdk.sendHLSTimedMetadata(metadataList);
|
|
558
|
+
}
|
|
553
559
|
async changeName(name: string) {
|
|
554
560
|
await this.sdk.changeName(name);
|
|
555
561
|
}
|
|
@@ -605,12 +611,12 @@ export class HMSSDKActions implements IHMSActions {
|
|
|
605
611
|
}
|
|
606
612
|
|
|
607
613
|
private resetState(reason = 'resetState') {
|
|
608
|
-
this.setState(store => {
|
|
609
|
-
Object.assign(store, createDefaultStoreState());
|
|
610
|
-
}, reason);
|
|
611
614
|
this.isRoomJoinCalled = false;
|
|
612
615
|
this.hmsSDKTracks = {};
|
|
613
616
|
HMSLogger.cleanUp();
|
|
617
|
+
this.setState(store => {
|
|
618
|
+
Object.assign(store, createDefaultStoreState());
|
|
619
|
+
}, reason);
|
|
614
620
|
}
|
|
615
621
|
|
|
616
622
|
private sdkJoinWithListeners(config: sdkTypes.HMSConfig) {
|
|
@@ -670,8 +676,6 @@ export class HMSSDKActions implements IHMSActions {
|
|
|
670
676
|
Object.assign(store.settings, this.getMediaSettings(this.hmsSDKPeers[localPeer?.id]));
|
|
671
677
|
}
|
|
672
678
|
}, 'deviceChange');
|
|
673
|
-
// sync is needed to update the current selected device
|
|
674
|
-
// this.syncRoomState('deviceChangeSync');
|
|
675
679
|
// send notification only on device change - selection is present
|
|
676
680
|
if (event.selection) {
|
|
677
681
|
const notification = SDKToHMS.convertDeviceChangeUpdate(event);
|
|
@@ -731,7 +735,7 @@ export class HMSSDKActions implements IHMSActions {
|
|
|
731
735
|
private async attachVideoInternal(trackID: string, videoElement: HTMLVideoElement) {
|
|
732
736
|
const sdkTrack = this.hmsSDKTracks[trackID];
|
|
733
737
|
if (sdkTrack && sdkTrack.type === 'video') {
|
|
734
|
-
|
|
738
|
+
(sdkTrack as SDKHMSVideoTrack).addSink(videoElement);
|
|
735
739
|
this.updateVideoLayer(trackID, 'attachVideo');
|
|
736
740
|
} else {
|
|
737
741
|
this.logPossibleInconsistency('no video track found to add sink');
|
|
@@ -750,7 +754,8 @@ export class HMSSDKActions implements IHMSActions {
|
|
|
750
754
|
* interested in with a new reference.
|
|
751
755
|
* @protected
|
|
752
756
|
*/
|
|
753
|
-
protected syncRoomState(action
|
|
757
|
+
protected syncRoomState(action: string) {
|
|
758
|
+
action = `${action}_fullSync`;
|
|
754
759
|
HMSLogger.time(`store-sync-${action}`);
|
|
755
760
|
const newHmsPeers: Record<HMSPeerID, Partial<HMSPeer>> = {};
|
|
756
761
|
const newHmsPeerIDs: HMSPeerID[] = []; // to add in room.peers
|
|
@@ -846,11 +851,10 @@ export class HMSSDKActions implements IHMSActions {
|
|
|
846
851
|
});
|
|
847
852
|
}
|
|
848
853
|
|
|
849
|
-
//@ts-ignore
|
|
850
854
|
protected onRoomUpdate(type: sdkTypes.HMSRoomUpdate, room: sdkTypes.HMSRoom) {
|
|
851
855
|
this.setState(store => {
|
|
852
856
|
Object.assign(store.room, SDKToHMS.convertRoom(room));
|
|
853
|
-
},
|
|
857
|
+
}, type);
|
|
854
858
|
}
|
|
855
859
|
|
|
856
860
|
protected onPeerUpdate(type: sdkTypes.HMSPeerUpdate, sdkPeer: sdkTypes.HMSPeer | sdkTypes.HMSPeer[]) {
|
|
@@ -881,7 +885,7 @@ export class HMSSDKActions implements IHMSActions {
|
|
|
881
885
|
this.hmsNotifications.sendTrackUpdate(type, track.trackId);
|
|
882
886
|
this.handleTrackRemove(track, peer);
|
|
883
887
|
} else {
|
|
884
|
-
const actionName = type
|
|
888
|
+
const actionName = TRACK_NOTIFICATION_TYPES[type] || 'trackUpdate';
|
|
885
889
|
this.syncRoomState(actionName);
|
|
886
890
|
this.hmsNotifications.sendTrackUpdate(type, track.trackId);
|
|
887
891
|
}
|
|
@@ -1061,10 +1065,15 @@ export class HMSSDKActions implements IHMSActions {
|
|
|
1061
1065
|
private updateVideoLayer(trackID: string, action: string) {
|
|
1062
1066
|
const sdkTrack = this.hmsSDKTracks[trackID];
|
|
1063
1067
|
if (sdkTrack && sdkTrack instanceof SDKHMSRemoteVideoTrack) {
|
|
1064
|
-
this.
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
+
const storeTrack = this.store.getState(selectTrackByID(trackID));
|
|
1069
|
+
const hasFieldChanged =
|
|
1070
|
+
storeTrack?.layer !== sdkTrack.getSimulcastLayer() || storeTrack?.degraded !== sdkTrack.degraded;
|
|
1071
|
+
if (hasFieldChanged) {
|
|
1072
|
+
this.setState(draft => {
|
|
1073
|
+
draft.tracks[trackID].layer = sdkTrack.getSimulcastLayer();
|
|
1074
|
+
draft.tracks[trackID].degraded = sdkTrack.degraded;
|
|
1075
|
+
}, action);
|
|
1076
|
+
}
|
|
1068
1077
|
}
|
|
1069
1078
|
}
|
|
1070
1079
|
|
|
@@ -1263,7 +1272,7 @@ export class HMSSDKActions implements IHMSActions {
|
|
|
1263
1272
|
|
|
1264
1273
|
private sendPeerUpdateNotification = (type: sdkTypes.HMSPeerUpdate, sdkPeer: sdkTypes.HMSPeer) => {
|
|
1265
1274
|
let peer = this.store.getState(selectPeerByID(sdkPeer.peerId));
|
|
1266
|
-
const actionName =
|
|
1275
|
+
const actionName = PEER_NOTIFICATION_TYPES[type] || 'peerUpdate';
|
|
1267
1276
|
this.syncRoomState(actionName);
|
|
1268
1277
|
// if peer wasn't available before sync(will happen if event is peer join)
|
|
1269
1278
|
if (!peer) {
|
|
@@ -1,33 +1,23 @@
|
|
|
1
1
|
import * as sdkTypes from '../sdkTypes';
|
|
2
2
|
import { HMSNotificationTypes } from '../../schema';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
[key: number]: string;
|
|
6
|
-
}
|
|
4
|
+
type PeerNotificationMap = { [key in sdkTypes.HMSPeerUpdate]?: HMSNotificationTypes };
|
|
7
5
|
|
|
8
|
-
export const PEER_NOTIFICATION_TYPES:
|
|
6
|
+
export const PEER_NOTIFICATION_TYPES: PeerNotificationMap = {
|
|
9
7
|
[sdkTypes.HMSPeerUpdate.PEER_JOINED]: HMSNotificationTypes.PEER_JOINED,
|
|
10
8
|
[sdkTypes.HMSPeerUpdate.PEER_LEFT]: HMSNotificationTypes.PEER_LEFT,
|
|
11
9
|
[sdkTypes.HMSPeerUpdate.ROLE_UPDATED]: HMSNotificationTypes.ROLE_UPDATED,
|
|
12
|
-
[sdkTypes.HMSPeerUpdate.AUDIO_TOGGLED]: 'PEER_AUDIO_UPDATED',
|
|
13
|
-
[sdkTypes.HMSPeerUpdate.VIDEO_TOGGLED]: 'PEER_VIDEO_UPDATED',
|
|
14
10
|
[sdkTypes.HMSPeerUpdate.NAME_UPDATED]: HMSNotificationTypes.NAME_UPDATED,
|
|
15
11
|
[sdkTypes.HMSPeerUpdate.METADATA_UPDATED]: HMSNotificationTypes.METADATA_UPDATED,
|
|
16
12
|
};
|
|
17
13
|
|
|
18
|
-
|
|
14
|
+
type TrackNotificationMap = { [key in sdkTypes.HMSTrackUpdate]: HMSNotificationTypes };
|
|
15
|
+
export const TRACK_NOTIFICATION_TYPES: TrackNotificationMap = {
|
|
19
16
|
[sdkTypes.HMSTrackUpdate.TRACK_ADDED]: HMSNotificationTypes.TRACK_ADDED,
|
|
20
17
|
[sdkTypes.HMSTrackUpdate.TRACK_REMOVED]: HMSNotificationTypes.TRACK_REMOVED,
|
|
21
18
|
[sdkTypes.HMSTrackUpdate.TRACK_MUTED]: HMSNotificationTypes.TRACK_MUTED,
|
|
22
19
|
[sdkTypes.HMSTrackUpdate.TRACK_UNMUTED]: HMSNotificationTypes.TRACK_UNMUTED,
|
|
23
20
|
[sdkTypes.HMSTrackUpdate.TRACK_DEGRADED]: HMSNotificationTypes.TRACK_DEGRADED,
|
|
24
21
|
[sdkTypes.HMSTrackUpdate.TRACK_RESTORED]: HMSNotificationTypes.TRACK_RESTORED,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
export const ACTION_TYPES: notifcationMap = {
|
|
28
|
-
[sdkTypes.HMSPeerUpdate.PEER_JOINED]: 'peerJoined',
|
|
29
|
-
[sdkTypes.HMSPeerUpdate.PEER_LEFT]: 'peerLeft',
|
|
30
|
-
[sdkTypes.HMSPeerUpdate.NAME_UPDATED]: 'peerNameUpdated',
|
|
31
|
-
[sdkTypes.HMSPeerUpdate.ROLE_UPDATED]: 'peerRoleUpdated',
|
|
32
|
-
[sdkTypes.HMSPeerUpdate.METADATA_UPDATED]: 'peerMetadataUpdated',
|
|
22
|
+
[sdkTypes.HMSTrackUpdate.TRACK_DESCRIPTION_CHANGED]: HMSNotificationTypes.TRACK_DESCRIPTION_CHANGED,
|
|
33
23
|
};
|
|
@@ -34,6 +34,7 @@ import {
|
|
|
34
34
|
HMSAudioPlugin,
|
|
35
35
|
HLSConfig,
|
|
36
36
|
HMSHLS,
|
|
37
|
+
HLSTimedMetadata,
|
|
37
38
|
HMSPeerStats,
|
|
38
39
|
HMSTrackStats,
|
|
39
40
|
HMSLocalTrackStats,
|
|
@@ -82,6 +83,7 @@ export type {
|
|
|
82
83
|
HMSVideoPlugin,
|
|
83
84
|
HMSAudioPlugin,
|
|
84
85
|
HLSConfig,
|
|
86
|
+
HLSTimedMetadata,
|
|
85
87
|
HLSMeetingURLVariant,
|
|
86
88
|
HMSHLS,
|
|
87
89
|
HMSPeerStats,
|
package/src/core/index.ts
CHANGED
|
@@ -25,12 +25,7 @@ export type {
|
|
|
25
25
|
HMSConfigInitialSettings,
|
|
26
26
|
HMSAudioTrackSettings,
|
|
27
27
|
HMSVideoTrackSettings,
|
|
28
|
-
HMSSimulcastLayer,
|
|
29
|
-
SimulcastLayerDefinition,
|
|
30
|
-
DeviceMap,
|
|
31
28
|
RTMPRecordingConfig,
|
|
32
|
-
HMSRecording,
|
|
33
|
-
HMSRTMP,
|
|
34
29
|
HMSPeerStats,
|
|
35
30
|
HMSTrackStats,
|
|
36
31
|
HMSLocalTrackStats,
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { DeviceMap } from '../hmsSDKStore/sdkTypes';
|
|
2
2
|
import { HMSException } from './error';
|
|
3
3
|
|
|
4
|
+
export type { DeviceMap };
|
|
5
|
+
|
|
4
6
|
/**
|
|
5
7
|
* Test fails when adding InputDeviceInfo[error TS2304: Cannot find name 'InputDeviceInfo'.]
|
|
6
8
|
* InputDeviceInfo extends MediaDeviceInfo. See https://w3c.github.io/mediacapture-main/#input-specific-device-info
|
|
@@ -11,7 +11,6 @@ export interface HMSNotification {
|
|
|
11
11
|
export enum HMSNotificationSeverity {
|
|
12
12
|
INFO = 'info',
|
|
13
13
|
ERROR = 'error',
|
|
14
|
-
CRITICAL = 'critical',
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
export enum HMSNotificationTypes {
|
|
@@ -28,7 +27,7 @@ export enum HMSNotificationTypes {
|
|
|
28
27
|
TRACK_UNMUTED = 'TRACK_UNMUTED',
|
|
29
28
|
TRACK_DEGRADED = 'TRACK_DEGRADED',
|
|
30
29
|
TRACK_RESTORED = 'TRACK_RESTORED',
|
|
31
|
-
|
|
30
|
+
TRACK_DESCRIPTION_CHANGED = 'TRACK_DESCRIPTION_CHANGED',
|
|
32
31
|
ROLE_UPDATED = 'ROLE_UPDATED',
|
|
33
32
|
CHANGE_TRACK_STATE_REQUEST = 'CHANGE_TRACK_STATE_REQUEST',
|
|
34
33
|
CHANGE_MULTI_TRACK_STATE_REQUEST = 'CHANGE_MULTI_TRACK_STATE_REQUEST',
|
package/src/core/schema/peer.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { SimulcastLayerDefinition } from '
|
|
2
|
-
// noinspection ES6PreferShortImport
|
|
3
|
-
import { HMSSimulcastLayer } from '../hmsSDKStore/sdkTypes';
|
|
1
|
+
import { HMSSimulcastLayer, SimulcastLayerDefinition } from '../hmsSDKStore/sdkTypes';
|
|
4
2
|
import { HMSRoleName } from './role';
|
|
5
3
|
|
|
4
|
+
export type { SimulcastLayerDefinition, HMSSimulcastLayer };
|
|
6
5
|
export type HMSPeerID = string;
|
|
7
6
|
export type HMSTrackID = string;
|
|
8
7
|
export type HMSTrackSource = 'regular' | 'screen' | 'plugin' | 'audioplaylist' | 'videoplaylist' | string;
|
package/src/core/schema/room.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { HMSRecording, HMSRTMP, HMSHLS } from '@100mslive/hms-video';
|
|
1
|
+
import { HMSRecording, HMSRTMP, HMSHLS, HLSVariant } from '@100mslive/hms-video';
|
|
2
2
|
import { HMSPeerID } from './peer';
|
|
3
3
|
|
|
4
|
+
export type { HMSRecording, HMSRTMP, HMSHLS, HLSVariant };
|
|
4
5
|
export type HMSRoomID = string;
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -58,11 +58,6 @@ describe('hms notifications tests', () => {
|
|
|
58
58
|
expect(cb.mock.results[0].value.severity).toBe(HMSNotificationSeverity.INFO);
|
|
59
59
|
});
|
|
60
60
|
|
|
61
|
-
test('when unhandled track event on Notification not to be called', () => {
|
|
62
|
-
notifications.sendTrackUpdate(sdkTypes.HMSTrackUpdate.TRACK_DESCRIPTION_CHANGED, track.id);
|
|
63
|
-
expect(cb.mock.calls.length).toBe(0);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
61
|
test('when track added on Notification to be called', () => {
|
|
67
62
|
notifications.sendTrackUpdate(sdkTypes.HMSTrackUpdate.TRACK_ADDED, track.id);
|
|
68
63
|
expect(cb.mock.calls.length).toBe(1);
|