@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
package/README.md
CHANGED
|
@@ -61,18 +61,18 @@ We suggest using [react-native-permission](https://www.npmjs.com/package/react-n
|
|
|
61
61
|
|
|
62
62
|
## QuickStart
|
|
63
63
|
|
|
64
|
-
The package exports
|
|
64
|
+
The package exports all the classes and a HMSSDK class that manages everything.
|
|
65
65
|
|
|
66
66
|
# Setting up the HMS Instance:
|
|
67
67
|
|
|
68
|
-
first we'll have to call build method, that method returns an instance of
|
|
68
|
+
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
69
|
|
|
70
70
|
```js
|
|
71
|
-
import
|
|
71
|
+
import { HMSSDK } from '@100mslive/react-native-hms';
|
|
72
72
|
...
|
|
73
73
|
|
|
74
|
-
const hmsInstance = await
|
|
75
|
-
//save this instance, will be used for all the operations that we'll perform
|
|
74
|
+
const hmsInstance = await HMSSDK.build();
|
|
75
|
+
// save this instance, it will be used for all the operations that we'll perform
|
|
76
76
|
|
|
77
77
|
...
|
|
78
78
|
```
|
|
@@ -82,9 +82,7 @@ const hmsInstance = await HmsManager.build();
|
|
|
82
82
|
add event listeners for all the events such as onPreview, onJoin, onPeerUpdate etc. the actions can be found in HMSUpdateListenerActions class
|
|
83
83
|
|
|
84
84
|
```js
|
|
85
|
-
import
|
|
86
|
-
HMSUpdateListenerActions,
|
|
87
|
-
} from 'react-native-hms';
|
|
85
|
+
import { HMSUpdateListenerActions } from '@100mslive/react-native-hms';
|
|
88
86
|
...
|
|
89
87
|
|
|
90
88
|
// instance acquired from build() method
|
|
@@ -103,17 +101,15 @@ The event handlers are the way of handling any update happening in hms all event
|
|
|
103
101
|
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
|
|
104
102
|
|
|
105
103
|
```js
|
|
106
|
-
import
|
|
107
|
-
HMSUpdateListenerActions,
|
|
108
|
-
HMSConfig,
|
|
109
|
-
} from 'react-native-hms';
|
|
104
|
+
import { HMSUpdateListenerActions, HMSConfig } from '@100mslive/react-native-hms';
|
|
110
105
|
...
|
|
111
106
|
|
|
112
|
-
// instance acquired from build() method
|
|
113
107
|
const HmsConfig = new HMSConfig({authToken, userID, roomID});
|
|
114
|
-
|
|
108
|
+
|
|
109
|
+
// instance acquired from build() method
|
|
110
|
+
hmsInstance.preview(HmsConfig); // to start preview
|
|
115
111
|
// or
|
|
116
|
-
|
|
112
|
+
hmsInstance.join(HmsConfig); // to join a room
|
|
117
113
|
|
|
118
114
|
...
|
|
119
115
|
```
|
|
@@ -126,16 +122,17 @@ To display a video on screen the package provide a UI component named HmsView th
|
|
|
126
122
|
|
|
127
123
|
```js
|
|
128
124
|
...
|
|
125
|
+
import { HMSRemotePeer } from '@100mslive/react-native-hms';
|
|
129
126
|
|
|
130
|
-
//getting local track ID
|
|
131
|
-
const localTrackId =
|
|
127
|
+
// getting local track ID
|
|
128
|
+
const localTrackId: string = hmsInstance?.localPeer?.videoTrack?.trackId;
|
|
132
129
|
|
|
133
130
|
// getting remote track IDs
|
|
134
|
-
const remotePeers =
|
|
131
|
+
const remotePeers: HMSRemotePeer[] = hmsInstance?.remotePeers
|
|
135
132
|
const remoteVideoIds: string[] = [];
|
|
136
133
|
|
|
137
|
-
remotePeers.map((remotePeer:
|
|
138
|
-
const remoteTrackId = remotePeer?.videoTrack?.trackId;
|
|
134
|
+
remotePeers.map((remotePeer: HMSRemotePeer) => {
|
|
135
|
+
const remoteTrackId: string = remotePeer?.videoTrack?.trackId;
|
|
139
136
|
|
|
140
137
|
if (remoteTrackId) {
|
|
141
138
|
remoteVideoIds.push(remoteTrackId);
|
|
@@ -148,8 +145,10 @@ remotePeers.map((remotePeer: any) => {
|
|
|
148
145
|
# Display a video in HmsView
|
|
149
146
|
|
|
150
147
|
```js
|
|
151
|
-
import {
|
|
148
|
+
import { HMSVideoViewMode } from '@100mslive/react-native-hms';
|
|
152
149
|
|
|
150
|
+
// instance acquired from build() method
|
|
151
|
+
const HmsView = hmsInstance?.HmsView;
|
|
153
152
|
...
|
|
154
153
|
const styles = StyleSheet.create({
|
|
155
154
|
hmsView: {
|
|
@@ -162,7 +161,7 @@ const styles = StyleSheet.create({
|
|
|
162
161
|
// sink is passed false video would be removed. It is a ios only prop, for android it is handled by the package itself.
|
|
163
162
|
// scaleType can be selected from HMSVideoViewMode as required
|
|
164
163
|
// mirror can be passed as true to flip videos horizontally
|
|
165
|
-
<HmsView sink={true} style={styles.hmsView} trackId={trackId} mirror={true} scaleType={HMSVideoViewMode.
|
|
164
|
+
<HmsView sink={true} style={styles.hmsView} trackId={trackId} mirror={true} scaleType={HMSVideoViewMode.ASPECT_FIT} />
|
|
166
165
|
|
|
167
166
|
...
|
|
168
167
|
```
|
|
@@ -171,40 +170,39 @@ const styles = StyleSheet.create({
|
|
|
171
170
|
|
|
172
171
|
```js
|
|
173
172
|
// Mute Audio
|
|
174
|
-
|
|
173
|
+
hmsInstance?.localPeer?.localAudioTrack()?.setMute(true);
|
|
175
174
|
|
|
176
175
|
// Stop Video
|
|
177
|
-
|
|
176
|
+
hmsInstance?.localPeer?.localVideoTrack()?.setMute(true);
|
|
178
177
|
|
|
179
178
|
// Switch Camera
|
|
180
|
-
|
|
179
|
+
hmsInstance?.localPeer?.localVideoTrack()?.switchCamera();
|
|
181
180
|
|
|
182
|
-
// Leave the call
|
|
183
|
-
|
|
181
|
+
// Leave the call (async function)
|
|
182
|
+
await hmsInstance?.leave();
|
|
184
183
|
```
|
|
185
184
|
|
|
186
185
|
# Sending messages
|
|
187
186
|
|
|
188
187
|
```js
|
|
189
|
-
import {
|
|
188
|
+
import { HMSRole } from '@100mslive/react-native-hms';
|
|
190
189
|
|
|
191
|
-
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
message: value,
|
|
196
|
-
});
|
|
190
|
+
const message = 'hello'
|
|
191
|
+
const roles: HMSRole[] = hmsInstance?.knownRoles
|
|
192
|
+
// can any remote peer's peerID
|
|
193
|
+
const peerId: string = hmsInstance?.localPeer?.peerID
|
|
197
194
|
|
|
198
|
-
// send a
|
|
199
|
-
|
|
195
|
+
// send a different type of messages
|
|
196
|
+
hmsInstance?.sendBroadcastMessage(message);
|
|
197
|
+
hmsInstance?.sendGroupMessage(message, [role[0]);
|
|
198
|
+
hmsInstance?.sendDirectMessage(message, peerId);
|
|
200
199
|
```
|
|
201
200
|
|
|
202
201
|
# Error handling
|
|
203
202
|
|
|
204
203
|
```js
|
|
205
|
-
// import actions
|
|
206
204
|
import { HMSUpdateListenerActions } from '@100mslive/react-native-hms';
|
|
207
205
|
|
|
208
|
-
// add
|
|
209
|
-
|
|
206
|
+
// add an error event listener
|
|
207
|
+
hmsInstance.addEventListener(HMSUpdateListenerActions.ON_ERROR, onError);
|
|
210
208
|
```
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/android/.project
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<projectDescription>
|
|
3
|
+
<name>reactnativehmssdk</name>
|
|
4
|
+
<comment>Project reactnativehmssdk created by Buildship.</comment>
|
|
5
|
+
<projects>
|
|
6
|
+
</projects>
|
|
7
|
+
<buildSpec>
|
|
8
|
+
<buildCommand>
|
|
9
|
+
<name>org.eclipse.jdt.core.javabuilder</name>
|
|
10
|
+
<arguments>
|
|
11
|
+
</arguments>
|
|
12
|
+
</buildCommand>
|
|
13
|
+
<buildCommand>
|
|
14
|
+
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
|
|
15
|
+
<arguments>
|
|
16
|
+
</arguments>
|
|
17
|
+
</buildCommand>
|
|
18
|
+
</buildSpec>
|
|
19
|
+
<natures>
|
|
20
|
+
<nature>org.eclipse.jdt.core.javanature</nature>
|
|
21
|
+
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
|
|
22
|
+
</natures>
|
|
23
|
+
<filteredResources>
|
|
24
|
+
<filter>
|
|
25
|
+
<id>0</id>
|
|
26
|
+
<name></name>
|
|
27
|
+
<type>30</type>
|
|
28
|
+
<matcher>
|
|
29
|
+
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
|
30
|
+
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
|
31
|
+
</matcher>
|
|
32
|
+
</filter>
|
|
33
|
+
</filteredResources>
|
|
34
|
+
</projectDescription>
|
package/android/build.gradle
CHANGED
|
@@ -64,6 +64,6 @@ dependencies {
|
|
|
64
64
|
//noinspection GradleDynamicVersion
|
|
65
65
|
implementation "com.facebook.react:react-native:+"
|
|
66
66
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" // From node_modules
|
|
67
|
-
implementation 'com.github.100mslive:android-sdk:
|
|
67
|
+
implementation 'com.github.100mslive:android-sdk:2.2.3'
|
|
68
68
|
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0'
|
|
69
69
|
}
|
|
@@ -2,6 +2,8 @@ package com.reactnativehmssdk
|
|
|
2
2
|
|
|
3
3
|
import com.facebook.react.bridge.*
|
|
4
4
|
import java.util.*
|
|
5
|
+
import live.hms.video.error.HMSException
|
|
6
|
+
import live.hms.video.media.codec.HMSVideoCodec
|
|
5
7
|
import live.hms.video.media.settings.HMSAudioTrackSettings
|
|
6
8
|
import live.hms.video.media.settings.HMSVideoTrackSettings
|
|
7
9
|
import live.hms.video.media.tracks.*
|
|
@@ -17,6 +19,19 @@ object HmsDecoder {
|
|
|
17
19
|
room.putString("id", hmsRoom.roomId)
|
|
18
20
|
room.putString("name", hmsRoom.name)
|
|
19
21
|
room.putString("metaData", null)
|
|
22
|
+
room.putString("startedAt", hmsRoom.startedAt.toString())
|
|
23
|
+
room.putMap(
|
|
24
|
+
"browserRecordingState",
|
|
25
|
+
this.getHMSBrowserRecordingState(hmsRoom.browserRecordingState)
|
|
26
|
+
)
|
|
27
|
+
room.putMap(
|
|
28
|
+
"rtmpHMSRtmpStreamingState",
|
|
29
|
+
this.getHMSRtmpStreamingState(hmsRoom.rtmpHMSRtmpStreamingState)
|
|
30
|
+
)
|
|
31
|
+
room.putMap(
|
|
32
|
+
"serverRecordingState",
|
|
33
|
+
this.getHMSServerRecordingState(hmsRoom.serverRecordingState)
|
|
34
|
+
)
|
|
20
35
|
var peers: WritableArray = Arguments.createArray()
|
|
21
36
|
for (peer in hmsRoom.peerList) {
|
|
22
37
|
peers.pushMap(getHmsPeer(peer))
|
|
@@ -36,10 +51,7 @@ object HmsDecoder {
|
|
|
36
51
|
"customerUserID",
|
|
37
52
|
if (hmsPeer.customerUserID == null) hmsPeer.customerUserID else ""
|
|
38
53
|
)
|
|
39
|
-
peer.putString(
|
|
40
|
-
"customerDescription",
|
|
41
|
-
if (hmsPeer.customerDescription == null) hmsPeer.customerDescription else ""
|
|
42
|
-
)
|
|
54
|
+
peer.putString("metadata", if (hmsPeer.metadata == null) hmsPeer.metadata else "")
|
|
43
55
|
peer.putMap("audioTrack", getHmsAudioTrack(hmsPeer.audioTrack))
|
|
44
56
|
peer.putMap("videoTrack", getHmsVideoTrack(hmsPeer.videoTrack))
|
|
45
57
|
peer.putMap("role", getHmsRole(hmsPeer.hmsRole))
|
|
@@ -70,6 +82,7 @@ object HmsDecoder {
|
|
|
70
82
|
hmsTrack.putString("source", hmsVideoTrack.source)
|
|
71
83
|
hmsTrack.putString("trackDescription", hmsVideoTrack.description)
|
|
72
84
|
hmsTrack.putBoolean("isMute", hmsVideoTrack.isMute)
|
|
85
|
+
hmsTrack.putBoolean("isDegraded", hmsVideoTrack.isDegraded)
|
|
73
86
|
}
|
|
74
87
|
return hmsTrack
|
|
75
88
|
}
|
|
@@ -81,6 +94,7 @@ object HmsDecoder {
|
|
|
81
94
|
hmsTrack.putString("source", track.source)
|
|
82
95
|
hmsTrack.putString("trackDescription", track.description)
|
|
83
96
|
hmsTrack.putBoolean("isMute", track.isMute)
|
|
97
|
+
hmsTrack.putString("type", track.type.toString())
|
|
84
98
|
}
|
|
85
99
|
return hmsTrack
|
|
86
100
|
}
|
|
@@ -132,14 +146,22 @@ object HmsDecoder {
|
|
|
132
146
|
"mute",
|
|
133
147
|
if (hmsPermissions.mute != null) hmsPermissions.mute else false
|
|
134
148
|
)
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
149
|
+
permissions.putBoolean(
|
|
150
|
+
"changeRoleForce",
|
|
151
|
+
if (hmsPermissions.changeRoleForce != null) hmsPermissions.changeRoleForce else false
|
|
152
|
+
)
|
|
153
|
+
permissions.putBoolean(
|
|
154
|
+
"unmute",
|
|
155
|
+
if (hmsPermissions.unmute != null) hmsPermissions.unmute else false
|
|
156
|
+
)
|
|
157
|
+
permissions.putBoolean(
|
|
158
|
+
"recording",
|
|
159
|
+
if (hmsPermissions.recording != null) hmsPermissions.recording else false
|
|
160
|
+
)
|
|
161
|
+
permissions.putBoolean(
|
|
162
|
+
"rtmp",
|
|
163
|
+
if (hmsPermissions.rtmp != null) hmsPermissions.rtmp else false
|
|
164
|
+
)
|
|
143
165
|
permissions.putBoolean(
|
|
144
166
|
"changeRole",
|
|
145
167
|
if (hmsPermissions.changeRole != null) hmsPermissions.changeRole else false
|
|
@@ -161,11 +183,25 @@ object HmsDecoder {
|
|
|
161
183
|
// getHmsSimulcastLayers(hmsPublishSettings.screenSimulcastLayers));
|
|
162
184
|
publishSettings.putMap("videoSimulcastLayers", null)
|
|
163
185
|
publishSettings.putMap("screenSimulcastLayers", null)
|
|
164
|
-
|
|
165
|
-
|
|
186
|
+
publishSettings.putArray(
|
|
187
|
+
"allowed",
|
|
188
|
+
if (hmsPublishSettings.allowed != null) getWriteableArray(hmsPublishSettings.allowed)
|
|
189
|
+
else emptyArray
|
|
190
|
+
)
|
|
166
191
|
}
|
|
167
192
|
return publishSettings
|
|
168
193
|
}
|
|
194
|
+
|
|
195
|
+
fun getWriteableArray(array: List<String>?): WritableArray {
|
|
196
|
+
val decodedArray: WritableArray = Arguments.createArray()
|
|
197
|
+
if (array != null) {
|
|
198
|
+
for (value in array) {
|
|
199
|
+
decodedArray.pushString(value)
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return decodedArray
|
|
203
|
+
}
|
|
204
|
+
|
|
169
205
|
fun getHmsAudioSettings(hmsAudioSettings: AudioParams?): WritableMap {
|
|
170
206
|
val audioSettings: WritableMap = Arguments.createMap()
|
|
171
207
|
if (hmsAudioSettings != null) {
|
|
@@ -225,10 +261,7 @@ object HmsDecoder {
|
|
|
225
261
|
"customerUserID",
|
|
226
262
|
if (hmsLocalPeer.customerUserID != null) hmsLocalPeer.customerUserID else ""
|
|
227
263
|
)
|
|
228
|
-
peer.putString(
|
|
229
|
-
"customerDescription",
|
|
230
|
-
if (hmsLocalPeer.customerDescription != null) hmsLocalPeer.customerDescription else ""
|
|
231
|
-
)
|
|
264
|
+
peer.putString("metadata", if (hmsLocalPeer.metadata != null) hmsLocalPeer.metadata else "")
|
|
232
265
|
peer.putMap("audioTrack", getHmsAudioTrack(hmsLocalPeer.audioTrack))
|
|
233
266
|
peer.putMap("videoTrack", getHmsVideoTrack(hmsLocalPeer.videoTrack))
|
|
234
267
|
peer.putMap("role", getHmsRole(hmsLocalPeer.hmsRole))
|
|
@@ -277,7 +310,7 @@ object HmsDecoder {
|
|
|
277
310
|
fun getHmsVideoTrackSettings(hmsVideoTrackSettings: HMSVideoTrackSettings?): WritableMap {
|
|
278
311
|
val settings: WritableMap = Arguments.createMap()
|
|
279
312
|
if (hmsVideoTrackSettings != null) {
|
|
280
|
-
settings.
|
|
313
|
+
settings.putString("codec", getHmsVideoTrackCodec(hmsVideoTrackSettings.codec))
|
|
281
314
|
|
|
282
315
|
val resolution: WritableMap = Arguments.createMap()
|
|
283
316
|
resolution.putInt("height", hmsVideoTrackSettings.resolution.height)
|
|
@@ -286,7 +319,10 @@ object HmsDecoder {
|
|
|
286
319
|
|
|
287
320
|
settings.putInt("maxBitrate", hmsVideoTrackSettings.maxBitRate)
|
|
288
321
|
settings.putInt("maxFrameRate", hmsVideoTrackSettings.maxFrameRate)
|
|
289
|
-
settings.
|
|
322
|
+
settings.putString(
|
|
323
|
+
"cameraFacing",
|
|
324
|
+
getHmsVideoTrackCameraFacing(hmsVideoTrackSettings.cameraFacing)
|
|
325
|
+
)
|
|
290
326
|
// settings.putString("trackDescription",
|
|
291
327
|
// if(hmsVideoTrackSettings.trackDescription!==null)hmsVideoTrackSettings.trackDescription
|
|
292
328
|
// else "");
|
|
@@ -295,6 +331,31 @@ object HmsDecoder {
|
|
|
295
331
|
return settings
|
|
296
332
|
}
|
|
297
333
|
|
|
334
|
+
fun getHmsVideoTrackCodec(codec: HMSVideoCodec): String {
|
|
335
|
+
return when (codec) {
|
|
336
|
+
HMSVideoCodec.H264 -> {
|
|
337
|
+
"h264"
|
|
338
|
+
}
|
|
339
|
+
HMSVideoCodec.VP9 -> {
|
|
340
|
+
"vp9"
|
|
341
|
+
}
|
|
342
|
+
HMSVideoCodec.VP8 -> {
|
|
343
|
+
"vp8"
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
fun getHmsVideoTrackCameraFacing(cameraFacing: HMSVideoTrackSettings.CameraFacing): String {
|
|
349
|
+
return when (cameraFacing) {
|
|
350
|
+
HMSVideoTrackSettings.CameraFacing.FRONT -> {
|
|
351
|
+
"FRONT"
|
|
352
|
+
}
|
|
353
|
+
HMSVideoTrackSettings.CameraFacing.BACK -> {
|
|
354
|
+
"BACK"
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
298
359
|
fun getHmsRemotePeers(remotePeers: Array<HMSRemotePeer>?): WritableArray {
|
|
299
360
|
val peers: WritableArray = Arguments.createArray()
|
|
300
361
|
if (remotePeers != null) {
|
|
@@ -315,10 +376,7 @@ object HmsDecoder {
|
|
|
315
376
|
"customerUserID",
|
|
316
377
|
if (hmsRemotePeer.customerUserID != null) hmsRemotePeer.customerUserID else ""
|
|
317
378
|
)
|
|
318
|
-
peer.putString(
|
|
319
|
-
"customerDescription",
|
|
320
|
-
if (hmsRemotePeer.customerDescription != null) hmsRemotePeer.customerDescription else ""
|
|
321
|
-
)
|
|
379
|
+
peer.putString("metadata", if (hmsRemotePeer.metadata != null) hmsRemotePeer.metadata else "")
|
|
322
380
|
peer.putMap("audioTrack", getHmsAudioTrack(hmsRemotePeer.audioTrack))
|
|
323
381
|
peer.putMap("videoTrack", getHmsVideoTrack(hmsRemotePeer.videoTrack))
|
|
324
382
|
peer.putMap("role", getHmsRole(hmsRemotePeer.hmsRole))
|
|
@@ -384,12 +442,14 @@ object HmsDecoder {
|
|
|
384
442
|
return hmsTracks
|
|
385
443
|
}
|
|
386
444
|
|
|
387
|
-
fun getHmsRoleChangeRequest(request: HMSRoleChangeRequest): WritableMap {
|
|
445
|
+
fun getHmsRoleChangeRequest(request: HMSRoleChangeRequest, id: String?): WritableMap {
|
|
388
446
|
val roleChangeRequest: WritableMap = Arguments.createMap()
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
447
|
+
if (id != null) {
|
|
448
|
+
roleChangeRequest.putMap("requestedBy", getHmsPeer(request.requestedBy))
|
|
449
|
+
roleChangeRequest.putMap("suggestedRole", getHmsRole(request.suggestedRole))
|
|
450
|
+
roleChangeRequest.putString("id", id)
|
|
451
|
+
return roleChangeRequest
|
|
452
|
+
}
|
|
393
453
|
return roleChangeRequest
|
|
394
454
|
}
|
|
395
455
|
|
|
@@ -401,4 +461,44 @@ object HmsDecoder {
|
|
|
401
461
|
|
|
402
462
|
return changeTrackStateRequest
|
|
403
463
|
}
|
|
464
|
+
|
|
465
|
+
fun getError(error: HMSException): WritableMap {
|
|
466
|
+
val decodedError: WritableMap = Arguments.createMap()
|
|
467
|
+
|
|
468
|
+
decodedError.putInt("code", error.code)
|
|
469
|
+
decodedError.putString("localizedDescription", error.localizedMessage)
|
|
470
|
+
decodedError.putString("description", error.description)
|
|
471
|
+
decodedError.putString("message", error.message)
|
|
472
|
+
decodedError.putString("name", error.name)
|
|
473
|
+
decodedError.putString("action", error.action)
|
|
474
|
+
|
|
475
|
+
return decodedError
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
fun getHMSBrowserRecordingState(data: HMSBrowserRecordingState?): ReadableMap {
|
|
479
|
+
val input = Arguments.createMap()
|
|
480
|
+
if (data !== null) {
|
|
481
|
+
input.putBoolean("running", data.running)
|
|
482
|
+
input.putMap("error", data.error?.let { this.getError(it) })
|
|
483
|
+
}
|
|
484
|
+
return input
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
fun getHMSRtmpStreamingState(data: HMSRtmpStreamingState?): ReadableMap {
|
|
488
|
+
val input = Arguments.createMap()
|
|
489
|
+
if (data !== null) {
|
|
490
|
+
input.putBoolean("running", data.running)
|
|
491
|
+
input.putMap("error", data.error?.let { this.getError(it) })
|
|
492
|
+
}
|
|
493
|
+
return input
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
fun getHMSServerRecordingState(data: HMSServerRecordingState?): ReadableMap {
|
|
497
|
+
val input = Arguments.createMap()
|
|
498
|
+
if (data !== null) {
|
|
499
|
+
input.putBoolean("running", data.running)
|
|
500
|
+
input.putMap("error", data.error?.let { this.getError(it) })
|
|
501
|
+
}
|
|
502
|
+
return input
|
|
503
|
+
}
|
|
404
504
|
}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
package com.reactnativehmssdk
|
|
2
2
|
|
|
3
|
+
import com.facebook.react.bridge.ReadableArray
|
|
3
4
|
import com.facebook.react.bridge.ReadableMap
|
|
5
|
+
import live.hms.video.media.codec.HMSAudioCodec
|
|
6
|
+
import live.hms.video.media.codec.HMSVideoCodec
|
|
7
|
+
import live.hms.video.media.settings.HMSAudioTrackSettings
|
|
8
|
+
import live.hms.video.media.settings.HMSVideoResolution
|
|
9
|
+
import live.hms.video.media.settings.HMSVideoTrackSettings
|
|
4
10
|
import live.hms.video.media.tracks.*
|
|
5
11
|
import live.hms.video.sdk.models.*
|
|
6
12
|
import live.hms.video.sdk.models.role.*
|
|
@@ -22,6 +28,11 @@ object HmsHelper {
|
|
|
22
28
|
return false
|
|
23
29
|
}
|
|
24
30
|
}
|
|
31
|
+
"Float" -> {
|
|
32
|
+
if (map.getDouble(key) == null) {
|
|
33
|
+
return false
|
|
34
|
+
}
|
|
35
|
+
}
|
|
25
36
|
"Boolean" -> {
|
|
26
37
|
if (map.getBoolean(key) == null) {
|
|
27
38
|
return false
|
|
@@ -101,7 +112,10 @@ object HmsHelper {
|
|
|
101
112
|
return null
|
|
102
113
|
}
|
|
103
114
|
|
|
104
|
-
fun getRemoteAudioTrackFromTrackId(
|
|
115
|
+
fun getRemoteAudioTrackFromTrackId(
|
|
116
|
+
trackId: String?,
|
|
117
|
+
remotePeers: Array<HMSRemotePeer>?
|
|
118
|
+
): HMSRemoteAudioTrack? {
|
|
105
119
|
if (trackId != null && remotePeers != null) {
|
|
106
120
|
for (remotePeer in remotePeers) {
|
|
107
121
|
if (remotePeer.audioTrack?.trackId == trackId) {
|
|
@@ -112,7 +126,10 @@ object HmsHelper {
|
|
|
112
126
|
return null
|
|
113
127
|
}
|
|
114
128
|
|
|
115
|
-
fun getRemoteVideoTrackFromTrackId(
|
|
129
|
+
fun getRemoteVideoTrackFromTrackId(
|
|
130
|
+
trackId: String?,
|
|
131
|
+
remotePeers: Array<HMSRemotePeer>?
|
|
132
|
+
): HMSRemoteVideoTrack? {
|
|
116
133
|
if (trackId != null && remotePeers != null) {
|
|
117
134
|
for (remotePeer in remotePeers) {
|
|
118
135
|
if (remotePeer.videoTrack?.trackId == trackId) {
|
|
@@ -156,4 +173,109 @@ object HmsHelper {
|
|
|
156
173
|
}
|
|
157
174
|
return null
|
|
158
175
|
}
|
|
176
|
+
|
|
177
|
+
fun getAudioTrackSettings(data: ReadableMap?): HMSAudioTrackSettings {
|
|
178
|
+
val builder = HMSAudioTrackSettings.Builder()
|
|
179
|
+
|
|
180
|
+
if (data != null) {
|
|
181
|
+
val maxBitrate = data.getInt("maxBitrate")
|
|
182
|
+
val codec = getAudioCodec(data.getString("codec"))
|
|
183
|
+
val trackDescription = data.getString("trackDescription")
|
|
184
|
+
|
|
185
|
+
builder.maxBitrate(maxBitrate)
|
|
186
|
+
builder.codec(codec)
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return builder.build()
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// TODO: find out a way to set settings required to create HMSVideTrackSettings
|
|
193
|
+
|
|
194
|
+
fun getVideoTrackSettings(data: ReadableMap?): HMSVideoTrackSettings {
|
|
195
|
+
val builder = HMSVideoTrackSettings.Builder()
|
|
196
|
+
if (data != null) {
|
|
197
|
+
val codec = getVideoCodec(data.getString("codec"))
|
|
198
|
+
val resolution = getVideoResolution(data.getMap("resolution"))
|
|
199
|
+
val maxBitrate = data.getInt("maxBitrate")
|
|
200
|
+
val maxFrameRate = data.getInt("maxFrameRate")
|
|
201
|
+
val cameraFacing = getCameraFacing(data.getString("cameraFacing"))
|
|
202
|
+
val trackDescription = data.getString("trackDescription")
|
|
203
|
+
|
|
204
|
+
builder.codec(codec)
|
|
205
|
+
builder.cameraFacing(cameraFacing)
|
|
206
|
+
if (resolution != null) {
|
|
207
|
+
builder.resolution(resolution)
|
|
208
|
+
}
|
|
209
|
+
builder.maxBitrate(maxBitrate)
|
|
210
|
+
builder.maxFrameRate(maxFrameRate)
|
|
211
|
+
}
|
|
212
|
+
return builder.build()
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
fun getVideoResolution(map: ReadableMap?): HMSVideoResolution? {
|
|
216
|
+
val width = map?.getDouble("width")
|
|
217
|
+
val height = map?.getDouble("height")
|
|
218
|
+
|
|
219
|
+
return if (width != null && height != null) {
|
|
220
|
+
HMSVideoResolution(width = width.toInt(), height = height.toInt())
|
|
221
|
+
} else {
|
|
222
|
+
null
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
fun getAudioCodec(codecString: String?): HMSAudioCodec {
|
|
227
|
+
when (codecString) {
|
|
228
|
+
"opus" -> {
|
|
229
|
+
return HMSAudioCodec.OPUS
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return HMSAudioCodec.OPUS
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
fun getVideoCodec(codecString: String?): HMSVideoCodec {
|
|
236
|
+
when (codecString) {
|
|
237
|
+
"h264" -> {
|
|
238
|
+
return HMSVideoCodec.H264
|
|
239
|
+
}
|
|
240
|
+
"vp8" -> {
|
|
241
|
+
return HMSVideoCodec.VP8
|
|
242
|
+
}
|
|
243
|
+
"vp9" -> {
|
|
244
|
+
return HMSVideoCodec.VP9
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return HMSVideoCodec.H264
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
fun getCameraFacing(cameraFacing: String?): HMSVideoTrackSettings.CameraFacing {
|
|
251
|
+
when (cameraFacing) {
|
|
252
|
+
"FRONT" -> {
|
|
253
|
+
return HMSVideoTrackSettings.CameraFacing.FRONT
|
|
254
|
+
}
|
|
255
|
+
"BACK" -> {
|
|
256
|
+
return HMSVideoTrackSettings.CameraFacing.BACK
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return HMSVideoTrackSettings.CameraFacing.FRONT
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
fun getHms(credentials: ReadableMap, hmsCollection: MutableMap<String, HmsSDK>): HmsSDK? {
|
|
263
|
+
val id = credentials.getString("id")
|
|
264
|
+
|
|
265
|
+
if (id != null) {
|
|
266
|
+
return hmsCollection[id]
|
|
267
|
+
} else {
|
|
268
|
+
return null
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
fun getRtmpUrls(rtmpURLsList: ReadableArray?): List<String> {
|
|
273
|
+
val rtmpURLs = mutableListOf<String>()
|
|
274
|
+
if (rtmpURLsList !== null) {
|
|
275
|
+
for (rtmpURL in rtmpURLsList.toArrayList()) {
|
|
276
|
+
rtmpURLs.add(rtmpURL as String)
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return rtmpURLs
|
|
280
|
+
}
|
|
159
281
|
}
|