@100mslive/react-native-hms 1.3.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -5
- package/android/build.gradle +3 -2
- package/android/src/main/java/com/reactnativehmssdk/HMSDecoder.kt +189 -55
- package/android/src/main/java/com/reactnativehmssdk/HMSHelper.kt +1 -0
- package/android/src/main/java/com/reactnativehmssdk/HMSManager.kt +49 -14
- package/android/src/main/java/com/reactnativehmssdk/HMSRNSDK.kt +240 -46
- package/android/src/main/java/com/reactnativehmssdk/HMSSDKViewManager.kt +5 -0
- package/android/src/main/java/com/reactnativehmssdk/HMSView.kt +29 -21
- package/android/src/main/res/layout/hms_view.xml +2 -2
- package/ios/HMSConstants.swift +31 -0
- package/ios/HMSDecoder.swift +371 -156
- package/ios/HMSManager.m +10 -2
- package/ios/HMSManager.swift +149 -74
- package/ios/HMSRNSDK.swift +431 -181
- package/ios/HMSView.m +1 -0
- package/ios/HMSView.swift +21 -19
- package/lib/commonjs/classes/HMSAudioTrackSettings.js +1 -1
- package/lib/commonjs/classes/HMSAudioTrackSettings.js.map +1 -1
- package/lib/commonjs/classes/HMSCameraControl.js +28 -0
- package/lib/commonjs/classes/HMSCameraControl.js.map +1 -0
- package/lib/commonjs/classes/HMSEncoder.js +95 -13
- package/lib/commonjs/classes/HMSEncoder.js.map +1 -1
- package/lib/commonjs/classes/HMSException.js +3 -4
- package/lib/commonjs/classes/HMSException.js.map +1 -1
- package/lib/commonjs/classes/HMSLayer.js +14 -0
- package/lib/commonjs/classes/HMSLayer.js.map +1 -0
- package/lib/commonjs/classes/HMSLocalVideoStats.js +11 -0
- package/lib/commonjs/classes/HMSLocalVideoStats.js.map +1 -1
- package/lib/commonjs/classes/HMSLocalVideoTrack.js +5 -6
- package/lib/commonjs/classes/HMSLocalVideoTrack.js.map +1 -1
- package/lib/commonjs/classes/HMSMessage.js +1 -2
- package/lib/commonjs/classes/HMSMessage.js.map +1 -1
- package/lib/commonjs/classes/HMSPeer.js +3 -4
- package/lib/commonjs/classes/HMSPeer.js.map +1 -1
- package/lib/commonjs/classes/HMSPublishSettings.js +2 -0
- package/lib/commonjs/classes/HMSPublishSettings.js.map +1 -1
- package/lib/commonjs/classes/HMSQualityLimitationReason.js +16 -0
- package/lib/commonjs/classes/HMSQualityLimitationReason.js.map +1 -0
- package/lib/commonjs/classes/HMSQualityLimitationReasons.js +27 -0
- package/lib/commonjs/classes/HMSQualityLimitationReasons.js.map +1 -0
- package/lib/commonjs/classes/HMSRemotePeer.js.map +1 -1
- package/lib/commonjs/classes/HMSRemoteVideoTrack.js +39 -4
- package/lib/commonjs/classes/HMSRemoteVideoTrack.js.map +1 -1
- package/lib/commonjs/classes/HMSRoom.js +4 -0
- package/lib/commonjs/classes/HMSRoom.js.map +1 -1
- package/lib/commonjs/classes/HMSRoomUpdate.js +1 -0
- package/lib/commonjs/classes/HMSRoomUpdate.js.map +1 -1
- package/lib/commonjs/classes/HMSSDK.js +70 -62
- package/lib/commonjs/classes/HMSSDK.js.map +1 -1
- package/lib/commonjs/classes/HMSSimulcastLayerDefinition.js +19 -0
- package/lib/commonjs/classes/HMSSimulcastLayerDefinition.js.map +1 -0
- package/lib/commonjs/classes/HMSSimulcastLayerSettingsPolicy.js +23 -0
- package/lib/commonjs/classes/HMSSimulcastLayerSettingsPolicy.js.map +1 -0
- package/lib/commonjs/classes/HMSSimulcastSettings.js +5 -4
- package/lib/commonjs/classes/HMSSimulcastSettings.js.map +1 -1
- package/lib/commonjs/classes/HMSSimulcastSettingsPolicy.js +17 -0
- package/lib/commonjs/classes/HMSSimulcastSettingsPolicy.js.map +1 -0
- package/lib/commonjs/classes/HMSSubscribeDegradationPolicy.js +21 -0
- package/lib/commonjs/classes/HMSSubscribeDegradationPolicy.js.map +1 -0
- package/lib/commonjs/classes/HMSSubscribeSettings.js +2 -0
- package/lib/commonjs/classes/HMSSubscribeSettings.js.map +1 -1
- package/lib/commonjs/classes/HMSVideoResolution.js.map +1 -1
- package/lib/commonjs/classes/HMSVideoTrackSettings.js +1 -1
- package/lib/commonjs/classes/HMSVideoTrackSettings.js.map +1 -1
- package/lib/commonjs/classes/HmsView.js +2 -0
- package/lib/commonjs/classes/HmsView.js.map +1 -1
- package/lib/commonjs/index.js +60 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/classes/HMSAudioTrackSettings.js +1 -1
- package/lib/module/classes/HMSAudioTrackSettings.js.map +1 -1
- package/lib/module/classes/HMSCameraControl.js +21 -0
- package/lib/module/classes/HMSCameraControl.js.map +1 -0
- package/lib/module/classes/HMSEncoder.js +95 -13
- package/lib/module/classes/HMSEncoder.js.map +1 -1
- package/lib/module/classes/HMSException.js +3 -4
- package/lib/module/classes/HMSException.js.map +1 -1
- package/lib/module/classes/HMSLayer.js +7 -0
- package/lib/module/classes/HMSLayer.js.map +1 -0
- package/lib/module/classes/HMSLocalVideoStats.js +11 -0
- package/lib/module/classes/HMSLocalVideoStats.js.map +1 -1
- package/lib/module/classes/HMSLocalVideoTrack.js +5 -6
- package/lib/module/classes/HMSLocalVideoTrack.js.map +1 -1
- package/lib/module/classes/HMSMessage.js +1 -2
- package/lib/module/classes/HMSMessage.js.map +1 -1
- package/lib/module/classes/HMSPeer.js +3 -4
- package/lib/module/classes/HMSPeer.js.map +1 -1
- package/lib/module/classes/HMSPublishSettings.js +2 -0
- package/lib/module/classes/HMSPublishSettings.js.map +1 -1
- package/lib/module/classes/HMSQualityLimitationReason.js +9 -0
- package/lib/module/classes/HMSQualityLimitationReason.js.map +1 -0
- package/lib/module/classes/HMSQualityLimitationReasons.js +20 -0
- package/lib/module/classes/HMSQualityLimitationReasons.js.map +1 -0
- package/lib/module/classes/HMSRemotePeer.js.map +1 -1
- package/lib/module/classes/HMSRemoteVideoTrack.js +39 -4
- package/lib/module/classes/HMSRemoteVideoTrack.js.map +1 -1
- package/lib/module/classes/HMSRoom.js +4 -0
- package/lib/module/classes/HMSRoom.js.map +1 -1
- package/lib/module/classes/HMSRoomUpdate.js +1 -0
- package/lib/module/classes/HMSRoomUpdate.js.map +1 -1
- package/lib/module/classes/HMSSDK.js +71 -62
- package/lib/module/classes/HMSSDK.js.map +1 -1
- package/lib/module/classes/HMSSimulcastLayerDefinition.js +12 -0
- package/lib/module/classes/HMSSimulcastLayerDefinition.js.map +1 -0
- package/lib/module/classes/HMSSimulcastLayerSettingsPolicy.js +16 -0
- package/lib/module/classes/HMSSimulcastLayerSettingsPolicy.js.map +1 -0
- package/lib/module/classes/HMSSimulcastSettings.js +5 -4
- package/lib/module/classes/HMSSimulcastSettings.js.map +1 -1
- package/lib/module/classes/HMSSimulcastSettingsPolicy.js +10 -0
- package/lib/module/classes/HMSSimulcastSettingsPolicy.js.map +1 -0
- package/lib/module/classes/HMSSubscribeDegradationPolicy.js +14 -0
- package/lib/module/classes/HMSSubscribeDegradationPolicy.js.map +1 -0
- package/lib/module/classes/HMSSubscribeSettings.js +2 -0
- package/lib/module/classes/HMSSubscribeSettings.js.map +1 -1
- package/lib/module/classes/HMSVideoResolution.js.map +1 -1
- package/lib/module/classes/HMSVideoTrackSettings.js +1 -1
- package/lib/module/classes/HMSVideoTrackSettings.js.map +1 -1
- package/lib/module/classes/HmsView.js +2 -0
- package/lib/module/classes/HmsView.js.map +1 -1
- package/lib/module/index.js +5 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/classes/HMSCameraControl.d.ts +9 -0
- package/lib/typescript/classes/HMSEncoder.d.ts +13 -1
- package/lib/typescript/classes/HMSLayer.d.ts +5 -0
- package/lib/typescript/classes/HMSLocalVideoStats.d.ts +6 -0
- package/lib/typescript/classes/HMSPeer.d.ts +1 -1
- package/lib/typescript/classes/HMSPublishSettings.d.ts +3 -0
- package/lib/typescript/classes/HMSQualityLimitationReason.d.ts +7 -0
- package/lib/typescript/classes/HMSQualityLimitationReasons.d.ts +17 -0
- package/lib/typescript/classes/HMSRemotePeer.d.ts +0 -1
- package/lib/typescript/classes/HMSRemoteVideoTrack.d.ts +6 -2
- package/lib/typescript/classes/HMSRoomUpdate.d.ts +2 -1
- package/lib/typescript/classes/HMSSDK.d.ts +24 -42
- package/lib/typescript/classes/HMSSimulcastLayerDefinition.d.ts +10 -0
- package/lib/typescript/classes/HMSSimulcastLayerSettingsPolicy.d.ts +12 -0
- package/lib/typescript/classes/HMSSimulcastSettings.d.ts +7 -3
- package/lib/typescript/classes/HMSSimulcastSettingsPolicy.d.ts +7 -0
- package/lib/typescript/classes/HMSSubscribeDegradationPolicy.d.ts +10 -0
- package/lib/typescript/classes/HMSSubscribeSettings.d.ts +5 -2
- package/lib/typescript/classes/HMSVideoResolution.d.ts +2 -2
- package/lib/typescript/classes/HmsView.d.ts +2 -2
- package/lib/typescript/index.d.ts +5 -0
- package/package.json +2 -2
- package/sdk-versions.json +3 -3
- package/src/classes/HMSCameraControl.ts +21 -0
- package/src/classes/HMSEncoder.ts +125 -11
- package/src/classes/HMSLayer.ts +5 -0
- package/src/classes/HMSLocalVideoStats.ts +21 -0
- package/src/classes/HMSPeer.ts +1 -1
- package/src/classes/HMSPublishSettings.ts +4 -0
- package/src/classes/HMSQualityLimitationReason.ts +7 -0
- package/src/classes/HMSQualityLimitationReasons.ts +27 -0
- package/src/classes/HMSRemotePeer.ts +0 -1
- package/src/classes/HMSRemoteVideoTrack.ts +52 -4
- package/src/classes/HMSRoom.ts +2 -0
- package/src/classes/HMSRoomUpdate.ts +1 -0
- package/src/classes/HMSSDK.tsx +99 -67
- package/src/classes/HMSSimulcastLayerDefinition.ts +12 -0
- package/src/classes/HMSSimulcastLayerSettingsPolicy.ts +18 -0
- package/src/classes/HMSSimulcastSettings.ts +12 -3
- package/src/classes/HMSSimulcastSettingsPolicy.ts +9 -0
- package/src/classes/HMSSubscribeDegradationPolicy.ts +15 -0
- package/src/classes/HMSSubscribeSettings.ts +10 -2
- package/src/classes/HMSVideoResolution.ts +1 -1
- package/src/classes/HmsView.tsx +5 -1
- package/src/index.ts +5 -0
package/README.md
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
<a href="https://100ms.live/">
|
|
2
|
-
<img src="https://
|
|
3
|
-
<img src="https://github.com/100mslive/100ms-react-native/blob/main/100ms.svg" title="100ms logo" float=center height=256>
|
|
2
|
+
<img src="https://raw.githubusercontent.com/100mslive/react-native-hms/main/100ms.svg" title="100ms logo" float=center height=256>
|
|
4
3
|
</a>
|
|
5
4
|
|
|
6
5
|
[](https://www.npmjs.com/package/@100mslive/react-native-hms)
|
|
@@ -17,6 +16,11 @@
|
|
|
17
16
|
|
|
18
17
|
# 100ms React Native SDK
|
|
19
18
|
|
|
19
|
+
Integrate Real Time Audio and Video conferencing, Interactive Live Streaming, and Chat in your apps with 100ms React Native SDK.
|
|
20
|
+
|
|
21
|
+
With support for HLS and RTMP Live Streaming and Recording, Picture-in-Picture (PiP), one-to-one Video Call Modes, Audio Rooms, Video Player and much more, add immersive real-time communications to your apps.
|
|
22
|
+
|
|
23
|
+
|
|
20
24
|
📖 Read the Complete Documentation here: https://www.100ms.live/docs/react-native/v2/foundation/basics
|
|
21
25
|
|
|
22
26
|
## 🏃 Example App
|
|
@@ -120,17 +124,65 @@ More information about Audio Video Permission on iOS & Android is [available her
|
|
|
120
124
|
|
|
121
125
|
The package exports all the classes and a HMSSDK class that manages everything.
|
|
122
126
|
|
|
123
|
-
## Setting up the HMS Instance
|
|
127
|
+
## [Setting up the HMS Instance](https://www.100ms.live/docs/react-native/v2/how--to-guides/install-the-sdk/hmssdk)
|
|
124
128
|
|
|
125
129
|
First invoke the `build` method which returns an instance of `HMSSDK`. Save this instance to perform all actions related to 100ms.
|
|
126
130
|
|
|
127
131
|
```ts
|
|
128
132
|
import { HMSSDK } from '@100mslive/react-native-hms';
|
|
129
133
|
|
|
130
|
-
|
|
134
|
+
/**
|
|
135
|
+
* create HMSSDK instance using the build method & save it for further usage
|
|
136
|
+
*
|
|
137
|
+
* Important Note: Don't build new `HMSSDK` instance before destroying the previous one.
|
|
138
|
+
* for more info checkout {@link https://www.100ms.live/docs/react-native/v2/how--to-guides/install-the-sdk/hmssdk#what-does-destroy-method-do}
|
|
139
|
+
*/
|
|
131
140
|
const hmsInstance = await HMSSDK.build();
|
|
132
141
|
```
|
|
133
142
|
|
|
143
|
+
## [Get Authentication Token](https://www.100ms.live/docs/react-native/v2/get-started/quickstart#fetch-token-to-join-the-room)
|
|
144
|
+
|
|
145
|
+
### Fetch token using room-code method (Recommended)
|
|
146
|
+
|
|
147
|
+
We can get the authentication token using room-code from meeting URL.
|
|
148
|
+
|
|
149
|
+
Let's understand the subdomain and code from the sample URL
|
|
150
|
+
|
|
151
|
+
In this sample url: `http://100ms-rocks.app.100ms.live/meeting/abc-defg-hij`
|
|
152
|
+
- Subdomain is `100ms-rocks`
|
|
153
|
+
- Room code is `abc-defg-hij`
|
|
154
|
+
|
|
155
|
+
Now to get the room-code from meeting URL, we can write our own logic or use the `getCode` method from [here](https://github.com/100mslive/react-native-hms/blob/main/example/src/utils/getRoomLinkDetails.ts)
|
|
156
|
+
|
|
157
|
+
To generate token we will be using `getAuthTokenByRoomCode` method available on `HMSSDK` instance. This method has `roomCode` as a required
|
|
158
|
+
parameter and `userId` & `endpoint` as optional parameter.
|
|
159
|
+
|
|
160
|
+
Let's checkout the implementation:
|
|
161
|
+
|
|
162
|
+
```js
|
|
163
|
+
/**
|
|
164
|
+
* `getAuthTokenByRoomCode` returns a promise which is resolved with "auth token"
|
|
165
|
+
* checkout {@link https://www.100ms.live/docs/react-native/v2/how--to-guides/install-the-sdk/hmssdk#what-does-destroy-method-do}
|
|
166
|
+
*/
|
|
167
|
+
const token = await hmsInstance.getAuthTokenByRoomCode('YOUR_ROOM_CODE');
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Create `HMSConfig` with the above auth token and username
|
|
171
|
+
*/
|
|
172
|
+
const hmsConfig = new HMSConfig({ authToken: token, username: 'John Appleseed' });
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Get temporary token from dashboard
|
|
176
|
+
|
|
177
|
+
To test audio/video functionality, you need to connect to a 100ms Room. Please check the following steps for the same -
|
|
178
|
+
|
|
179
|
+
1. Navigate to your [100ms dashboard](https://dashboard.100ms.live/dashboard) or [create an account](https://dashboard.100ms.live/register) if you don't have one.
|
|
180
|
+
2. Use the `Video Conferencing Starter Kit` to create a room with a default template assigned to it to test this app quickly.
|
|
181
|
+
3. Go to the [Rooms page](https://dashboard.100ms.live/rooms) in your dashboard, click on the `Room Id` of the room you created above, and click on the `Join Room` button on the top right.
|
|
182
|
+
4. You will see 100ms demo URLs for the roles created when you deployed the starter kit; you can click on the 'key' icon to copy the token and update the `AUTH_TOKEN` variable in "App.js" file.
|
|
183
|
+
> Token from 100ms dashboard is for testing purposes only, For production applications you must generate tokens on your own server. Refer to the [Management Token section](/concepts/v2/concepts/security-and-tokens#management-token) in Authentication and Tokens guide for more information.
|
|
184
|
+
|
|
185
|
+
|
|
134
186
|
## [Add Event Listeners](https://www.100ms.live/docs/react-native/v2/features/event-listeners)
|
|
135
187
|
|
|
136
188
|
Add Event Listeners to get notified about actions happening in the 100ms Room.
|
|
@@ -175,6 +227,8 @@ NOTE: `ON_JOIN` Event Listener must be **attached** before calling `join` functi
|
|
|
175
227
|
// create HMSSDK instance using the build function
|
|
176
228
|
const hmsInstance = await HMSSDK.build();
|
|
177
229
|
|
|
230
|
+
// Generate 100ms Auth Token by Room Code
|
|
231
|
+
const token = await hmsInstance.getAuthTokenByRoomCode('abc-defg-hij'); // Sample Room Code
|
|
178
232
|
|
|
179
233
|
// You'll need to add Event Listeners for HMSUpdateListenerActions, which are invoked to notify about updates happening in the room like a peer joins/leaves, a track got muted/unmuted, any errors that occur, etc.
|
|
180
234
|
hmsInstance.addEventListener(HMSUpdateListenerActions.ON_JOIN, onJoinSuccess);
|
|
@@ -185,7 +239,7 @@ hmsInstance.addEventListener(HMSUpdateListenerActions.ON_ERROR, onError);
|
|
|
185
239
|
|
|
186
240
|
// Next, create an object of HMSConfig class using the available joining configurations.
|
|
187
241
|
let config = new HMSConfig({
|
|
188
|
-
authToken:
|
|
242
|
+
authToken: token, // client-side token generated by `getAuthTokenByRoomCode` method
|
|
189
243
|
username: 'John Appleseed',
|
|
190
244
|
});
|
|
191
245
|
|
package/android/build.gradle
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import groovy.json.JsonSlurper
|
|
2
2
|
|
|
3
|
-
def
|
|
3
|
+
def sdkVersions = new JsonSlurper().parse file("../sdk-versions.json")
|
|
4
4
|
|
|
5
5
|
buildscript {
|
|
6
6
|
ext.kotlin_version = '1.5.30-RC'
|
|
@@ -69,7 +69,8 @@ dependencies {
|
|
|
69
69
|
//noinspection GradleDynamicVersion
|
|
70
70
|
implementation "com.facebook.react:react-native:+"
|
|
71
71
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" // From node_modules
|
|
72
|
-
implementation "live.100ms:android-sdk:${
|
|
72
|
+
implementation "live.100ms:android-sdk:${sdkVersions["android"]}"
|
|
73
|
+
implementation "live.100ms:video-view:${sdkVersions["android"]}"
|
|
73
74
|
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.0'
|
|
74
75
|
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
|
|
75
76
|
implementation 'androidx.appcompat:appcompat:1.3.1'
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
package com.reactnativehmssdk
|
|
2
2
|
|
|
3
3
|
import com.facebook.react.bridge.*
|
|
4
|
+
import live.hms.video.connection.degredation.QualityLimitationReasons
|
|
4
5
|
import live.hms.video.connection.stats.*
|
|
5
6
|
import live.hms.video.connection.stats.quality.HMSNetworkQuality
|
|
6
7
|
import live.hms.video.error.HMSException
|
|
7
|
-
import live.hms.video.media.settings
|
|
8
|
-
import live.hms.video.media.settings.HMSVideoResolution
|
|
9
|
-
import live.hms.video.media.settings.HMSVideoTrackSettings
|
|
8
|
+
import live.hms.video.media.settings.*
|
|
10
9
|
import live.hms.video.media.tracks.*
|
|
11
10
|
import live.hms.video.sdk.models.*
|
|
12
11
|
import live.hms.video.sdk.models.enums.HMSPeerUpdate
|
|
@@ -77,12 +76,14 @@ object HMSDecoder {
|
|
|
77
76
|
val room: WritableMap = Arguments.createMap()
|
|
78
77
|
if (hmsRoom != null) {
|
|
79
78
|
room.putString("id", hmsRoom.roomId)
|
|
80
|
-
|
|
79
|
+
hmsRoom.sessionId?.let {
|
|
80
|
+
room.putString("sessionId", it)
|
|
81
|
+
}
|
|
81
82
|
room.putString("name", hmsRoom.name)
|
|
82
83
|
room.putString("metaData", null)
|
|
83
|
-
hmsRoom.startedAt?.let {
|
|
84
|
-
|
|
85
|
-
}
|
|
84
|
+
// hmsRoom.startedAt?.let {
|
|
85
|
+
// room.putString("startedAt", it.toString())
|
|
86
|
+
// }
|
|
86
87
|
|
|
87
88
|
hmsRoom.browserRecordingState?.let {
|
|
88
89
|
room.putMap(
|
|
@@ -113,7 +114,9 @@ object HMSDecoder {
|
|
|
113
114
|
room.putMap("hlsRecordingState", this.getHMSHlsRecordingState(hmsRoom.hlsRecordingState))
|
|
114
115
|
}
|
|
115
116
|
|
|
116
|
-
|
|
117
|
+
hmsRoom.localPeer?.let {
|
|
118
|
+
room.putMap("localPeer", this.getHmsLocalPeer(it))
|
|
119
|
+
}
|
|
117
120
|
|
|
118
121
|
room.putArray("peers", this.getAllPeers(hmsRoom.peerList))
|
|
119
122
|
|
|
@@ -309,6 +312,10 @@ object HMSDecoder {
|
|
|
309
312
|
publishSettings.putMap("screen", this.getHmsVideoSettings(it))
|
|
310
313
|
}
|
|
311
314
|
|
|
315
|
+
hmsPublishSettings.simulcast?.let {
|
|
316
|
+
publishSettings.putMap("simulcast", this.getHmsSimulcastSettings(it))
|
|
317
|
+
}
|
|
318
|
+
|
|
312
319
|
publishSettings.putArray("allowed", this.getWriteableArray(hmsPublishSettings.allowed))
|
|
313
320
|
}
|
|
314
321
|
return publishSettings
|
|
@@ -345,6 +352,50 @@ object HMSDecoder {
|
|
|
345
352
|
return videoSettings
|
|
346
353
|
}
|
|
347
354
|
|
|
355
|
+
private fun getHmsSimulcastSettings(hmsSimulcastSettings: Simulcast?): WritableMap {
|
|
356
|
+
val simulcastSettings: WritableMap = Arguments.createMap()
|
|
357
|
+
if (hmsSimulcastSettings != null) {
|
|
358
|
+
hmsSimulcastSettings.video?.let {
|
|
359
|
+
simulcastSettings.putMap("video", getHmsVideoSimulcastLayersParams(it))
|
|
360
|
+
}
|
|
361
|
+
hmsSimulcastSettings.screen?.let {
|
|
362
|
+
simulcastSettings.putMap("screen", getHmsVideoSimulcastLayersParams(it))
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
return simulcastSettings
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
private fun getHmsVideoSimulcastLayersParams(hmsVideoSimulcastLayersParams: VideoSimulcastLayersParams?): WritableMap {
|
|
369
|
+
val videoSimulcastLayersParams: WritableMap = Arguments.createMap()
|
|
370
|
+
if (hmsVideoSimulcastLayersParams != null) {
|
|
371
|
+
hmsVideoSimulcastLayersParams.layers?.let {
|
|
372
|
+
val layersParams = Arguments.createArray()
|
|
373
|
+
it.forEach { layer -> layersParams.pushMap(getHmsLayerParams(layer)) }
|
|
374
|
+
videoSimulcastLayersParams.putArray("layers", layersParams)
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
return videoSimulcastLayersParams
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
private fun getHmsLayerParams(hmsLayerParams: LayerParams?): WritableMap {
|
|
381
|
+
val layerParams: WritableMap = Arguments.createMap()
|
|
382
|
+
if (hmsLayerParams != null) {
|
|
383
|
+
hmsLayerParams.rid?.let {
|
|
384
|
+
layerParams.putString("rid", it)
|
|
385
|
+
}
|
|
386
|
+
hmsLayerParams.maxBitrate?.let {
|
|
387
|
+
layerParams.putInt("maxBitrate", it)
|
|
388
|
+
}
|
|
389
|
+
hmsLayerParams.scaleResolutionDownBy?.let {
|
|
390
|
+
layerParams.putDouble("scaleResolutionDownBy", it.toDouble())
|
|
391
|
+
}
|
|
392
|
+
hmsLayerParams.maxFramerate?.let {
|
|
393
|
+
layerParams.putInt("maxFramerate", it)
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
return layerParams
|
|
397
|
+
}
|
|
398
|
+
|
|
348
399
|
fun getHmsLocalPeer(hmsLocalPeer: HMSLocalPeer?): WritableMap {
|
|
349
400
|
val peer: WritableMap = Arguments.createMap()
|
|
350
401
|
if (hmsLocalPeer != null) {
|
|
@@ -412,10 +463,11 @@ object HMSDecoder {
|
|
|
412
463
|
return settings
|
|
413
464
|
}
|
|
414
465
|
|
|
415
|
-
private fun getHmsVideoTrackResolution(hmsResolution: HMSVideoResolution):
|
|
416
|
-
val resolution:
|
|
417
|
-
resolution.
|
|
418
|
-
resolution.
|
|
466
|
+
private fun getHmsVideoTrackResolution(hmsResolution: HMSVideoResolution): WritableArray {
|
|
467
|
+
val resolution: WritableArray = Arguments.createArray() // [width, height]
|
|
468
|
+
resolution.pushInt(hmsResolution.width)
|
|
469
|
+
resolution.pushInt(hmsResolution.height)
|
|
470
|
+
|
|
419
471
|
return resolution
|
|
420
472
|
}
|
|
421
473
|
|
|
@@ -630,6 +682,11 @@ object HMSDecoder {
|
|
|
630
682
|
val subscribeSettings: WritableMap = Arguments.createMap()
|
|
631
683
|
if (hmsSubscribeSettings != null) {
|
|
632
684
|
subscribeSettings.putInt("maxSubsBitRate", hmsSubscribeSettings.maxSubsBitRate)
|
|
685
|
+
|
|
686
|
+
hmsSubscribeSettings.subscribeDegradationParam?.let {
|
|
687
|
+
subscribeSettings.putMap("subscribeDegradation", this.getHmsSubscribeDegradationSettings(it))
|
|
688
|
+
}
|
|
689
|
+
|
|
633
690
|
subscribeSettings.putArray(
|
|
634
691
|
"subscribeTo",
|
|
635
692
|
this.getWriteableArray(hmsSubscribeSettings.subscribeTo)
|
|
@@ -702,26 +759,32 @@ object HMSDecoder {
|
|
|
702
759
|
return hmsNetworkQuality
|
|
703
760
|
}
|
|
704
761
|
|
|
705
|
-
fun getHMSRTCStats(hmsRtcStats: HMSRTCStats?):
|
|
706
|
-
val rtcStats:
|
|
762
|
+
fun getHMSRTCStats(hmsRtcStats: HMSRTCStats?): WritableArray {
|
|
763
|
+
val rtcStats: WritableArray = Arguments.createArray() // [bitrateReceived, bitrateSent, bytesReceived, bytesSent, packetsLost, packetsReceived, roundTripTime]
|
|
707
764
|
if (hmsRtcStats != null) {
|
|
708
|
-
rtcStats.
|
|
709
|
-
rtcStats.
|
|
710
|
-
rtcStats.
|
|
711
|
-
rtcStats.
|
|
712
|
-
rtcStats.
|
|
713
|
-
rtcStats.
|
|
714
|
-
rtcStats.
|
|
765
|
+
rtcStats.pushDouble(hmsRtcStats.bitrateReceived)
|
|
766
|
+
rtcStats.pushDouble(hmsRtcStats.bitrateSent)
|
|
767
|
+
rtcStats.pushString(hmsRtcStats.bytesReceived.toString())
|
|
768
|
+
rtcStats.pushString(hmsRtcStats.bytesSent.toString())
|
|
769
|
+
rtcStats.pushString(hmsRtcStats.packetsLost.toString())
|
|
770
|
+
rtcStats.pushString(hmsRtcStats.packetsReceived.toString())
|
|
771
|
+
rtcStats.pushDouble(hmsRtcStats.roundTripTime)
|
|
715
772
|
}
|
|
716
773
|
return rtcStats
|
|
717
774
|
}
|
|
718
775
|
|
|
719
|
-
fun getLocalAudioStats(hmsLocalAudioStats: HMSLocalAudioStats?):
|
|
720
|
-
val localAudioStats:
|
|
776
|
+
fun getLocalAudioStats(hmsLocalAudioStats: HMSLocalAudioStats?): WritableArray {
|
|
777
|
+
val localAudioStats: WritableArray = Arguments.createArray()
|
|
778
|
+
|
|
721
779
|
if (hmsLocalAudioStats != null) {
|
|
722
|
-
|
|
723
|
-
localAudioStats.
|
|
724
|
-
|
|
780
|
+
val bitrate = hmsLocalAudioStats.bitrate ?: -1.0
|
|
781
|
+
localAudioStats.pushDouble(bitrate)
|
|
782
|
+
|
|
783
|
+
val bytesSent = hmsLocalAudioStats.bytesSent.let { if (it === null) "" else it.toString() }
|
|
784
|
+
localAudioStats.pushString(bytesSent)
|
|
785
|
+
|
|
786
|
+
val roundTripTime = hmsLocalAudioStats.roundTripTime ?: -1.0
|
|
787
|
+
localAudioStats.pushDouble(roundTripTime)
|
|
725
788
|
}
|
|
726
789
|
return localAudioStats
|
|
727
790
|
}
|
|
@@ -730,48 +793,119 @@ object HMSDecoder {
|
|
|
730
793
|
val stats: WritableArray = Arguments.createArray()
|
|
731
794
|
|
|
732
795
|
for (stat in hmsLocalVideoStats) {
|
|
733
|
-
val localVideoStats:
|
|
796
|
+
val localVideoStats: WritableArray = Arguments.createArray() // [bitrate, bytesSent, roundTripTime, frameRate, resolution, layer, qualityLimitationReasons]
|
|
734
797
|
|
|
735
|
-
|
|
736
|
-
localVideoStats.
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
)
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
798
|
+
val bitrate = stat.bitrate ?: -1.0
|
|
799
|
+
localVideoStats.pushDouble(bitrate)
|
|
800
|
+
|
|
801
|
+
val bytesSent = stat.bytesSent.let { if (it === null) "" else it.toString() }
|
|
802
|
+
localVideoStats.pushString(bytesSent)
|
|
803
|
+
|
|
804
|
+
val roundTripTime = stat.roundTripTime ?: -1.0
|
|
805
|
+
localVideoStats.pushDouble(roundTripTime)
|
|
806
|
+
|
|
807
|
+
val frameRate = stat.frameRate ?: -1.0
|
|
808
|
+
localVideoStats.pushDouble(frameRate)
|
|
809
|
+
|
|
810
|
+
stat.resolution.let {
|
|
811
|
+
if (it === null) {
|
|
812
|
+
localVideoStats.pushNull()
|
|
813
|
+
} else {
|
|
814
|
+
localVideoStats.pushArray(getHmsVideoTrackResolution(it)) // [width, height]
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
val layer = stat.hmsLayer.let { if (it === null) HMSLayer.HIGH.name else it.name }
|
|
819
|
+
localVideoStats.pushString(layer)
|
|
820
|
+
|
|
821
|
+
val qualityLimitationReasons = getHmsQualityLimitationReasons(stat.qualityLimitationReason)
|
|
822
|
+
localVideoStats.pushMap(qualityLimitationReasons)
|
|
823
|
+
|
|
824
|
+
stats.pushArray(localVideoStats)
|
|
744
825
|
}
|
|
745
826
|
|
|
746
827
|
return stats
|
|
747
828
|
}
|
|
748
829
|
|
|
749
|
-
fun
|
|
750
|
-
val
|
|
830
|
+
private fun getHmsQualityLimitationReasons(hmsQualityLimitationReasons: QualityLimitationReasons?): WritableMap {
|
|
831
|
+
val qualityLimitationReasons: WritableMap = Arguments.createMap()
|
|
832
|
+
|
|
833
|
+
if (hmsQualityLimitationReasons != null) {
|
|
834
|
+
hmsQualityLimitationReasons.bandWidth?.let { qualityLimitationReasons.putDouble("bandwidth", it) }
|
|
835
|
+
hmsQualityLimitationReasons.cpu?.let { qualityLimitationReasons.putDouble("cpu", it) }
|
|
836
|
+
hmsQualityLimitationReasons.none?.let { qualityLimitationReasons.putDouble("none", it) }
|
|
837
|
+
hmsQualityLimitationReasons.other?.let { qualityLimitationReasons.putDouble("other", it) }
|
|
838
|
+
hmsQualityLimitationReasons.qualityLimitationResolutionChanges?.let { qualityLimitationReasons.putInt("qualityLimitationResolutionChanges", it.toInt()) }
|
|
839
|
+
qualityLimitationReasons.putString("reason", hmsQualityLimitationReasons.reason.name)
|
|
840
|
+
}
|
|
841
|
+
return qualityLimitationReasons
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
fun getRemoteAudioStats(hmsRemoteAudioStats: HMSRemoteAudioStats?): WritableArray {
|
|
845
|
+
val remoteAudioStats: WritableArray = Arguments.createArray()
|
|
846
|
+
|
|
751
847
|
if (hmsRemoteAudioStats != null) {
|
|
752
|
-
|
|
753
|
-
remoteAudioStats.
|
|
754
|
-
|
|
755
|
-
hmsRemoteAudioStats.
|
|
756
|
-
remoteAudioStats.
|
|
848
|
+
val bitrate = hmsRemoteAudioStats.bitrate ?: -1.0
|
|
849
|
+
remoteAudioStats.pushDouble(bitrate)
|
|
850
|
+
|
|
851
|
+
val bytesReceived = hmsRemoteAudioStats.bytesReceived.let { if (it === null) "" else it.toString() }
|
|
852
|
+
remoteAudioStats.pushString(bytesReceived)
|
|
853
|
+
|
|
854
|
+
val jitter = hmsRemoteAudioStats.jitter ?: -1.0
|
|
855
|
+
remoteAudioStats.pushDouble(jitter)
|
|
856
|
+
|
|
857
|
+
val packetsLost = hmsRemoteAudioStats.packetsLost ?: -1
|
|
858
|
+
remoteAudioStats.pushInt(packetsLost)
|
|
859
|
+
|
|
860
|
+
val packetsReceived = hmsRemoteAudioStats.packetsReceived.let { if (it === null) "" else it.toString() }
|
|
861
|
+
remoteAudioStats.pushString(packetsReceived)
|
|
757
862
|
}
|
|
758
863
|
return remoteAudioStats
|
|
759
864
|
}
|
|
760
865
|
|
|
761
|
-
fun getRemoteVideoStats(hmsRemoteVideoStats: HMSRemoteVideoStats?):
|
|
762
|
-
val remoteVideoStats:
|
|
866
|
+
fun getRemoteVideoStats(hmsRemoteVideoStats: HMSRemoteVideoStats?): WritableArray {
|
|
867
|
+
val remoteVideoStats: WritableArray = Arguments.createArray() // [bitrate, bytesReceived, frameRate, jitter, packetsLost, packetsReceived, resolution]
|
|
868
|
+
|
|
763
869
|
if (hmsRemoteVideoStats != null) {
|
|
764
|
-
|
|
765
|
-
remoteVideoStats.
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
hmsRemoteVideoStats.
|
|
870
|
+
val bitrate = hmsRemoteVideoStats.bitrate ?: -1.0
|
|
871
|
+
remoteVideoStats.pushDouble(bitrate)
|
|
872
|
+
|
|
873
|
+
val bytesReceived = hmsRemoteVideoStats.bytesReceived.let { if (it === null) "" else it.toString() }
|
|
874
|
+
remoteVideoStats.pushString(bytesReceived)
|
|
875
|
+
|
|
876
|
+
val frameRate = hmsRemoteVideoStats.frameRate ?: -1.0
|
|
877
|
+
remoteVideoStats.pushDouble(frameRate)
|
|
878
|
+
|
|
879
|
+
val jitter = hmsRemoteVideoStats.jitter ?: -1.0
|
|
880
|
+
remoteVideoStats.pushDouble(jitter)
|
|
881
|
+
|
|
882
|
+
val packetsLost = hmsRemoteVideoStats.packetsLost ?: -1
|
|
883
|
+
remoteVideoStats.pushInt(packetsLost)
|
|
884
|
+
|
|
885
|
+
val packetsReceived = hmsRemoteVideoStats.packetsReceived.let { if (it === null) "" else it.toString() }
|
|
886
|
+
remoteVideoStats.pushString(packetsReceived)
|
|
887
|
+
|
|
888
|
+
hmsRemoteVideoStats.resolution.let {
|
|
889
|
+
if (it === null) {
|
|
890
|
+
remoteVideoStats.pushNull()
|
|
891
|
+
} else {
|
|
892
|
+
remoteVideoStats.pushArray(getHmsVideoTrackResolution(it)) // [width, height]
|
|
893
|
+
}
|
|
894
|
+
}
|
|
774
895
|
}
|
|
775
896
|
return remoteVideoStats
|
|
776
897
|
}
|
|
898
|
+
|
|
899
|
+
private fun getSimulcastLayerDefinition(hmsSimulcastLayerDefinition: HMSSimulcastLayerDefinition): WritableMap {
|
|
900
|
+
val simulcastLayerDefinition: WritableMap = Arguments.createMap()
|
|
901
|
+
simulcastLayerDefinition.putString("layer", hmsSimulcastLayerDefinition.layer.name)
|
|
902
|
+
simulcastLayerDefinition.putArray("resolution", getHmsVideoTrackResolution(hmsSimulcastLayerDefinition.resolution)) // [width, height]
|
|
903
|
+
return simulcastLayerDefinition
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
fun getSimulcastLayerDefinitions(hmsSimulcastLayerDefinitions: List<HMSSimulcastLayerDefinition>): WritableArray {
|
|
907
|
+
val simulcastLayerDefinitions: WritableArray = Arguments.createArray()
|
|
908
|
+
hmsSimulcastLayerDefinitions.forEach { simulcastLayerDefinitions.pushMap(getSimulcastLayerDefinition(it)) }
|
|
909
|
+
return simulcastLayerDefinitions
|
|
910
|
+
}
|
|
777
911
|
}
|
|
@@ -370,20 +370,6 @@ class HMSManager(reactContext: ReactApplicationContext) :
|
|
|
370
370
|
callback?.resolve(result)
|
|
371
371
|
}
|
|
372
372
|
|
|
373
|
-
@ReactMethod
|
|
374
|
-
fun enableRTCStats(data: ReadableMap) {
|
|
375
|
-
val hms = HMSHelper.getHms(data, hmsCollection)
|
|
376
|
-
|
|
377
|
-
hms?.enableRTCStats()
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
@ReactMethod
|
|
381
|
-
fun disableRTCStats(data: ReadableMap) {
|
|
382
|
-
val hms = HMSHelper.getHms(data, hmsCollection)
|
|
383
|
-
|
|
384
|
-
hms?.disableRTCStats()
|
|
385
|
-
}
|
|
386
|
-
|
|
387
373
|
@ReactMethod
|
|
388
374
|
fun enableNetworkQualityUpdates(data: ReadableMap) {
|
|
389
375
|
val hms = HMSHelper.getHms(data, hmsCollection)
|
|
@@ -482,6 +468,13 @@ class HMSManager(reactContext: ReactApplicationContext) :
|
|
|
482
468
|
hms?.restrictData(data, promise)
|
|
483
469
|
}
|
|
484
470
|
|
|
471
|
+
@ReactMethod()
|
|
472
|
+
fun getAuthTokenByRoomCode(data: ReadableMap, promise: Promise) {
|
|
473
|
+
val hms = HMSHelper.getHms(data, hmsCollection)
|
|
474
|
+
|
|
475
|
+
hms?.getAuthTokenByRoomCode(data, promise)
|
|
476
|
+
}
|
|
477
|
+
|
|
485
478
|
// region Person-In-Person Mode Action handing
|
|
486
479
|
private val pipReceiver by lazy {
|
|
487
480
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
@@ -877,6 +870,48 @@ class HMSManager(reactContext: ReactApplicationContext) :
|
|
|
877
870
|
}
|
|
878
871
|
}
|
|
879
872
|
|
|
873
|
+
@ReactMethod
|
|
874
|
+
fun getRemoteVideoTrackFromTrackId(data: ReadableMap, promise: Promise) {
|
|
875
|
+
val hms = HMSHelper.getHms(data, hmsCollection)
|
|
876
|
+
|
|
877
|
+
hms?.getRemoteVideoTrackFromTrackId(data, promise)
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
@ReactMethod
|
|
881
|
+
fun getRemoteAudioTrackFromTrackId(data: ReadableMap, promise: Promise) {
|
|
882
|
+
val hms = HMSHelper.getHms(data, hmsCollection)
|
|
883
|
+
|
|
884
|
+
hms?.getRemoteAudioTrackFromTrackId(data, promise)
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
@ReactMethod
|
|
888
|
+
fun getVideoTrackLayer(data: ReadableMap, promise: Promise) {
|
|
889
|
+
val hms = HMSHelper.getHms(data, hmsCollection)
|
|
890
|
+
|
|
891
|
+
hms?.getVideoTrackLayer(data, promise)
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
@ReactMethod
|
|
895
|
+
fun getVideoTrackLayerDefinition(data: ReadableMap, promise: Promise) {
|
|
896
|
+
val hms = HMSHelper.getHms(data, hmsCollection)
|
|
897
|
+
|
|
898
|
+
hms?.getVideoTrackLayerDefinition(data, promise)
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
@ReactMethod
|
|
902
|
+
fun setVideoTrackLayer(data: ReadableMap, promise: Promise?) {
|
|
903
|
+
val hms = HMSHelper.getHms(data, hmsCollection)
|
|
904
|
+
|
|
905
|
+
hms?.setVideoTrackLayer(data, promise)
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
@ReactMethod
|
|
909
|
+
fun captureImageAtMaxSupportedResolution(data: ReadableMap, promise: Promise?) {
|
|
910
|
+
val hms = HMSHelper.getHms(data, hmsCollection)
|
|
911
|
+
|
|
912
|
+
hms?.captureImageAtMaxSupportedResolution(data, promise)
|
|
913
|
+
}
|
|
914
|
+
|
|
880
915
|
fun emitEvent(event: String, data: WritableMap) {
|
|
881
916
|
reactApplicationContext
|
|
882
917
|
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|