@100mslive/react-native-hms 0.7.2 → 0.8.1
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/README.md +37 -39
- package/android/.gradle/checksums/checksums.lock +0 -0
- package/android/.gradle/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/checksums/sha1-checksums.bin +0 -0
- package/android/.project +34 -0
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/reactnativehmssdk/HmsDecoder.kt +129 -29
- package/android/src/main/java/com/reactnativehmssdk/HmsHelper.kt +124 -2
- package/android/src/main/java/com/reactnativehmssdk/HmsModule.kt +138 -495
- package/android/src/main/java/com/reactnativehmssdk/HmsSDK.kt +899 -0
- package/android/src/main/java/com/reactnativehmssdk/HmsView.kt +26 -8
- package/android/src/main/java/com/reactnativehmssdk/HmssdkViewManager.kt +8 -6
- package/ios/HmsDecoder.swift +142 -20
- package/ios/HmsHelper.swift +110 -0
- package/ios/HmsManager.m +13 -7
- package/ios/HmsManager.swift +115 -375
- package/ios/HmsSDK.swift +716 -0
- package/ios/HmsView.swift +16 -8
- package/lib/commonjs/classes/HMSAudioTrack.js.map +1 -1
- package/lib/commonjs/classes/HMSAudioTrackSettings.js +3 -0
- package/lib/commonjs/classes/HMSAudioTrackSettings.js.map +1 -1
- package/lib/commonjs/classes/HMSBrowserRecordingState.js +23 -0
- package/lib/commonjs/classes/HMSBrowserRecordingState.js.map +1 -0
- package/lib/commonjs/classes/HMSCameraFacing.js +14 -0
- package/lib/commonjs/classes/HMSCameraFacing.js.map +1 -0
- package/lib/commonjs/classes/HMSConfig.js +3 -7
- package/lib/commonjs/classes/HMSConfig.js.map +1 -1
- package/lib/commonjs/classes/HMSEncoder.js +60 -32
- package/lib/commonjs/classes/HMSEncoder.js.map +1 -1
- package/lib/commonjs/classes/HMSException.js +30 -0
- package/lib/commonjs/classes/HMSException.js.map +1 -0
- package/lib/commonjs/classes/HMSHelper.js +2 -2
- package/lib/commonjs/classes/HMSHelper.js.map +1 -1
- package/lib/commonjs/classes/HMSLocalAudioTrack.js +19 -1
- package/lib/commonjs/classes/HMSLocalAudioTrack.js.map +1 -1
- package/lib/commonjs/classes/HMSLocalPeer.js.map +1 -1
- package/lib/commonjs/classes/HMSLocalVideoTrack.js +10 -2
- package/lib/commonjs/classes/HMSLocalVideoTrack.js.map +1 -1
- package/lib/commonjs/classes/HMSLogger.js.map +1 -1
- package/lib/commonjs/classes/HMSPeer.js +3 -0
- package/lib/commonjs/classes/HMSPeer.js.map +1 -1
- package/lib/commonjs/classes/HMSPeerUpdate.js +1 -0
- package/lib/commonjs/classes/HMSPeerUpdate.js.map +1 -1
- package/lib/commonjs/classes/HMSPermissions.js +7 -7
- package/lib/commonjs/classes/HMSPermissions.js.map +1 -1
- package/lib/commonjs/classes/HMSRTMPConfig.js +26 -0
- package/lib/commonjs/classes/HMSRTMPConfig.js.map +1 -0
- package/lib/commonjs/classes/HMSRemoteAudioTrack.js +2 -0
- package/lib/commonjs/classes/HMSRemoteAudioTrack.js.map +1 -1
- package/lib/commonjs/classes/HMSRemotePeer.js.map +1 -1
- package/lib/commonjs/classes/HMSRemoteVideoTrack.js +2 -0
- package/lib/commonjs/classes/HMSRemoteVideoTrack.js.map +1 -1
- package/lib/commonjs/classes/HMSRoom.js +9 -0
- package/lib/commonjs/classes/HMSRoom.js.map +1 -1
- package/lib/commonjs/classes/HMSRtmpStreamingState.js +23 -0
- package/lib/commonjs/classes/HMSRtmpStreamingState.js.map +1 -0
- package/lib/commonjs/classes/HMSSDK.js +336 -109
- package/lib/commonjs/classes/HMSSDK.js.map +1 -1
- package/lib/commonjs/classes/HMSServerRecordingState.js +23 -0
- package/lib/commonjs/classes/HMSServerRecordingState.js.map +1 -0
- package/lib/commonjs/classes/HMSTrack.js +8 -18
- package/lib/commonjs/classes/HMSTrack.js.map +1 -1
- package/lib/commonjs/classes/HMSTrackType.js +14 -0
- package/lib/commonjs/classes/HMSTrackType.js.map +1 -0
- package/lib/commonjs/classes/HMSVideoResolution.js +23 -0
- package/lib/commonjs/classes/HMSVideoResolution.js.map +1 -0
- package/lib/commonjs/classes/HMSVideoSettings.js.map +1 -1
- package/lib/commonjs/classes/HMSVideoTrack.js +2 -0
- package/lib/commonjs/classes/HMSVideoTrack.js.map +1 -1
- package/lib/commonjs/classes/HMSVideoTrackSettings.js +0 -3
- package/lib/commonjs/classes/HMSVideoTrackSettings.js.map +1 -1
- package/lib/commonjs/classes/HmsView.js +10 -7
- package/lib/commonjs/classes/HmsView.js.map +1 -1
- package/lib/commonjs/index.js +98 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/classes/HMSAudioTrack.js.map +1 -1
- package/lib/module/classes/HMSAudioTrackSettings.js +3 -0
- package/lib/module/classes/HMSAudioTrackSettings.js.map +1 -1
- package/lib/module/classes/HMSBrowserRecordingState.js +14 -0
- package/lib/module/classes/HMSBrowserRecordingState.js.map +1 -0
- package/lib/module/classes/HMSCameraFacing.js +7 -0
- package/lib/module/classes/HMSCameraFacing.js.map +1 -0
- package/lib/module/classes/HMSConfig.js +3 -7
- package/lib/module/classes/HMSConfig.js.map +1 -1
- package/lib/module/classes/HMSEncoder.js +59 -32
- package/lib/module/classes/HMSEncoder.js.map +1 -1
- package/lib/module/classes/HMSException.js +21 -0
- package/lib/module/classes/HMSException.js.map +1 -0
- package/lib/module/classes/HMSHelper.js +2 -2
- package/lib/module/classes/HMSHelper.js.map +1 -1
- package/lib/module/classes/HMSLocalAudioTrack.js +20 -2
- package/lib/module/classes/HMSLocalAudioTrack.js.map +1 -1
- package/lib/module/classes/HMSLocalPeer.js.map +1 -1
- package/lib/module/classes/HMSLocalVideoTrack.js +10 -2
- package/lib/module/classes/HMSLocalVideoTrack.js.map +1 -1
- package/lib/module/classes/HMSLogger.js.map +1 -1
- package/lib/module/classes/HMSPeer.js +3 -0
- package/lib/module/classes/HMSPeer.js.map +1 -1
- package/lib/module/classes/HMSPeerUpdate.js +1 -0
- package/lib/module/classes/HMSPeerUpdate.js.map +1 -1
- package/lib/module/classes/HMSPermissions.js +7 -7
- package/lib/module/classes/HMSPermissions.js.map +1 -1
- package/lib/module/classes/HMSRTMPConfig.js +17 -0
- package/lib/module/classes/HMSRTMPConfig.js.map +1 -0
- package/lib/module/classes/HMSRemoteAudioTrack.js +2 -0
- package/lib/module/classes/HMSRemoteAudioTrack.js.map +1 -1
- package/lib/module/classes/HMSRemotePeer.js.map +1 -1
- package/lib/module/classes/HMSRemoteVideoTrack.js +2 -0
- package/lib/module/classes/HMSRemoteVideoTrack.js.map +1 -1
- package/lib/module/classes/HMSRoom.js +9 -0
- package/lib/module/classes/HMSRoom.js.map +1 -1
- package/lib/module/classes/HMSRtmpStreamingState.js +14 -0
- package/lib/module/classes/HMSRtmpStreamingState.js.map +1 -0
- package/lib/module/classes/HMSSDK.js +328 -109
- package/lib/module/classes/HMSSDK.js.map +1 -1
- package/lib/module/classes/HMSServerRecordingState.js +14 -0
- package/lib/module/classes/HMSServerRecordingState.js.map +1 -0
- package/lib/module/classes/HMSTrack.js +8 -16
- package/lib/module/classes/HMSTrack.js.map +1 -1
- package/lib/module/classes/HMSTrackType.js +7 -0
- package/lib/module/classes/HMSTrackType.js.map +1 -0
- package/lib/module/classes/HMSVideoResolution.js +14 -0
- package/lib/module/classes/HMSVideoResolution.js.map +1 -0
- package/lib/module/classes/HMSVideoSettings.js.map +1 -1
- package/lib/module/classes/HMSVideoTrack.js +2 -0
- package/lib/module/classes/HMSVideoTrack.js.map +1 -1
- package/lib/module/classes/HMSVideoTrackSettings.js +0 -3
- package/lib/module/classes/HMSVideoTrackSettings.js.map +1 -1
- package/lib/module/classes/HmsView.js +10 -7
- package/lib/module/classes/HmsView.js.map +1 -1
- package/lib/module/index.js +7 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/classes/HMSAudioTrack.d.ts +3 -0
- package/lib/typescript/classes/HMSAudioTrackSettings.d.ts +3 -0
- package/lib/typescript/classes/HMSBrowserRecordingState.d.ts +9 -0
- package/lib/typescript/classes/HMSCameraFacing.d.ts +4 -0
- package/lib/typescript/classes/HMSConfig.d.ts +2 -4
- package/lib/typescript/classes/HMSEncoder.d.ts +14 -12
- package/lib/typescript/classes/HMSException.d.ts +22 -0
- package/lib/typescript/classes/HMSLocalAudioTrack.d.ts +5 -0
- package/lib/typescript/classes/HMSLocalPeer.d.ts +3 -0
- package/lib/typescript/classes/HMSLocalVideoTrack.d.ts +4 -0
- package/lib/typescript/classes/HMSLogger.d.ts +4 -4
- package/lib/typescript/classes/HMSPeer.d.ts +2 -0
- package/lib/typescript/classes/HMSPeerUpdate.d.ts +1 -0
- package/lib/typescript/classes/HMSPermissions.d.ts +6 -6
- package/lib/typescript/classes/HMSRTMPConfig.d.ts +10 -0
- package/lib/typescript/classes/HMSRemoteAudioTrack.d.ts +4 -0
- package/lib/typescript/classes/HMSRemotePeer.d.ts +3 -0
- package/lib/typescript/classes/HMSRemoteVideoTrack.d.ts +4 -0
- package/lib/typescript/classes/HMSRoom.d.ts +9 -0
- package/lib/typescript/classes/HMSRtmpStreamingState.d.ts +9 -0
- package/lib/typescript/classes/HMSSDK.d.ts +36 -6
- package/lib/typescript/classes/HMSServerRecordingState.d.ts +9 -0
- package/lib/typescript/classes/HMSTrack.d.ts +6 -1
- package/lib/typescript/classes/HMSTrackType.d.ts +4 -0
- package/lib/typescript/classes/HMSVideoResolution.d.ts +8 -0
- package/lib/typescript/classes/HMSVideoSettings.d.ts +3 -3
- package/lib/typescript/classes/HMSVideoTrack.d.ts +5 -1
- package/lib/typescript/classes/HMSVideoTrackSettings.d.ts +13 -10
- package/lib/typescript/classes/HmsView.d.ts +2 -1
- package/lib/typescript/index.d.ts +7 -0
- package/package.json +1 -1
- package/src/classes/HMSAudioTrack.ts +3 -0
- package/src/classes/HMSAudioTrackSettings.ts +9 -1
- package/src/classes/HMSBrowserRecordingState.ts +11 -0
- package/src/classes/HMSCameraFacing.ts +4 -0
- package/src/classes/HMSConfig.ts +3 -7
- package/src/classes/HMSEncoder.ts +62 -28
- package/src/classes/HMSException.ts +33 -0
- package/src/classes/HMSHelper.ts +2 -2
- package/src/classes/HMSLocalAudioTrack.ts +19 -2
- package/src/classes/HMSLocalPeer.ts +3 -0
- package/src/classes/HMSLocalVideoTrack.ts +7 -2
- package/src/classes/HMSLogger.ts +5 -5
- package/src/classes/HMSPeer.ts +3 -0
- package/src/classes/HMSPeerUpdate.ts +1 -0
- package/src/classes/HMSPermissions.ts +9 -9
- package/src/classes/HMSRTMPConfig.ts +15 -0
- package/src/classes/HMSRemoteAudioTrack.ts +13 -2
- package/src/classes/HMSRemotePeer.ts +3 -0
- package/src/classes/HMSRemoteVideoTrack.ts +13 -2
- package/src/classes/HMSRoom.ts +12 -0
- package/src/classes/HMSRtmpStreamingState.ts +11 -0
- package/src/classes/{HMSSDK.ts → HMSSDK.tsx} +284 -42
- package/src/classes/HMSServerRecordingState.ts +11 -0
- package/src/classes/HMSTrack.ts +9 -15
- package/src/classes/HMSTrackType.ts +4 -0
- package/src/classes/HMSVideoResolution.ts +9 -0
- package/src/classes/HMSVideoSettings.ts +3 -3
- package/src/classes/HMSVideoTrack.ts +6 -1
- package/src/classes/HMSVideoTrackSettings.ts +13 -10
- package/src/classes/HmsView.tsx +4 -0
- package/src/index.ts +7 -0
- package/ios/Hmssdk.m +0 -8
- package/ios/Hmssdk.swift +0 -8
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { NativeEventEmitter, NativeModules, ViewStyle } from 'react-native';
|
|
2
3
|
import { HMSUpdateListenerActions } from './HMSUpdateListenerActions';
|
|
3
4
|
import type { HMSConfig } from './HMSConfig';
|
|
4
5
|
import type { HMSLocalPeer } from './HMSLocalPeer';
|
|
@@ -9,7 +10,22 @@ import { HMSEncoder } from './HMSEncoder';
|
|
|
9
10
|
import { HMSMessage } from './HMSMessage';
|
|
10
11
|
import { HMSHelper } from './HMSHelper';
|
|
11
12
|
import type { HMSTrack } from './HMSTrack';
|
|
13
|
+
import type { HMSTrackType } from './HMSTrackType';
|
|
12
14
|
import type { HMSLogger } from './HMSLogger';
|
|
15
|
+
import type { HMSPeer } from './HMSPeer';
|
|
16
|
+
import { HmsView as HMSViewComponent } from './HmsView';
|
|
17
|
+
import { HMSVideoViewMode } from './HMSVideoViewMode';
|
|
18
|
+
import type { HMSTrackSettings } from './HMSTrackSettings';
|
|
19
|
+
import type { HMSRTMPConfig } from './HMSRTMPConfig';
|
|
20
|
+
|
|
21
|
+
interface HmsComponentProps {
|
|
22
|
+
trackId: string;
|
|
23
|
+
sink: boolean;
|
|
24
|
+
style: ViewStyle;
|
|
25
|
+
mirror?: boolean;
|
|
26
|
+
scaleType: HMSVideoViewMode;
|
|
27
|
+
id?: string | null;
|
|
28
|
+
}
|
|
13
29
|
|
|
14
30
|
const {
|
|
15
31
|
/**
|
|
@@ -28,6 +44,8 @@ export class HMSSDK {
|
|
|
28
44
|
remotePeers?: HMSRemotePeer[];
|
|
29
45
|
knownRoles?: HMSRole[];
|
|
30
46
|
logger?: HMSLogger;
|
|
47
|
+
id: string;
|
|
48
|
+
private muteStatus: boolean | undefined;
|
|
31
49
|
|
|
32
50
|
onPreviewDelegate?: any;
|
|
33
51
|
onJoinDelegate?: any;
|
|
@@ -43,6 +61,10 @@ export class HMSSDK {
|
|
|
43
61
|
onChangeTrackStateRequestDelegate?: any;
|
|
44
62
|
onRemovedFromRoomDelegate?: any;
|
|
45
63
|
|
|
64
|
+
constructor(id: string) {
|
|
65
|
+
this.id = id;
|
|
66
|
+
}
|
|
67
|
+
|
|
46
68
|
/**
|
|
47
69
|
* - Returns an instance of [HMSSDK]{@link HMSSDK}
|
|
48
70
|
* - This function must be called to get an instance of HMSSDK class and only then user can interact with its methods
|
|
@@ -51,15 +73,18 @@ export class HMSSDK {
|
|
|
51
73
|
* @returns
|
|
52
74
|
* @memberof HMSSDK
|
|
53
75
|
*/
|
|
54
|
-
static build() {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
HmsSdk = new HMSSDK();
|
|
76
|
+
static async build(params?: { trackSettings?: HMSTrackSettings }) {
|
|
77
|
+
let id = await HmsManager.build(params?.trackSettings || {});
|
|
78
|
+
HmsSdk = new HMSSDK(id);
|
|
79
|
+
HmsSdk.attachPreviewListener();
|
|
80
|
+
HmsSdk.attachListeners();
|
|
60
81
|
return HmsSdk;
|
|
61
82
|
}
|
|
62
83
|
|
|
84
|
+
destroy = () => {
|
|
85
|
+
this.removeListeners();
|
|
86
|
+
};
|
|
87
|
+
|
|
63
88
|
attachPreviewListener = () => {
|
|
64
89
|
HmsEventEmitter.addListener(
|
|
65
90
|
HMSUpdateListenerActions.ON_PREVIEW,
|
|
@@ -129,6 +154,68 @@ export class HMSSDK {
|
|
|
129
154
|
);
|
|
130
155
|
};
|
|
131
156
|
|
|
157
|
+
removeListeners = () => {
|
|
158
|
+
HmsEventEmitter.removeListener(
|
|
159
|
+
HMSUpdateListenerActions.ON_JOIN,
|
|
160
|
+
this.onJoinListener
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
HmsEventEmitter.removeListener(
|
|
164
|
+
HMSUpdateListenerActions.ON_ROOM_UPDATE,
|
|
165
|
+
this.onRoomListener
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
HmsEventEmitter.removeListener(
|
|
169
|
+
HMSUpdateListenerActions.ON_PEER_UPDATE,
|
|
170
|
+
this.onPeerListener
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
HmsEventEmitter.removeListener(
|
|
174
|
+
HMSUpdateListenerActions.ON_TRACK_UPDATE,
|
|
175
|
+
this.onTrackListener
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
HmsEventEmitter.removeListener(
|
|
179
|
+
HMSUpdateListenerActions.ON_ERROR,
|
|
180
|
+
this.onErrorListener
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
HmsEventEmitter.removeListener(
|
|
184
|
+
HMSUpdateListenerActions.ON_MESSAGE,
|
|
185
|
+
this.onMessageListener
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
HmsEventEmitter.removeListener(
|
|
189
|
+
HMSUpdateListenerActions.ON_SPEAKER,
|
|
190
|
+
this.onSpeakerListener
|
|
191
|
+
);
|
|
192
|
+
|
|
193
|
+
HmsEventEmitter.removeListener(
|
|
194
|
+
HMSUpdateListenerActions.RECONNECTING,
|
|
195
|
+
this.reconnectingListener
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
HmsEventEmitter.removeListener(
|
|
199
|
+
HMSUpdateListenerActions.RECONNECTED,
|
|
200
|
+
this.reconnectedListener
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
HmsEventEmitter.removeListener(
|
|
204
|
+
HMSUpdateListenerActions.ON_ROLE_CHANGE_REQUEST,
|
|
205
|
+
this.onRoleChangeRequestListener
|
|
206
|
+
);
|
|
207
|
+
|
|
208
|
+
HmsEventEmitter.removeListener(
|
|
209
|
+
HMSUpdateListenerActions.ON_CHANGE_TRACK_STATE_REQUEST,
|
|
210
|
+
this.onChangeTrackStateRequestListener
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
HmsEventEmitter.removeListener(
|
|
214
|
+
HMSUpdateListenerActions.ON_REMOVED_FROM_ROOM,
|
|
215
|
+
this.onRemovedFromRoomListener
|
|
216
|
+
);
|
|
217
|
+
};
|
|
218
|
+
|
|
132
219
|
/**
|
|
133
220
|
* takes an instance of [HMSConfig]{@link HMSConfig} and joins the room
|
|
134
221
|
* after joining the room user will start receiving the events and updates of the room
|
|
@@ -138,14 +225,31 @@ export class HMSSDK {
|
|
|
138
225
|
*/
|
|
139
226
|
join = async (config: HMSConfig) => {
|
|
140
227
|
this.logger?.verbose('JOIN', { config });
|
|
141
|
-
this.
|
|
142
|
-
await HmsManager.join(config);
|
|
228
|
+
await HmsManager.join({ ...config, id: this.id });
|
|
143
229
|
};
|
|
144
230
|
|
|
145
231
|
preview = (config: HMSConfig) => {
|
|
146
232
|
this.logger?.verbose('PREVIEW', { config });
|
|
147
|
-
this.
|
|
148
|
-
|
|
233
|
+
HmsManager.preview({ ...config, id: this.id });
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
HmsView = ({
|
|
237
|
+
sink,
|
|
238
|
+
trackId,
|
|
239
|
+
style,
|
|
240
|
+
mirror,
|
|
241
|
+
scaleType = HMSVideoViewMode.ASPECT_FIT,
|
|
242
|
+
}: HmsComponentProps) => {
|
|
243
|
+
return (
|
|
244
|
+
<HMSViewComponent
|
|
245
|
+
sink={sink}
|
|
246
|
+
trackId={trackId}
|
|
247
|
+
style={style}
|
|
248
|
+
mirror={mirror}
|
|
249
|
+
scaleType={scaleType}
|
|
250
|
+
id={this.id}
|
|
251
|
+
/>
|
|
252
|
+
);
|
|
149
253
|
};
|
|
150
254
|
|
|
151
255
|
/**
|
|
@@ -153,37 +257,73 @@ export class HMSSDK {
|
|
|
153
257
|
*
|
|
154
258
|
* @memberof HMSSDK
|
|
155
259
|
*/
|
|
156
|
-
leave = () => {
|
|
260
|
+
leave = async () => {
|
|
157
261
|
this.logger?.verbose('LEAVE', {});
|
|
158
|
-
|
|
262
|
+
const data = {
|
|
263
|
+
id: this.id,
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
await HmsManager.leave(data);
|
|
267
|
+
this.muteStatus = undefined;
|
|
268
|
+
this.localPeer = undefined;
|
|
269
|
+
this.remotePeers = undefined;
|
|
270
|
+
this.room = undefined;
|
|
271
|
+
this.knownRoles = undefined;
|
|
159
272
|
};
|
|
160
273
|
|
|
161
|
-
sendBroadcastMessage = (message: string) => {
|
|
274
|
+
sendBroadcastMessage = (message: string, type?: string) => {
|
|
162
275
|
this.logger?.verbose('SEND_BROADCAST_MESSAGE', { message });
|
|
163
|
-
HmsManager.sendBroadcastMessage({
|
|
276
|
+
HmsManager.sendBroadcastMessage({
|
|
277
|
+
message,
|
|
278
|
+
type: type || null,
|
|
279
|
+
id: this.id,
|
|
280
|
+
});
|
|
164
281
|
};
|
|
165
282
|
|
|
166
|
-
sendGroupMessage = (message: string, roles: HMSRole[]) => {
|
|
283
|
+
sendGroupMessage = (message: string, roles: HMSRole[], type?: string) => {
|
|
167
284
|
this.logger?.verbose('SEND_GROUP_MESSAGE', { message, roles });
|
|
168
285
|
HmsManager.sendGroupMessage({
|
|
169
286
|
message,
|
|
170
287
|
roles: HMSHelper.getRoleNames(roles),
|
|
288
|
+
id: this.id,
|
|
289
|
+
type: type || null,
|
|
171
290
|
});
|
|
172
291
|
};
|
|
173
292
|
|
|
174
|
-
sendDirectMessage = (message: string, peerId: string) => {
|
|
293
|
+
sendDirectMessage = (message: string, peerId: string, type?: string) => {
|
|
175
294
|
this.logger?.verbose('SEND_DIRECT_MESSAGE', { message, peerId });
|
|
176
295
|
HmsManager.sendDirectMessage({
|
|
177
296
|
message,
|
|
178
297
|
peerId,
|
|
298
|
+
id: this.id,
|
|
299
|
+
type: type || null,
|
|
179
300
|
});
|
|
180
301
|
};
|
|
181
302
|
|
|
182
|
-
|
|
303
|
+
changeMetadata = (metadata: string) => {
|
|
304
|
+
this.logger?.verbose('CHANGE_METADATA', { metadata });
|
|
305
|
+
HmsManager.changeMetadata({ metadata, id: this.id });
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
startRTMPOrRecording = async (data: HMSRTMPConfig) => {
|
|
309
|
+
this.logger?.verbose('START_RTMP_OR_RECORDING', { data });
|
|
310
|
+
|
|
311
|
+
const op = await HmsManager.startRTMPOrRecording({ ...data, id: this.id });
|
|
312
|
+
return op;
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
stopRtmpAndRecording = async () => {
|
|
316
|
+
this.logger?.verbose('STOP_RTMP_OR_RECORDING', {});
|
|
317
|
+
const op = await HmsManager.stopRtmpAndRecording({ id: this.id });
|
|
318
|
+
return op;
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
changeRole = (peer: HMSPeer, role: HMSRole, force: boolean = false) => {
|
|
183
322
|
const data = {
|
|
184
|
-
peerId:
|
|
185
|
-
role: role,
|
|
323
|
+
peerId: peer?.peerID,
|
|
324
|
+
role: role?.name,
|
|
186
325
|
force: force,
|
|
326
|
+
id: this.id,
|
|
187
327
|
};
|
|
188
328
|
this.logger?.verbose('CHANGE_ROLE', data);
|
|
189
329
|
HmsManager.changeRole(data);
|
|
@@ -194,16 +334,41 @@ export class HMSSDK {
|
|
|
194
334
|
const data = {
|
|
195
335
|
trackId: track.trackId,
|
|
196
336
|
mute,
|
|
337
|
+
id: this.id,
|
|
197
338
|
};
|
|
198
339
|
|
|
199
340
|
HmsManager.changeTrackState(data);
|
|
200
341
|
};
|
|
201
342
|
|
|
343
|
+
changeTrackStateRoles = (
|
|
344
|
+
type: HMSTrackType,
|
|
345
|
+
mute: boolean,
|
|
346
|
+
source: string,
|
|
347
|
+
roles: Array<HMSRole>
|
|
348
|
+
) => {
|
|
349
|
+
this.logger?.verbose('CHANGE_TRACK_STATE_ROLES', {
|
|
350
|
+
source,
|
|
351
|
+
mute,
|
|
352
|
+
type,
|
|
353
|
+
roles,
|
|
354
|
+
});
|
|
355
|
+
const data = {
|
|
356
|
+
source,
|
|
357
|
+
mute,
|
|
358
|
+
type,
|
|
359
|
+
roles: HMSHelper.getRoleNames(roles),
|
|
360
|
+
id: this.id,
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
HmsManager.changeTrackStateRoles(data);
|
|
364
|
+
};
|
|
365
|
+
|
|
202
366
|
removePeer = (peerId: string, reason: string) => {
|
|
203
367
|
this.logger?.verbose('REMOVE_PEER', { peerId, reason });
|
|
204
368
|
const data = {
|
|
205
369
|
peerId,
|
|
206
370
|
reason,
|
|
371
|
+
id: this.id,
|
|
207
372
|
};
|
|
208
373
|
|
|
209
374
|
HmsManager.removePeer(data);
|
|
@@ -214,6 +379,7 @@ export class HMSSDK {
|
|
|
214
379
|
const data = {
|
|
215
380
|
lock,
|
|
216
381
|
reason,
|
|
382
|
+
id: this.id,
|
|
217
383
|
};
|
|
218
384
|
|
|
219
385
|
HmsManager.endRoom(data);
|
|
@@ -221,12 +387,31 @@ export class HMSSDK {
|
|
|
221
387
|
|
|
222
388
|
acceptRoleChange = () => {
|
|
223
389
|
this.logger?.verbose('ACCEPT_ROLE_CHANGE', {});
|
|
224
|
-
HmsManager.acceptRoleChange();
|
|
390
|
+
HmsManager.acceptRoleChange({ id: this.id });
|
|
225
391
|
};
|
|
226
392
|
|
|
227
393
|
muteAllPeersAudio = (mute: boolean) => {
|
|
228
394
|
this.logger?.verbose('ON_MUTE_ALL_PEERS', { mute });
|
|
229
|
-
|
|
395
|
+
this.muteStatus = mute;
|
|
396
|
+
HmsManager.muteAllPeersAudio({ mute, id: this.id });
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
getRoom = async () => {
|
|
400
|
+
this.logger?.verbose('GET_ROOM_API_CALL', { roomID: this.id });
|
|
401
|
+
const hmsRoom = await HmsManager.getRoom({ id: this.id });
|
|
402
|
+
|
|
403
|
+
const encodedHmsRoom = HMSEncoder.encodeHmsRoom(hmsRoom, this.id);
|
|
404
|
+
return encodedHmsRoom;
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
setVolume = (track: HMSTrack, volume: number) => {
|
|
408
|
+
this.logger?.verbose('SET_VOLUME_CALL', { track, volume });
|
|
409
|
+
HmsManager.setVolume({
|
|
410
|
+
id: this.id,
|
|
411
|
+
trackId: track.trackId,
|
|
412
|
+
volume,
|
|
413
|
+
});
|
|
414
|
+
return;
|
|
230
415
|
};
|
|
231
416
|
|
|
232
417
|
/**
|
|
@@ -366,10 +551,14 @@ export class HMSSDK {
|
|
|
366
551
|
};
|
|
367
552
|
|
|
368
553
|
onPreviewListener = (data: any) => {
|
|
554
|
+
if (data.id !== this.id) {
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
369
557
|
this.logger?.verbose('ON_PREVIEW', data);
|
|
370
|
-
const room: HMSRoom = HMSEncoder.encodeHmsRoom(data.room);
|
|
558
|
+
const room: HMSRoom = HMSEncoder.encodeHmsRoom(data.room, this.id);
|
|
371
559
|
const localPeer: HMSLocalPeer = HMSEncoder.encodeHmsLocalPeer(
|
|
372
|
-
data.localPeer
|
|
560
|
+
data.localPeer,
|
|
561
|
+
this.id
|
|
373
562
|
);
|
|
374
563
|
|
|
375
564
|
const previewTracks = HMSEncoder.encodeHmsPreviewTracks(data.previewTracks);
|
|
@@ -388,14 +577,19 @@ export class HMSSDK {
|
|
|
388
577
|
};
|
|
389
578
|
|
|
390
579
|
onJoinListener = (data: any) => {
|
|
580
|
+
if (data.id !== this.id) {
|
|
581
|
+
return;
|
|
582
|
+
}
|
|
391
583
|
this.logger?.verbose('ON_JOIN', data);
|
|
392
584
|
// Preprocessing
|
|
393
|
-
const room: HMSRoom = HMSEncoder.encodeHmsRoom(data.room);
|
|
585
|
+
const room: HMSRoom = HMSEncoder.encodeHmsRoom(data.room, this.id);
|
|
394
586
|
const localPeer: HMSLocalPeer = HMSEncoder.encodeHmsLocalPeer(
|
|
395
|
-
data.localPeer
|
|
587
|
+
data.localPeer,
|
|
588
|
+
this.id
|
|
396
589
|
);
|
|
397
590
|
const remotePeers: HMSRemotePeer[] = HMSEncoder.encodeHmsRemotePeers(
|
|
398
|
-
data.remotePeers
|
|
591
|
+
data.remotePeers,
|
|
592
|
+
this.id
|
|
399
593
|
);
|
|
400
594
|
const roles: HMSRole[] = HMSEncoder.encodeHmsRoles(data.roles);
|
|
401
595
|
this.room = room;
|
|
@@ -414,13 +608,18 @@ export class HMSSDK {
|
|
|
414
608
|
};
|
|
415
609
|
|
|
416
610
|
onRoomListener = (data: any) => {
|
|
611
|
+
if (data.id !== this.id) {
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
417
614
|
this.logger?.verbose('ON_ROOM', data);
|
|
418
|
-
const room: HMSRoom = HMSEncoder.encodeHmsRoom(data.room);
|
|
615
|
+
const room: HMSRoom = HMSEncoder.encodeHmsRoom(data.room, this.id);
|
|
419
616
|
const localPeer: HMSLocalPeer = HMSEncoder.encodeHmsLocalPeer(
|
|
420
|
-
data.localPeer
|
|
617
|
+
data.localPeer,
|
|
618
|
+
this.id
|
|
421
619
|
);
|
|
422
620
|
const remotePeers: HMSRemotePeer[] = HMSEncoder.encodeHmsRemotePeers(
|
|
423
|
-
data.remotePeers
|
|
621
|
+
data.remotePeers,
|
|
622
|
+
this.id
|
|
424
623
|
);
|
|
425
624
|
this.room = room;
|
|
426
625
|
this.localPeer = localPeer;
|
|
@@ -437,41 +636,59 @@ export class HMSSDK {
|
|
|
437
636
|
};
|
|
438
637
|
|
|
439
638
|
onPeerListener = (data: any) => {
|
|
639
|
+
if (data.id !== this.id) {
|
|
640
|
+
return;
|
|
641
|
+
}
|
|
440
642
|
this.logger?.verbose('ON_PEER', data);
|
|
643
|
+
const room: HMSRoom = HMSEncoder.encodeHmsRoom(data.room, this.id);
|
|
441
644
|
const localPeer: HMSLocalPeer = HMSEncoder.encodeHmsLocalPeer(
|
|
442
|
-
data.localPeer
|
|
645
|
+
data.localPeer,
|
|
646
|
+
this.id
|
|
443
647
|
);
|
|
444
648
|
const remotePeers: HMSRemotePeer[] = HMSEncoder.encodeHmsRemotePeers(
|
|
445
|
-
data.remotePeers
|
|
649
|
+
data.remotePeers,
|
|
650
|
+
this.id
|
|
446
651
|
);
|
|
447
652
|
// this.room = room;
|
|
448
653
|
this.localPeer = localPeer;
|
|
449
654
|
this.remotePeers = remotePeers;
|
|
655
|
+
this.room = room;
|
|
450
656
|
if (this.onPeerDelegate) {
|
|
451
657
|
this.logger?.verbose('ON_PEER_LISTENER_CALL', data);
|
|
452
|
-
this.onPeerDelegate({ ...data, localPeer, remotePeers });
|
|
658
|
+
this.onPeerDelegate({ ...data, localPeer, remotePeers, room });
|
|
453
659
|
}
|
|
454
660
|
};
|
|
455
661
|
|
|
456
662
|
onTrackListener = (data: any) => {
|
|
663
|
+
if (data.id !== this.id) {
|
|
664
|
+
return;
|
|
665
|
+
}
|
|
457
666
|
this.logger?.verbose('ON_TRACK', data);
|
|
458
|
-
|
|
667
|
+
const room: HMSRoom = HMSEncoder.encodeHmsRoom(data.room, this.id);
|
|
459
668
|
const localPeer: HMSLocalPeer = HMSEncoder.encodeHmsLocalPeer(
|
|
460
|
-
data.localPeer
|
|
669
|
+
data.localPeer,
|
|
670
|
+
this.id
|
|
461
671
|
);
|
|
462
672
|
const remotePeers: HMSRemotePeer[] = HMSEncoder.encodeHmsRemotePeers(
|
|
463
|
-
data.remotePeers
|
|
673
|
+
data.remotePeers,
|
|
674
|
+
this.id
|
|
464
675
|
);
|
|
465
|
-
|
|
676
|
+
if (this.muteStatus && data?.type === 'TRACK_ADDED') {
|
|
677
|
+
this.muteAllPeersAudio(this.muteStatus);
|
|
678
|
+
}
|
|
679
|
+
this.room = room;
|
|
466
680
|
this.localPeer = localPeer;
|
|
467
681
|
this.remotePeers = remotePeers;
|
|
468
682
|
if (this.onTrackDelegate) {
|
|
469
683
|
this.logger?.verbose('ON_TRACK_LISTENER_CALL', data);
|
|
470
|
-
this.onTrackDelegate({ ...data, localPeer, remotePeers });
|
|
684
|
+
this.onTrackDelegate({ ...data, localPeer, remotePeers, room });
|
|
471
685
|
}
|
|
472
686
|
};
|
|
473
687
|
|
|
474
688
|
onMessageListener = (data: any) => {
|
|
689
|
+
if (data.id !== this.id) {
|
|
690
|
+
return;
|
|
691
|
+
}
|
|
475
692
|
this.logger?.verbose('ON_MESSAGE', data);
|
|
476
693
|
const message = new HMSMessage(data);
|
|
477
694
|
if (this.onMessageDelegate) {
|
|
@@ -481,6 +698,9 @@ export class HMSSDK {
|
|
|
481
698
|
};
|
|
482
699
|
|
|
483
700
|
onSpeakerListener = (data: any) => {
|
|
701
|
+
if (data.id !== this.id) {
|
|
702
|
+
return;
|
|
703
|
+
}
|
|
484
704
|
this.logger?.verbose('ON_SPEAKER', data);
|
|
485
705
|
if (this.onSpeakerDelegate) {
|
|
486
706
|
this.onSpeakerDelegate(data);
|
|
@@ -488,18 +708,28 @@ export class HMSSDK {
|
|
|
488
708
|
};
|
|
489
709
|
|
|
490
710
|
onErrorListener = (data: any) => {
|
|
711
|
+
if (data.id !== this.id) {
|
|
712
|
+
return;
|
|
713
|
+
}
|
|
491
714
|
this.logger?.warn('ON_ERROR', data);
|
|
715
|
+
this.logger?.verbose('ON_ERROR', data);
|
|
492
716
|
if (this.onErrorDelegate) {
|
|
717
|
+
this.logger?.verbose('ON_ERROR_LISTENER_CALL', data);
|
|
493
718
|
this.logger?.warn('ON_ERROR_LISTENER_CALL', data);
|
|
494
719
|
this.onErrorDelegate(data);
|
|
495
720
|
}
|
|
496
721
|
};
|
|
497
722
|
|
|
498
723
|
onRoleChangeRequestListener = (data: any) => {
|
|
724
|
+
if (data.id !== this.id) {
|
|
725
|
+
return;
|
|
726
|
+
}
|
|
499
727
|
this.logger?.verbose('ON_ROLE_CHANGE_REQUEST', data);
|
|
500
728
|
if (this.onRoleChangeRequestDelegate) {
|
|
501
|
-
const encodedRoleChangeRequest =
|
|
502
|
-
|
|
729
|
+
const encodedRoleChangeRequest = HMSEncoder.encodeHmsRoleChangeRequest(
|
|
730
|
+
data,
|
|
731
|
+
this.id
|
|
732
|
+
);
|
|
503
733
|
this.logger?.verbose(
|
|
504
734
|
'ON_ROLE_CHANGE_LISTENER_CALL',
|
|
505
735
|
encodedRoleChangeRequest
|
|
@@ -512,7 +742,7 @@ export class HMSSDK {
|
|
|
512
742
|
this.logger?.verbose('ON_CHANGE_TRACK_STATE_REQUEST', data);
|
|
513
743
|
if (this.onChangeTrackStateRequestDelegate) {
|
|
514
744
|
const encodedRoleChangeRequest =
|
|
515
|
-
HMSEncoder.encodeHmsChangeTrackStateRequest(data);
|
|
745
|
+
HMSEncoder.encodeHmsChangeTrackStateRequest(data, this.id);
|
|
516
746
|
this.logger?.verbose(
|
|
517
747
|
'ON_CHANGE_TRACK_STATE_REQUEST_LISTENER_CALL',
|
|
518
748
|
encodedRoleChangeRequest
|
|
@@ -522,9 +752,15 @@ export class HMSSDK {
|
|
|
522
752
|
};
|
|
523
753
|
|
|
524
754
|
onRemovedFromRoomListener = (data: any) => {
|
|
755
|
+
if (data.id !== this.id) {
|
|
756
|
+
return;
|
|
757
|
+
}
|
|
525
758
|
this.logger?.verbose('ON_REMOVED_FROM_ROOM', data);
|
|
526
759
|
if (this.onRemovedFromRoomDelegate) {
|
|
527
|
-
|
|
760
|
+
let requestedBy = null;
|
|
761
|
+
if (data.requestedBy) {
|
|
762
|
+
requestedBy = HMSEncoder.encodeHmsPeer(data.requestedBy, this.id);
|
|
763
|
+
}
|
|
528
764
|
const reason = data.reason;
|
|
529
765
|
const roomEnded = data.roomEnded;
|
|
530
766
|
|
|
@@ -538,6 +774,9 @@ export class HMSSDK {
|
|
|
538
774
|
};
|
|
539
775
|
|
|
540
776
|
reconnectingListener = (data: any) => {
|
|
777
|
+
if (data.id !== this.id) {
|
|
778
|
+
return;
|
|
779
|
+
}
|
|
541
780
|
this.logger?.verbose('ON_RECONNECTING', data);
|
|
542
781
|
if (this.onReconnectingDelegate) {
|
|
543
782
|
this.onReconnectingDelegate(data);
|
|
@@ -545,6 +784,9 @@ export class HMSSDK {
|
|
|
545
784
|
};
|
|
546
785
|
|
|
547
786
|
reconnectedListener = (data: any) => {
|
|
787
|
+
if (data.id !== this.id) {
|
|
788
|
+
return;
|
|
789
|
+
}
|
|
548
790
|
this.logger?.verbose('ON_RECONNECTED', data);
|
|
549
791
|
if (this.onReconnectedDelegate) {
|
|
550
792
|
this.onReconnectedDelegate(data);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { HMSException } from './HMSException';
|
|
2
|
+
|
|
3
|
+
export class HMSServerRecordingState {
|
|
4
|
+
running: string;
|
|
5
|
+
error: HMSException;
|
|
6
|
+
|
|
7
|
+
constructor(params: { running: string; error: HMSException }) {
|
|
8
|
+
this.running = params.running;
|
|
9
|
+
this.error = params.error;
|
|
10
|
+
}
|
|
11
|
+
}
|
package/src/classes/HMSTrack.ts
CHANGED
|
@@ -1,25 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
const {
|
|
4
|
-
/**
|
|
5
|
-
* @ignore
|
|
6
|
-
*/
|
|
7
|
-
HmsManager,
|
|
8
|
-
} = NativeModules;
|
|
1
|
+
import type { HMSTrackType } from './HMSTrackType';
|
|
9
2
|
|
|
10
3
|
export class HMSTrack {
|
|
11
4
|
trackId: string;
|
|
12
5
|
source?: number | string;
|
|
13
6
|
trackDescription?: string;
|
|
14
7
|
mute?: boolean;
|
|
8
|
+
id: string;
|
|
9
|
+
type?: HMSTrackType;
|
|
15
10
|
|
|
16
|
-
isMute =
|
|
17
|
-
|
|
18
|
-
let val = await HmsManager.isMute({ trackId: this.trackId });
|
|
19
|
-
return val;
|
|
20
|
-
} catch (e) {
|
|
21
|
-
return true;
|
|
22
|
-
}
|
|
11
|
+
isMute = () => {
|
|
12
|
+
return this.mute;
|
|
23
13
|
};
|
|
24
14
|
|
|
25
15
|
constructor(params: {
|
|
@@ -27,10 +17,14 @@ export class HMSTrack {
|
|
|
27
17
|
source?: number | string;
|
|
28
18
|
trackDescription?: string;
|
|
29
19
|
isMute?: boolean;
|
|
20
|
+
id: string;
|
|
21
|
+
type?: HMSTrackType;
|
|
30
22
|
}) {
|
|
31
23
|
this.trackId = params.trackId;
|
|
32
24
|
this.source = params.source;
|
|
33
25
|
this.trackDescription = params.trackDescription;
|
|
34
26
|
this.mute = params.isMute;
|
|
27
|
+
this.id = params.id;
|
|
28
|
+
this.type = params.type;
|
|
35
29
|
}
|
|
36
30
|
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { HMSVideoCodec } from '..';
|
|
2
2
|
|
|
3
3
|
export class HMSVideoSettings {
|
|
4
4
|
bitrate?: number;
|
|
5
5
|
frameRate: number;
|
|
6
6
|
width: number;
|
|
7
7
|
height: number;
|
|
8
|
-
codec:
|
|
8
|
+
codec: HMSVideoCodec;
|
|
9
9
|
|
|
10
10
|
constructor(params: {
|
|
11
11
|
bitrate?: number;
|
|
12
12
|
frameRate: number;
|
|
13
13
|
width: number;
|
|
14
14
|
height: number;
|
|
15
|
-
codec:
|
|
15
|
+
codec: HMSVideoCodec;
|
|
16
16
|
}) {
|
|
17
17
|
this.bitrate = params.bitrate;
|
|
18
18
|
this.frameRate = params.frameRate;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { HMSTrack } from './HMSTrack';
|
|
2
|
+
import type { HMSTrackType } from './HMSTrackType';
|
|
2
3
|
|
|
3
4
|
export class HMSVideoTrack extends HMSTrack {
|
|
4
|
-
isDegraded?:
|
|
5
|
+
isDegraded?: boolean;
|
|
5
6
|
addSink?: Function;
|
|
6
7
|
removeSink?: Function;
|
|
7
8
|
|
|
@@ -10,7 +11,11 @@ export class HMSVideoTrack extends HMSTrack {
|
|
|
10
11
|
source?: number | string;
|
|
11
12
|
trackDescription?: string;
|
|
12
13
|
isMute?: boolean;
|
|
14
|
+
id: string;
|
|
15
|
+
isDegraded?: boolean;
|
|
16
|
+
type?: HMSTrackType;
|
|
13
17
|
}) {
|
|
14
18
|
super(params);
|
|
19
|
+
this.isDegraded = params.isDegraded;
|
|
15
20
|
}
|
|
16
21
|
}
|