@100mslive/react-native-hms 0.8.4 → 0.9.2
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 +247 -26
- package/android/.gradle/6.9/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/6.9/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- 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/.idea/gradle.xml +13 -0
- package/android/.idea/misc.xml +9 -0
- package/android/.idea/modules/android.iml +18 -0
- package/android/.idea/modules.xml +8 -0
- package/android/.idea/sonarlint/issuestore/f/0/f07866736216be0ee2aba49e392191aeae700a35 +0 -0
- package/android/.idea/sonarlint/issuestore/index.pb +3 -0
- package/android/.idea/vcs.xml +6 -0
- package/android/build.gradle +4 -2
- package/android/local.properties +8 -0
- package/android/src/main/java/com/reactnativehmssdk/HmsDecoder.kt +67 -5
- package/android/src/main/java/com/reactnativehmssdk/HmsHelper.kt +67 -64
- package/android/src/main/java/com/reactnativehmssdk/HmsModule.kt +97 -6
- package/android/src/main/java/com/reactnativehmssdk/HmsSDK.kt +302 -118
- package/android/src/main/java/com/reactnativehmssdk/HmsScreenshareActivity.kt +77 -0
- package/android/src/main/java/com/reactnativehmssdk/HmsView.kt +28 -3
- package/android/src/main/java/com/reactnativehmssdk/HmssdkViewManager.kt +10 -1
- package/android/src/main/res/layout/hms_view.xml +19 -0
- package/ios/HmsDecoder.swift +250 -123
- package/ios/HmsHelper.swift +70 -38
- package/ios/HmsManager.m +11 -3
- package/ios/HmsManager.swift +123 -66
- package/ios/HmsSDK.swift +384 -195
- package/ios/HmsView.swift +50 -68
- package/ios/VideoCollectionViewCell.swift +4 -4
- package/lib/commonjs/classes/HMSBrowserRecordingState.js +6 -0
- package/lib/commonjs/classes/HMSBrowserRecordingState.js.map +1 -1
- package/lib/commonjs/classes/HMSEncoder.js +180 -3
- package/lib/commonjs/classes/HMSEncoder.js.map +1 -1
- package/lib/commonjs/classes/HMSHLSConfig.js +23 -0
- package/lib/commonjs/classes/HMSHLSConfig.js.map +1 -0
- package/lib/commonjs/classes/HMSHLSMeetingURLVariant.js +23 -0
- package/lib/commonjs/classes/HMSHLSMeetingURLVariant.js.map +1 -0
- package/lib/commonjs/classes/HMSHLSRecordingConfig.js +23 -0
- package/lib/commonjs/classes/HMSHLSRecordingConfig.js.map +1 -0
- package/lib/commonjs/classes/HMSHLSRecordingState.js +29 -0
- package/lib/commonjs/classes/HMSHLSRecordingState.js.map +1 -0
- package/lib/commonjs/classes/HMSHLSStreamingState.js +23 -0
- package/lib/commonjs/classes/HMSHLSStreamingState.js.map +1 -0
- package/lib/commonjs/classes/HMSHLSVariant.js +29 -0
- package/lib/commonjs/classes/HMSHLSVariant.js.map +1 -0
- package/lib/commonjs/classes/HMSLocalAudioStats.js +26 -0
- package/lib/commonjs/classes/HMSLocalAudioStats.js.map +1 -0
- package/lib/commonjs/classes/HMSLocalVideoStats.js +32 -0
- package/lib/commonjs/classes/HMSLocalVideoStats.js.map +1 -0
- package/lib/commonjs/classes/HMSLogger.js +48 -21
- package/lib/commonjs/classes/HMSLogger.js.map +1 -1
- package/lib/commonjs/classes/HMSMessage.js +4 -1
- package/lib/commonjs/classes/HMSMessage.js.map +1 -1
- package/lib/commonjs/classes/HMSMessageRecipient.js +26 -0
- package/lib/commonjs/classes/HMSMessageRecipient.js.map +1 -0
- package/lib/commonjs/classes/HMSMessageRecipientType.js +15 -0
- package/lib/commonjs/classes/HMSMessageRecipientType.js.map +1 -0
- package/lib/commonjs/classes/HMSPeerUpdate.js +1 -7
- package/lib/commonjs/classes/HMSPeerUpdate.js.map +1 -1
- package/lib/commonjs/classes/HMSPermissions.js +2 -2
- package/lib/commonjs/classes/HMSPermissions.js.map +1 -1
- package/lib/commonjs/classes/HMSRTCStats.js +38 -0
- package/lib/commonjs/classes/HMSRTCStats.js.map +1 -0
- package/lib/commonjs/classes/HMSRTCStatsReport.js +26 -0
- package/lib/commonjs/classes/HMSRTCStatsReport.js.map +1 -0
- package/lib/commonjs/classes/HMSRemoteAudioStats.js +32 -0
- package/lib/commonjs/classes/HMSRemoteAudioStats.js.map +1 -0
- package/lib/commonjs/classes/HMSRemoteVideoStats.js +38 -0
- package/lib/commonjs/classes/HMSRemoteVideoStats.js.map +1 -0
- package/lib/commonjs/classes/HMSRoom.js +9 -0
- package/lib/commonjs/classes/HMSRoom.js.map +1 -1
- package/lib/commonjs/classes/HMSRoomUpdate.js +7 -0
- package/lib/commonjs/classes/HMSRoomUpdate.js.map +1 -1
- package/lib/commonjs/classes/HMSRtmpStreamingState.js +6 -0
- package/lib/commonjs/classes/HMSRtmpStreamingState.js.map +1 -1
- package/lib/commonjs/classes/HMSSDK.js +488 -114
- package/lib/commonjs/classes/HMSSDK.js.map +1 -1
- package/lib/commonjs/classes/HMSServerRecordingState.js +3 -0
- package/lib/commonjs/classes/HMSServerRecordingState.js.map +1 -1
- package/lib/commonjs/classes/HMSUpdateListenerActions.js +5 -0
- package/lib/commonjs/classes/HMSUpdateListenerActions.js.map +1 -1
- package/lib/commonjs/classes/HmsView.js +26 -4
- package/lib/commonjs/classes/HmsView.js.map +1 -1
- package/lib/commonjs/index.js +196 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/classes/HMSBrowserRecordingState.js +6 -0
- package/lib/module/classes/HMSBrowserRecordingState.js.map +1 -1
- package/lib/module/classes/HMSEncoder.js +172 -3
- package/lib/module/classes/HMSEncoder.js.map +1 -1
- package/lib/module/classes/HMSHLSConfig.js +14 -0
- package/lib/module/classes/HMSHLSConfig.js.map +1 -0
- package/lib/module/classes/HMSHLSMeetingURLVariant.js +14 -0
- package/lib/module/classes/HMSHLSMeetingURLVariant.js.map +1 -0
- package/lib/module/classes/HMSHLSRecordingConfig.js +14 -0
- package/lib/module/classes/HMSHLSRecordingConfig.js.map +1 -0
- package/lib/module/classes/HMSHLSRecordingState.js +20 -0
- package/lib/module/classes/HMSHLSRecordingState.js.map +1 -0
- package/lib/module/classes/HMSHLSStreamingState.js +14 -0
- package/lib/module/classes/HMSHLSStreamingState.js.map +1 -0
- package/lib/module/classes/HMSHLSVariant.js +20 -0
- package/lib/module/classes/HMSHLSVariant.js.map +1 -0
- package/lib/module/classes/HMSLocalAudioStats.js +17 -0
- package/lib/module/classes/HMSLocalAudioStats.js.map +1 -0
- package/lib/module/classes/HMSLocalVideoStats.js +23 -0
- package/lib/module/classes/HMSLocalVideoStats.js.map +1 -0
- package/lib/module/classes/HMSLogger.js +48 -21
- package/lib/module/classes/HMSLogger.js.map +1 -1
- package/lib/module/classes/HMSMessage.js +4 -1
- package/lib/module/classes/HMSMessage.js.map +1 -1
- package/lib/module/classes/HMSMessageRecipient.js +17 -0
- package/lib/module/classes/HMSMessageRecipient.js.map +1 -0
- package/lib/module/classes/HMSMessageRecipientType.js +8 -0
- package/lib/module/classes/HMSMessageRecipientType.js.map +1 -0
- package/lib/module/classes/HMSPeerUpdate.js +1 -7
- package/lib/module/classes/HMSPeerUpdate.js.map +1 -1
- package/lib/module/classes/HMSPermissions.js +2 -2
- package/lib/module/classes/HMSPermissions.js.map +1 -1
- package/lib/module/classes/HMSRTCStats.js +29 -0
- package/lib/module/classes/HMSRTCStats.js.map +1 -0
- package/lib/module/classes/HMSRTCStatsReport.js +17 -0
- package/lib/module/classes/HMSRTCStatsReport.js.map +1 -0
- package/lib/module/classes/HMSRemoteAudioStats.js +23 -0
- package/lib/module/classes/HMSRemoteAudioStats.js.map +1 -0
- package/lib/module/classes/HMSRemoteVideoStats.js +29 -0
- package/lib/module/classes/HMSRemoteVideoStats.js.map +1 -0
- package/lib/module/classes/HMSRoom.js +9 -0
- package/lib/module/classes/HMSRoom.js.map +1 -1
- package/lib/module/classes/HMSRoomUpdate.js +7 -0
- package/lib/module/classes/HMSRoomUpdate.js.map +1 -1
- package/lib/module/classes/HMSRtmpStreamingState.js +6 -0
- package/lib/module/classes/HMSRtmpStreamingState.js.map +1 -1
- package/lib/module/classes/HMSSDK.js +476 -115
- package/lib/module/classes/HMSSDK.js.map +1 -1
- package/lib/module/classes/HMSServerRecordingState.js +3 -0
- package/lib/module/classes/HMSServerRecordingState.js.map +1 -1
- package/lib/module/classes/HMSUpdateListenerActions.js +5 -0
- package/lib/module/classes/HMSUpdateListenerActions.js.map +1 -1
- package/lib/module/classes/HmsView.js +23 -4
- package/lib/module/classes/HmsView.js.map +1 -1
- package/lib/module/index.js +14 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/classes/HMSBrowserRecordingState.d.ts +4 -0
- package/lib/typescript/classes/HMSEncoder.d.ts +23 -0
- package/lib/typescript/classes/HMSHLSConfig.d.ts +10 -0
- package/lib/typescript/classes/HMSHLSMeetingURLVariant.d.ts +8 -0
- package/lib/typescript/classes/HMSHLSRecordingConfig.d.ts +8 -0
- package/lib/typescript/classes/HMSHLSRecordingState.d.ts +12 -0
- package/lib/typescript/classes/HMSHLSStreamingState.d.ts +9 -0
- package/lib/typescript/classes/HMSHLSVariant.d.ts +12 -0
- package/lib/typescript/classes/HMSLocalAudioStats.d.ts +10 -0
- package/lib/typescript/classes/HMSLocalVideoStats.d.ts +15 -0
- package/lib/typescript/classes/HMSLogger.d.ts +2 -0
- package/lib/typescript/classes/HMSMessage.d.ts +8 -4
- package/lib/typescript/classes/HMSMessageRecipient.d.ts +13 -0
- package/lib/typescript/classes/HMSMessageRecipientType.d.ts +5 -0
- package/lib/typescript/classes/HMSPeerUpdate.d.ts +2 -8
- package/lib/typescript/classes/HMSPermissions.d.ts +2 -2
- package/lib/typescript/classes/HMSRTCStats.d.ts +18 -0
- package/lib/typescript/classes/HMSRTCStatsReport.d.ts +11 -0
- package/lib/typescript/classes/HMSRemoteAudioStats.d.ts +14 -0
- package/lib/typescript/classes/HMSRemoteVideoStats.d.ts +19 -0
- package/lib/typescript/classes/HMSRoom.d.ts +8 -0
- package/lib/typescript/classes/HMSRoomUpdate.d.ts +8 -1
- package/lib/typescript/classes/HMSRtmpStreamingState.d.ts +4 -0
- package/lib/typescript/classes/HMSSDK.d.ts +325 -14
- package/lib/typescript/classes/HMSServerRecordingState.d.ts +2 -0
- package/lib/typescript/classes/HMSUpdateListenerActions.d.ts +6 -1
- package/lib/typescript/index.d.ts +14 -0
- package/package.json +1 -2
- package/react-native-hms.podspec +1 -1
- package/src/classes/HMSBrowserRecordingState.ts +10 -1
- package/src/classes/HMSEncoder.ts +193 -3
- package/src/classes/HMSHLSConfig.ts +15 -0
- package/src/classes/HMSHLSMeetingURLVariant.ts +9 -0
- package/src/classes/HMSHLSRecordingConfig.ts +9 -0
- package/src/classes/HMSHLSRecordingState.ts +18 -0
- package/src/classes/HMSHLSStreamingState.ts +11 -0
- package/src/classes/HMSHLSVariant.ts +18 -0
- package/src/classes/HMSLocalAudioStats.ts +15 -0
- package/src/classes/HMSLocalVideoStats.ts +23 -0
- package/src/classes/HMSLogger.ts +17 -3
- package/src/classes/HMSMessage.ts +11 -5
- package/src/classes/HMSMessageRecipient.ts +19 -0
- package/src/classes/HMSMessageRecipientType.ts +5 -0
- package/src/classes/HMSPeerUpdate.ts +1 -7
- package/src/classes/HMSPermissions.ts +3 -3
- package/src/classes/HMSRTCStats.ts +27 -0
- package/src/classes/HMSRTCStatsReport.ts +17 -0
- package/src/classes/HMSRemoteAudioStats.ts +21 -0
- package/src/classes/HMSRemoteVideoStats.ts +29 -0
- package/src/classes/HMSRoom.ts +11 -0
- package/src/classes/HMSRoomUpdate.ts +7 -0
- package/src/classes/HMSRtmpStreamingState.ts +10 -1
- package/src/classes/HMSSDK.tsx +618 -30
- package/src/classes/HMSServerRecordingState.ts +7 -1
- package/src/classes/HMSUpdateListenerActions.ts +5 -0
- package/src/classes/HmsView.tsx +32 -4
- package/src/index.ts +14 -0
package/README.md
CHANGED
|
@@ -14,16 +14,25 @@
|
|
|
14
14
|
[](https://100ms.live/discord)
|
|
15
15
|
[](https://appdistribution.firebase.dev/i/7b7ab3b30e627c35)
|
|
16
16
|
[](https://testflight.apple.com/join/v4bSIPad)
|
|
17
|
+
[](https://github.com/100mslive/react-native-hms/projects/1)
|
|
17
18
|
[](https://dashboard.100ms.live/register)
|
|
18
19
|
|
|
19
20
|
React native wrapper for 100ms SDK
|
|
20
21
|
|
|
22
|
+
## Run Example App
|
|
23
|
+
|
|
24
|
+
To run the example app on your system, follow these steps -
|
|
25
|
+
|
|
26
|
+
1. In the project root, run `npm install`
|
|
27
|
+
2. Go to the example folder, `cd example`
|
|
28
|
+
3. In the example folder, run `npm install`
|
|
29
|
+
4. To run on Android, run `npx react-native run-android`
|
|
30
|
+
5. To run on iOS, first install the pods in iOS folder, `cd ios; pod install`. Then, in example folder, run `npx react-native run-ios`
|
|
31
|
+
|
|
21
32
|
## Installation
|
|
22
33
|
|
|
23
34
|
```bash
|
|
24
35
|
npm install @100mslive/react-native-hms --save
|
|
25
|
-
|
|
26
|
-
cd ios/ && pod install
|
|
27
36
|
```
|
|
28
37
|
|
|
29
38
|
📲 Download the Sample iOS App here: https://testflight.apple.com/join/v4bSIPad
|
|
@@ -63,7 +72,7 @@ We suggest using [react-native-permission](https://www.npmjs.com/package/react-n
|
|
|
63
72
|
|
|
64
73
|
The package exports all the classes and a HMSSDK class that manages everything.
|
|
65
74
|
|
|
66
|
-
|
|
75
|
+
## Setting up the HMS Instance
|
|
67
76
|
|
|
68
77
|
first we'll have to call build method, that method returns an instance of HMSSDK class and the same is used to perform all the operations
|
|
69
78
|
|
|
@@ -77,7 +86,7 @@ const hmsInstance = await HMSSDK.build();
|
|
|
77
86
|
...
|
|
78
87
|
```
|
|
79
88
|
|
|
80
|
-
|
|
89
|
+
## Add event listeners
|
|
81
90
|
|
|
82
91
|
add event listeners for all the events such as onPreview, onJoin, onPeerUpdate etc. the actions can be found in HMSUpdateListenerActions class
|
|
83
92
|
|
|
@@ -96,7 +105,16 @@ hmsInstance.addEventListener(
|
|
|
96
105
|
|
|
97
106
|
The event handlers are the way of handling any update happening in hms all events can be found in HMSUpdateListenerActions class
|
|
98
107
|
|
|
99
|
-
|
|
108
|
+
## Error handling
|
|
109
|
+
|
|
110
|
+
```js
|
|
111
|
+
import { HMSUpdateListenerActions } from '@100mslive/react-native-hms';
|
|
112
|
+
|
|
113
|
+
// add an error event listener
|
|
114
|
+
hmsInstance.addEventListener(HMSUpdateListenerActions.ON_ERROR, onError);
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Join the room
|
|
100
118
|
|
|
101
119
|
Joining the room connects you to the remote peer and broadcasts your stream to other peers, we need instance of HMSConfig in order to pass the details of room and user to join function
|
|
102
120
|
|
|
@@ -116,7 +134,23 @@ hmsInstance.join(HmsConfig); // to join a room
|
|
|
116
134
|
|
|
117
135
|
don't forget to add ON_JOIN listener before calling join to receive an event callback
|
|
118
136
|
|
|
119
|
-
|
|
137
|
+
## Calling various functions of HMS
|
|
138
|
+
|
|
139
|
+
```js
|
|
140
|
+
// Mute Audio
|
|
141
|
+
hmsInstance?.localPeer?.localAudioTrack()?.setMute(true);
|
|
142
|
+
|
|
143
|
+
// Stop Video
|
|
144
|
+
hmsInstance?.localPeer?.localVideoTrack()?.setMute(true);
|
|
145
|
+
|
|
146
|
+
// Switch Camera
|
|
147
|
+
hmsInstance?.localPeer?.localVideoTrack()?.switchCamera();
|
|
148
|
+
|
|
149
|
+
// Leave the call (async function)
|
|
150
|
+
await hmsInstance?.leave();
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Viewing the video of a peer
|
|
120
154
|
|
|
121
155
|
To display a video on screen the package provide a UI component named HmsView that takes the video track ID and displays the video in that component, this component requires on _width_ and _height_ in _style_ prop to set bounds of the tile that will show the video stream
|
|
122
156
|
|
|
@@ -124,7 +158,7 @@ To display a video on screen the package provide a UI component named HmsView th
|
|
|
124
158
|
...
|
|
125
159
|
import { HMSRemotePeer } from '@100mslive/react-native-hms';
|
|
126
160
|
|
|
127
|
-
// getting local track ID
|
|
161
|
+
// getting local track ID
|
|
128
162
|
const localTrackId: string = hmsInstance?.localPeer?.videoTrack?.trackId;
|
|
129
163
|
|
|
130
164
|
// getting remote track IDs
|
|
@@ -142,7 +176,7 @@ remotePeers.map((remotePeer: HMSRemotePeer) => {
|
|
|
142
176
|
...
|
|
143
177
|
```
|
|
144
178
|
|
|
145
|
-
|
|
179
|
+
## Display a video in HmsView
|
|
146
180
|
|
|
147
181
|
```js
|
|
148
182
|
import { HMSVideoViewMode } from '@100mslive/react-native-hms';
|
|
@@ -166,43 +200,230 @@ const styles = StyleSheet.create({
|
|
|
166
200
|
...
|
|
167
201
|
```
|
|
168
202
|
|
|
169
|
-
|
|
203
|
+
## Mute/Unmute others
|
|
170
204
|
|
|
171
205
|
```js
|
|
172
|
-
|
|
173
|
-
hmsInstance?.localPeer?.localAudioTrack()?.setMute(true);
|
|
206
|
+
const mute: boolean = true;
|
|
174
207
|
|
|
175
|
-
//
|
|
176
|
-
hmsInstance?.
|
|
208
|
+
// hms instance acquired by build methodhmsInstance?.changeTrackState(audioTrack as HMSTrack, mute);
|
|
209
|
+
hmsInstance?.changeTrackState(videoTrack as HMSTrack, mute);
|
|
177
210
|
|
|
178
|
-
|
|
179
|
-
hmsInstance?.localPeer?.localVideoTrack()?.switchCamera();
|
|
211
|
+
const unmute: boolean = false;
|
|
180
212
|
|
|
181
|
-
|
|
182
|
-
|
|
213
|
+
hmsInstance?.changeTrackState(audioTrack as HMSTrack, unmute);
|
|
214
|
+
hmsInstance?.changeTrackState(videoTrack as HMSTrack, unmute);
|
|
183
215
|
```
|
|
184
216
|
|
|
185
|
-
|
|
217
|
+
## End Room for all
|
|
186
218
|
|
|
187
219
|
```js
|
|
188
|
-
|
|
220
|
+
const reason = 'Host ended the room';
|
|
221
|
+
const lock = false; // optional parameter
|
|
222
|
+
|
|
223
|
+
// hms instance acquired by build method
|
|
224
|
+
hmsInstance.endRoom(reason, lock);
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## Remove Peer
|
|
228
|
+
|
|
229
|
+
```js
|
|
230
|
+
import { HMSPeer } from '@100mslive/react-native-hms';
|
|
231
|
+
|
|
232
|
+
const reason = 'removed from room';
|
|
233
|
+
|
|
234
|
+
// hms instance acquired by build method
|
|
235
|
+
const peer: HMSPeer = hmsInstance?.remotePeers[0];
|
|
236
|
+
|
|
237
|
+
hmsInstance.removePeer(peer, reason);
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## Sending messages
|
|
241
|
+
|
|
242
|
+
```js
|
|
243
|
+
import { HMSRole, HMSPeer } from '@100mslive/react-native-hms';
|
|
189
244
|
|
|
190
245
|
const message = 'hello'
|
|
191
246
|
const roles: HMSRole[] = hmsInstance?.knownRoles
|
|
192
|
-
//
|
|
193
|
-
const
|
|
247
|
+
// any remote peer
|
|
248
|
+
const peer: HMSPeer = hmsInstance?.remotePeers[0]
|
|
194
249
|
|
|
195
250
|
// send a different type of messages
|
|
196
251
|
hmsInstance?.sendBroadcastMessage(message);
|
|
197
252
|
hmsInstance?.sendGroupMessage(message, [role[0]);
|
|
198
|
-
hmsInstance?.sendDirectMessage(message,
|
|
253
|
+
hmsInstance?.sendDirectMessage(message, peer);
|
|
199
254
|
```
|
|
200
255
|
|
|
201
|
-
|
|
256
|
+
## Role Change
|
|
202
257
|
|
|
203
258
|
```js
|
|
204
|
-
import {
|
|
259
|
+
import { HMSRole, HMSRemotePeer } from '@100mslive/react-native-hms';
|
|
260
|
+
// hms instance acquired by build method
|
|
261
|
+
const roles: HMSRole[] = hmsInstance?.knownRoles;
|
|
262
|
+
const newRole: HMSRole = roles[0];
|
|
205
263
|
|
|
206
|
-
//
|
|
207
|
-
hmsInstance
|
|
264
|
+
// can any remote peer
|
|
265
|
+
const peer: HMSRemotePeer = hmsInstance?.remotePeers[0];
|
|
266
|
+
|
|
267
|
+
const force = false;
|
|
268
|
+
|
|
269
|
+
hmsInstance.changeRole(peer, newRole, force); // request role change
|
|
270
|
+
hmsInstance.changeRole(peer, newRole, !force); // force role change
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
## Raise Hand & BRB
|
|
274
|
+
|
|
275
|
+
```js
|
|
276
|
+
const parsedMetadata = JSON.parse(hmsInstance?.localPeer?.metadata);
|
|
277
|
+
|
|
278
|
+
// Raise Hand
|
|
279
|
+
// hms instance acquired by build method
|
|
280
|
+
hmsInstance?.changeMetadata(
|
|
281
|
+
JSON.stringify({
|
|
282
|
+
...parsedMetadata,
|
|
283
|
+
isHandRaised: true,
|
|
284
|
+
})
|
|
285
|
+
);
|
|
286
|
+
|
|
287
|
+
// BRB
|
|
288
|
+
// hms instance acquired by build method
|
|
289
|
+
hmsInstance?.changeMetadata(
|
|
290
|
+
JSON.stringify({
|
|
291
|
+
...parsedMetadata,
|
|
292
|
+
isBRBOn: true,
|
|
293
|
+
})
|
|
294
|
+
);
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
## HLS Streaming
|
|
298
|
+
|
|
299
|
+
```js
|
|
300
|
+
import {
|
|
301
|
+
HMSHLSMeetingURLVariant,
|
|
302
|
+
HMSHLSConfig,
|
|
303
|
+
} from '@100mslive/react-native-hms';
|
|
304
|
+
|
|
305
|
+
const startHLSStreaming = () => {
|
|
306
|
+
const hmsHLSMeetingURLVariant = new HMSHLSMeetingURLVariant({
|
|
307
|
+
meetingUrl:
|
|
308
|
+
'https://yogi.app.100ms.live/preview/nih-bkn-vek?token=beam_recording',
|
|
309
|
+
metadata: '',
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
const hmsHLSConfig = new HMSHLSConfig({
|
|
313
|
+
meetingURLVariants: [hlsStreamingDetails],
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
// hms instance acquired by build method
|
|
317
|
+
hmsInstance
|
|
318
|
+
.startHLSStreaming(hmsHLSConfig)
|
|
319
|
+
.then((r) => console.log(r))
|
|
320
|
+
.catch((e) => console.log(e));
|
|
321
|
+
};
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
## Start Streaming / Recording
|
|
325
|
+
|
|
326
|
+
```js
|
|
327
|
+
import { HMSRTMPConfig } from '@100mslive/react-native-hms';
|
|
328
|
+
|
|
329
|
+
const recordingDetails = HMSRTMPConfig({
|
|
330
|
+
record: true,
|
|
331
|
+
meetingURL: roomID + '/viewer?token=beam_recording',
|
|
332
|
+
rtmpURLs: [],
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
// hms instance acquired by build method
|
|
336
|
+
const result = await hmsInstance?.startRTMPOrRecording(recordingDetails);
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
## Get RTC Stats
|
|
340
|
+
|
|
341
|
+
```js
|
|
342
|
+
// hms instance acquired by build method
|
|
343
|
+
hmsInstance?.enableRTCStats();
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
## Screenshare
|
|
347
|
+
|
|
348
|
+
```js
|
|
349
|
+
// hms instance acquired by build method
|
|
350
|
+
hmsInstance?.startScreenshare();
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
## Getting Audio Levels for all speaking peers
|
|
354
|
+
|
|
355
|
+
```js
|
|
356
|
+
import {
|
|
357
|
+
HMSUpdateListenerActions,
|
|
358
|
+
HMSSpeakerUpdate,
|
|
359
|
+
HMSSpeaker,
|
|
360
|
+
} from '@100mslive/react-native-hms';
|
|
361
|
+
|
|
362
|
+
// hms instance acquired by build method
|
|
363
|
+
hmsInstance?.addEventListener(HMSUpdateListenerActions.ON_SPEAKER, onSpeaker);
|
|
364
|
+
|
|
365
|
+
const onSpeaker = (data: HMSSpeakerUpdate) => {
|
|
366
|
+
data?.peers?.map((speaker: HMSSpeaker) =>
|
|
367
|
+
console.log('speaker audio level: ', speaker?.level)
|
|
368
|
+
);
|
|
369
|
+
};
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
## Local mute others
|
|
373
|
+
|
|
374
|
+
```js
|
|
375
|
+
const remotePeer: HMSRemotePeer;
|
|
376
|
+
const isAudioPlaybackAllowed = remotePeer.remoteAudioTrack().setPlaybackAllowed(false);
|
|
377
|
+
const isVideoPlaybackAllowed = remotePeer.remoteVideoTrack().setPlaybackAllowed(true);
|
|
378
|
+
|
|
379
|
+
// hms instance acquired by build method
|
|
380
|
+
hmsInstance.muteAllPeersAudio(true) // mute
|
|
381
|
+
hmsInstance.muteAllPeersAudio(false) // unmute
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
## Locally Set Volume
|
|
385
|
+
|
|
386
|
+
```js
|
|
387
|
+
const volume: Float = 1.0;
|
|
388
|
+
const track: HMSTrack = remotePeer.audioTrack as HMSTrack;
|
|
389
|
+
|
|
390
|
+
// hms instance acquired by build method
|
|
391
|
+
hmsInstance?.setVolume(track, volume);
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
## Change name
|
|
395
|
+
|
|
396
|
+
```js
|
|
397
|
+
const newName: string = 'new name';
|
|
398
|
+
|
|
399
|
+
// hms instance acquired by build method
|
|
400
|
+
hmsInstance.changeName(newName);
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
## Join with specific Track Settings
|
|
404
|
+
|
|
405
|
+
```js
|
|
406
|
+
const getTrackSettings = () => {
|
|
407
|
+
let audioSettings = new HMSAudioTrackSettings({
|
|
408
|
+
maxBitrate: 32,
|
|
409
|
+
trackDescription: 'Simple Audio Track',
|
|
410
|
+
});
|
|
411
|
+
let videoSettings = new HMSVideoTrackSettings({
|
|
412
|
+
codec: HMSVideoCodec.vp8,
|
|
413
|
+
maxBitrate: 512,
|
|
414
|
+
maxFrameRate: 25,
|
|
415
|
+
cameraFacing: HMSCameraFacing.FRONT,
|
|
416
|
+
trackDescription: 'Simple Video Track',
|
|
417
|
+
resolution: new HMSVideoResolution({ height: 180, width: 320 }),
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
return new HMSTrackSettings({ video: videoSettings, audio: audioSettings });
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
const setupBuild = async () => {
|
|
424
|
+
const trackSettings = getTrackSettings();
|
|
425
|
+
const build = await HmsManager.build({ trackSettings });
|
|
426
|
+
setInstance(build);
|
|
427
|
+
updateHms({ hmsInstance: build });
|
|
428
|
+
};
|
|
208
429
|
```
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="GradleSettings">
|
|
4
|
+
<option name="linkedExternalProjectsSettings">
|
|
5
|
+
<GradleProjectSettings>
|
|
6
|
+
<option name="testRunner" value="GRADLE" />
|
|
7
|
+
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
|
8
|
+
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
|
9
|
+
<option name="resolveModulePerSourceSet" value="false" />
|
|
10
|
+
</GradleProjectSettings>
|
|
11
|
+
</option>
|
|
12
|
+
</component>
|
|
13
|
+
</project>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectRootManager" version="2" project-jdk-name="11" project-jdk-type="JavaSDK">
|
|
4
|
+
<output url="file://$PROJECT_DIR$/build/classes" />
|
|
5
|
+
</component>
|
|
6
|
+
<component name="ProjectType">
|
|
7
|
+
<option name="id" value="Android" />
|
|
8
|
+
</component>
|
|
9
|
+
</project>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module external.linked.project.id=":" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" type="JAVA_MODULE" version="4">
|
|
3
|
+
<component name="FacetManager">
|
|
4
|
+
<facet type="android-gradle" name="Android-Gradle">
|
|
5
|
+
<configuration>
|
|
6
|
+
<option name="GRADLE_PROJECT_PATH" value=":" />
|
|
7
|
+
<option name="LAST_SUCCESSFUL_SYNC_AGP_VERSION" />
|
|
8
|
+
<option name="LAST_KNOWN_AGP_VERSION" />
|
|
9
|
+
</configuration>
|
|
10
|
+
</facet>
|
|
11
|
+
</component>
|
|
12
|
+
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
13
|
+
<exclude-output />
|
|
14
|
+
<content url="file://$MODULE_DIR$/../.." />
|
|
15
|
+
<orderEntry type="inheritedJdk" />
|
|
16
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
17
|
+
</component>
|
|
18
|
+
</module>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectModuleManager">
|
|
4
|
+
<modules>
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/modules/android.iml" filepath="$PROJECT_DIR$/.idea/modules/android.iml" />
|
|
6
|
+
</modules>
|
|
7
|
+
</component>
|
|
8
|
+
</project>
|
|
File without changes
|
package/android/build.gradle
CHANGED
|
@@ -26,7 +26,7 @@ def safeExtGet(prop, fallback) {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
android {
|
|
29
|
-
compileSdkVersion safeExtGet('Hmssdk_compileSdkVersion',
|
|
29
|
+
compileSdkVersion safeExtGet('Hmssdk_compileSdkVersion', 30)
|
|
30
30
|
defaultConfig {
|
|
31
31
|
minSdkVersion safeExtGet('Hmssdk_minSdkVersion', 21)
|
|
32
32
|
targetSdkVersion safeExtGet('Hmssdk_targetSdkVersion', 29)
|
|
@@ -63,6 +63,8 @@ dependencies {
|
|
|
63
63
|
//noinspection GradleDynamicVersion
|
|
64
64
|
implementation "com.facebook.react:react-native:+"
|
|
65
65
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" // From node_modules
|
|
66
|
-
implementation 'com.github.100mslive
|
|
66
|
+
implementation 'com.github.100mslive.android-sdk:lib:2.3.4'
|
|
67
67
|
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0'
|
|
68
|
+
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
|
|
69
|
+
implementation 'androidx.appcompat:appcompat:1.3.1'
|
|
68
70
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
## This file must *NOT* be checked into Version Control Systems,
|
|
2
|
+
# as it contains information specific to your local configuration.
|
|
3
|
+
#
|
|
4
|
+
# Location of the SDK. This is only used by Gradle.
|
|
5
|
+
# For customization when using a Version Control System, please read the
|
|
6
|
+
# header note.
|
|
7
|
+
#Tue Mar 01 18:12:03 IST 2022
|
|
8
|
+
sdk.dir=/Users/yogesh/Library/Android/sdk
|
|
@@ -31,8 +31,10 @@ object HmsDecoder {
|
|
|
31
31
|
"serverRecordingState",
|
|
32
32
|
this.getHMSServerRecordingState(hmsRoom.serverRecordingState)
|
|
33
33
|
)
|
|
34
|
+
room.putMap("hlsStreamingState", this.getHMSHlsStreamingState(hmsRoom.hlsStreamingState))
|
|
34
35
|
room.putMap("localPeer", this.getHmsLocalPeer(hmsRoom.localPeer))
|
|
35
36
|
room.putArray("peers", this.getAllPeers(hmsRoom.peerList))
|
|
37
|
+
room.putInt("peerCount", hmsRoom.peerCount)
|
|
36
38
|
}
|
|
37
39
|
return room
|
|
38
40
|
}
|
|
@@ -122,7 +124,7 @@ object HmsDecoder {
|
|
|
122
124
|
permissions.putBoolean("changeRoleForce", hmsPermissions.changeRoleForce)
|
|
123
125
|
permissions.putBoolean("unmute", hmsPermissions.unmute)
|
|
124
126
|
permissions.putBoolean("recording", hmsPermissions.recording)
|
|
125
|
-
permissions.putBoolean("
|
|
127
|
+
permissions.putBoolean("streaming", hmsPermissions.streaming)
|
|
126
128
|
permissions.putBoolean("changeRole", hmsPermissions.changeRole)
|
|
127
129
|
}
|
|
128
130
|
return permissions
|
|
@@ -153,7 +155,7 @@ object HmsDecoder {
|
|
|
153
155
|
|
|
154
156
|
private fun getHmsAudioSettings(hmsAudioSettings: AudioParams?): WritableMap {
|
|
155
157
|
val audioSettings: WritableMap = Arguments.createMap()
|
|
156
|
-
if (hmsAudioSettings != null) {
|
|
158
|
+
if (hmsAudioSettings != null && hmsAudioSettings.codec != null) {
|
|
157
159
|
audioSettings.putInt("bitRate", hmsAudioSettings.bitRate)
|
|
158
160
|
audioSettings.putString("codec", hmsAudioSettings.codec.name)
|
|
159
161
|
}
|
|
@@ -162,7 +164,7 @@ object HmsDecoder {
|
|
|
162
164
|
|
|
163
165
|
private fun getHmsVideoSettings(hmsVideoSettings: VideoParams?): WritableMap {
|
|
164
166
|
val videoSettings: WritableMap = Arguments.createMap()
|
|
165
|
-
if (hmsVideoSettings != null) {
|
|
167
|
+
if (hmsVideoSettings != null && hmsVideoSettings.codec != null) {
|
|
166
168
|
videoSettings.putInt("bitRate", hmsVideoSettings.bitRate)
|
|
167
169
|
videoSettings.putInt("frameRate", hmsVideoSettings.frameRate)
|
|
168
170
|
videoSettings.putInt("width", hmsVideoSettings.width)
|
|
@@ -361,11 +363,34 @@ object HmsDecoder {
|
|
|
361
363
|
return decodedError
|
|
362
364
|
}
|
|
363
365
|
|
|
366
|
+
private fun getCustomError(message: String?, code: Int?): WritableMap {
|
|
367
|
+
val decodedError: WritableMap = Arguments.createMap()
|
|
368
|
+
var customCode = 101
|
|
369
|
+
var customMessage = "SOMETHING WENT WRONG"
|
|
370
|
+
if (code !== null) {
|
|
371
|
+
customCode = code.toInt()
|
|
372
|
+
}
|
|
373
|
+
if (message !== null) {
|
|
374
|
+
customMessage = message
|
|
375
|
+
}
|
|
376
|
+
decodedError.putInt("code", customCode)
|
|
377
|
+
decodedError.putString("localizedDescription", customMessage)
|
|
378
|
+
decodedError.putString("description", customMessage)
|
|
379
|
+
decodedError.putString("message", customMessage)
|
|
380
|
+
decodedError.putInt("name", customCode)
|
|
381
|
+
decodedError.putInt("action", customCode)
|
|
382
|
+
|
|
383
|
+
return decodedError
|
|
384
|
+
}
|
|
385
|
+
|
|
364
386
|
private fun getHMSBrowserRecordingState(data: HMSBrowserRecordingState?): ReadableMap {
|
|
365
387
|
val input = Arguments.createMap()
|
|
366
388
|
if (data !== null) {
|
|
367
389
|
input.putBoolean("running", data.running)
|
|
368
|
-
input.
|
|
390
|
+
input.putString("startedAt", data.startedAt.toString())
|
|
391
|
+
input.putString("stoppedAt", data.stoppedAt.toString())
|
|
392
|
+
input.putBoolean("running", data.running)
|
|
393
|
+
input.putMap("error", this.getCustomError(data.error?.message, data.error?.code))
|
|
369
394
|
}
|
|
370
395
|
return input
|
|
371
396
|
}
|
|
@@ -374,7 +399,9 @@ object HmsDecoder {
|
|
|
374
399
|
val input = Arguments.createMap()
|
|
375
400
|
if (data !== null) {
|
|
376
401
|
input.putBoolean("running", data.running)
|
|
377
|
-
input.
|
|
402
|
+
input.putString("startedAt", data.startedAt.toString())
|
|
403
|
+
input.putString("stoppedAt", data.stoppedAt.toString())
|
|
404
|
+
input.putMap("error", this.getCustomError(data.error?.message, data.error?.code))
|
|
378
405
|
}
|
|
379
406
|
return input
|
|
380
407
|
}
|
|
@@ -383,11 +410,36 @@ object HmsDecoder {
|
|
|
383
410
|
val input = Arguments.createMap()
|
|
384
411
|
if (data !== null) {
|
|
385
412
|
input.putBoolean("running", data.running)
|
|
413
|
+
input.putString("startedAt", data.startedAt.toString())
|
|
386
414
|
input.putMap("error", data.error?.let { this.getError(it) })
|
|
387
415
|
}
|
|
388
416
|
return input
|
|
389
417
|
}
|
|
390
418
|
|
|
419
|
+
private fun getHMSHlsStreamingState(data: HMSHLSStreamingState?): ReadableMap {
|
|
420
|
+
val input = Arguments.createMap()
|
|
421
|
+
if (data !== null) {
|
|
422
|
+
input.putBoolean("running", data.running)
|
|
423
|
+
input.putArray("variants", this.getHMSHLSVariant(data.variants))
|
|
424
|
+
}
|
|
425
|
+
return input
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
private fun getHMSHLSVariant(data: ArrayList<HMSHLSVariant>?): ReadableArray {
|
|
429
|
+
val variants = Arguments.createArray()
|
|
430
|
+
if (data !== null) {
|
|
431
|
+
for (variant in data) {
|
|
432
|
+
val input = Arguments.createMap()
|
|
433
|
+
input.putString("hlsStreamUrl", variant.hlsStreamUrl)
|
|
434
|
+
input.putString("meetingUrl", variant.meetingUrl)
|
|
435
|
+
input.putString("metadata", variant.metadata)
|
|
436
|
+
input.putString("startedAt", variant.startedAt.toString())
|
|
437
|
+
variants.pushMap(input)
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
return variants
|
|
441
|
+
}
|
|
442
|
+
|
|
391
443
|
private fun getHmsSubscribeSettings(hmsSubscribeSettings: SubscribeParams?): WritableMap {
|
|
392
444
|
val subscribeSettings: WritableMap = Arguments.createMap()
|
|
393
445
|
if (hmsSubscribeSettings != null) {
|
|
@@ -446,4 +498,14 @@ object HmsDecoder {
|
|
|
446
498
|
}
|
|
447
499
|
return decodedTracks
|
|
448
500
|
}
|
|
501
|
+
|
|
502
|
+
fun getHmsMessageRecipient(recipient: HMSMessageRecipient?): WritableMap {
|
|
503
|
+
val hmsRecipient: WritableMap = Arguments.createMap()
|
|
504
|
+
if (recipient != null) {
|
|
505
|
+
hmsRecipient.putMap("recipientPeer", this.getHmsPeer(recipient.recipientPeer))
|
|
506
|
+
hmsRecipient.putArray("recipientRoles", this.getAllRoles(recipient.recipientRoles))
|
|
507
|
+
hmsRecipient.putString("recipientType", recipient.recipientType.name)
|
|
508
|
+
}
|
|
509
|
+
return hmsRecipient
|
|
510
|
+
}
|
|
449
511
|
}
|