@100mslive/react-native-hms 0.9.2 → 0.9.5
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 +1 -2
- 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/build.gradle +1 -1
- package/android/src/main/java/com/reactnativehmssdk/HmsDecoder.kt +12 -0
- package/android/src/main/java/com/reactnativehmssdk/HmsHelper.kt +174 -2
- package/android/src/main/java/com/reactnativehmssdk/HmsSDK.kt +3 -73
- package/android/src/main/java/com/reactnativehmssdk/HmsScreenshareActivity.kt +9 -4
- package/android/src/main/java/com/reactnativehmssdk/HmsView.kt +18 -27
- package/android/src/main/java/com/reactnativehmssdk/HmssdkViewManager.kt +36 -2
- package/ios/HmsDecoder.swift +12 -2
- package/ios/HmsSDK.swift +9 -4
- package/ios/HmsView.swift +2 -14
- package/lib/commonjs/classes/HMSAudioCodec.js.map +1 -1
- package/lib/commonjs/classes/HMSAudioSettings.js.map +1 -1
- package/lib/commonjs/classes/HMSAudioTrack.js.map +1 -1
- package/lib/commonjs/classes/HMSAudioTrackSettings.js.map +1 -1
- package/lib/commonjs/classes/HMSBrowserRecordingState.js.map +1 -1
- package/lib/commonjs/classes/HMSCameraFacing.js.map +1 -1
- package/lib/commonjs/classes/HMSChangeTrackStateRequest.js.map +1 -1
- package/lib/commonjs/classes/HMSConfig.js +3 -0
- package/lib/commonjs/classes/HMSConfig.js.map +1 -1
- package/lib/commonjs/classes/HMSEncoder.js +31 -8
- package/lib/commonjs/classes/HMSEncoder.js.map +1 -1
- package/lib/commonjs/classes/HMSException.js.map +1 -1
- package/lib/commonjs/classes/HMSHLSConfig.js.map +1 -1
- package/lib/commonjs/classes/HMSHLSMeetingURLVariant.js.map +1 -1
- package/lib/commonjs/classes/HMSHLSRecordingConfig.js.map +1 -1
- package/lib/commonjs/classes/HMSHLSRecordingState.js.map +1 -1
- package/lib/commonjs/classes/HMSHLSStreamingState.js.map +1 -1
- package/lib/commonjs/classes/HMSHLSVariant.js.map +1 -1
- package/lib/commonjs/classes/HMSHelper.js.map +1 -1
- package/lib/commonjs/classes/HMSLocalAudioStats.js.map +1 -1
- package/lib/commonjs/classes/HMSLocalAudioTrack.js +3 -5
- package/lib/commonjs/classes/HMSLocalAudioTrack.js.map +1 -1
- package/lib/commonjs/classes/HMSLocalPeer.js.map +1 -1
- package/lib/commonjs/classes/HMSLocalVideoStats.js.map +1 -1
- package/lib/commonjs/classes/HMSLocalVideoTrack.js +3 -5
- package/lib/commonjs/classes/HMSLocalVideoTrack.js.map +1 -1
- package/lib/commonjs/classes/HMSLogLevel.js.map +1 -1
- package/lib/commonjs/classes/HMSLogger.js +19 -1
- package/lib/commonjs/classes/HMSLogger.js.map +1 -1
- package/lib/commonjs/classes/HMSMessage.js +1 -1
- package/lib/commonjs/classes/HMSMessage.js.map +1 -1
- package/lib/commonjs/classes/HMSMessageRecipient.js.map +1 -1
- package/lib/commonjs/classes/HMSMessageRecipientType.js.map +1 -1
- package/lib/commonjs/classes/HMSNetworkQuality.js +20 -0
- package/lib/commonjs/classes/HMSNetworkQuality.js.map +1 -0
- 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.map +1 -1
- package/lib/commonjs/classes/HMSPublishSettings.js.map +1 -1
- package/lib/commonjs/classes/HMSRTCStats.js.map +1 -1
- package/lib/commonjs/classes/HMSRTCStatsReport.js.map +1 -1
- package/lib/commonjs/classes/HMSRTMPConfig.js.map +1 -1
- package/lib/commonjs/classes/HMSRemoteAudioStats.js.map +1 -1
- package/lib/commonjs/classes/HMSRemoteAudioTrack.js +3 -5
- package/lib/commonjs/classes/HMSRemoteAudioTrack.js.map +1 -1
- package/lib/commonjs/classes/HMSRemotePeer.js.map +1 -1
- package/lib/commonjs/classes/HMSRemoteVideoStats.js.map +1 -1
- package/lib/commonjs/classes/HMSRemoteVideoTrack.js +3 -5
- package/lib/commonjs/classes/HMSRemoteVideoTrack.js.map +1 -1
- package/lib/commonjs/classes/HMSRole.js.map +1 -1
- package/lib/commonjs/classes/HMSRoleChangeRequest.js.map +1 -1
- package/lib/commonjs/classes/HMSRoom.js.map +1 -1
- package/lib/commonjs/classes/HMSRoomUpdate.js.map +1 -1
- package/lib/commonjs/classes/HMSRtmpStreamingState.js.map +1 -1
- package/lib/commonjs/classes/HMSSDK.js +79 -202
- package/lib/commonjs/classes/HMSSDK.js.map +1 -1
- package/lib/commonjs/classes/HMSServerRecordingState.js.map +1 -1
- package/lib/commonjs/classes/HMSSimulcastLayerSettings.js.map +1 -1
- package/lib/commonjs/classes/HMSSimulcastSettings.js.map +1 -1
- package/lib/commonjs/classes/HMSSpeaker.js.map +1 -1
- package/lib/commonjs/classes/HMSSpeakerUpdate.js.map +1 -1
- package/lib/commonjs/classes/HMSSubscribeSettings.js.map +1 -1
- package/lib/commonjs/classes/HMSTrack.js.map +1 -1
- package/lib/commonjs/classes/HMSTrackSettings.js.map +1 -1
- package/lib/commonjs/classes/HMSTrackType.js.map +1 -1
- package/lib/commonjs/classes/HMSTrackUpdate.js.map +1 -1
- package/lib/commonjs/classes/HMSUpdateListenerActions.js.map +1 -1
- package/lib/commonjs/classes/HMSVideoCodec.js.map +1 -1
- package/lib/commonjs/classes/HMSVideoResolution.js.map +1 -1
- package/lib/commonjs/classes/HMSVideoSettings.js.map +1 -1
- package/lib/commonjs/classes/HMSVideoTrack.js.map +1 -1
- package/lib/commonjs/classes/HMSVideoTrackSettings.js.map +1 -1
- package/lib/commonjs/classes/HMSVideoViewMode.js.map +1 -1
- package/lib/commonjs/classes/HmsView.js +69 -17
- package/lib/commonjs/classes/HmsView.js.map +1 -1
- package/lib/commonjs/index.js +14 -14
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/classes/HMSAudioCodec.js.map +1 -1
- package/lib/module/classes/HMSAudioSettings.js.map +1 -1
- package/lib/module/classes/HMSAudioTrack.js.map +1 -1
- package/lib/module/classes/HMSAudioTrackSettings.js.map +1 -1
- package/lib/module/classes/HMSBrowserRecordingState.js.map +1 -1
- package/lib/module/classes/HMSCameraFacing.js.map +1 -1
- package/lib/module/classes/HMSChangeTrackStateRequest.js.map +1 -1
- package/lib/module/classes/HMSConfig.js +3 -0
- package/lib/module/classes/HMSConfig.js.map +1 -1
- package/lib/module/classes/HMSEncoder.js +20 -2
- package/lib/module/classes/HMSEncoder.js.map +1 -1
- package/lib/module/classes/HMSException.js.map +1 -1
- package/lib/module/classes/HMSHLSConfig.js.map +1 -1
- package/lib/module/classes/HMSHLSMeetingURLVariant.js.map +1 -1
- package/lib/module/classes/HMSHLSRecordingConfig.js.map +1 -1
- package/lib/module/classes/HMSHLSRecordingState.js.map +1 -1
- package/lib/module/classes/HMSHLSStreamingState.js.map +1 -1
- package/lib/module/classes/HMSHLSVariant.js.map +1 -1
- package/lib/module/classes/HMSHelper.js.map +1 -1
- package/lib/module/classes/HMSLocalAudioStats.js.map +1 -1
- package/lib/module/classes/HMSLocalAudioTrack.js +3 -3
- package/lib/module/classes/HMSLocalAudioTrack.js.map +1 -1
- package/lib/module/classes/HMSLocalPeer.js.map +1 -1
- package/lib/module/classes/HMSLocalVideoStats.js.map +1 -1
- package/lib/module/classes/HMSLocalVideoTrack.js +3 -3
- package/lib/module/classes/HMSLocalVideoTrack.js.map +1 -1
- package/lib/module/classes/HMSLogLevel.js.map +1 -1
- package/lib/module/classes/HMSLogger.js +10 -0
- package/lib/module/classes/HMSLogger.js.map +1 -1
- package/lib/module/classes/HMSMessage.js +1 -1
- package/lib/module/classes/HMSMessage.js.map +1 -1
- package/lib/module/classes/HMSMessageRecipient.js.map +1 -1
- package/lib/module/classes/HMSMessageRecipientType.js.map +1 -1
- package/lib/module/classes/HMSNetworkQuality.js +11 -0
- package/lib/module/classes/HMSNetworkQuality.js.map +1 -0
- 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.map +1 -1
- package/lib/module/classes/HMSPublishSettings.js.map +1 -1
- package/lib/module/classes/HMSRTCStats.js.map +1 -1
- package/lib/module/classes/HMSRTCStatsReport.js.map +1 -1
- package/lib/module/classes/HMSRTMPConfig.js.map +1 -1
- package/lib/module/classes/HMSRemoteAudioStats.js.map +1 -1
- package/lib/module/classes/HMSRemoteAudioTrack.js +3 -3
- package/lib/module/classes/HMSRemoteAudioTrack.js.map +1 -1
- package/lib/module/classes/HMSRemotePeer.js.map +1 -1
- package/lib/module/classes/HMSRemoteVideoStats.js.map +1 -1
- package/lib/module/classes/HMSRemoteVideoTrack.js +3 -3
- package/lib/module/classes/HMSRemoteVideoTrack.js.map +1 -1
- package/lib/module/classes/HMSRole.js.map +1 -1
- package/lib/module/classes/HMSRoleChangeRequest.js.map +1 -1
- package/lib/module/classes/HMSRoom.js.map +1 -1
- package/lib/module/classes/HMSRoomUpdate.js.map +1 -1
- package/lib/module/classes/HMSRtmpStreamingState.js.map +1 -1
- package/lib/module/classes/HMSSDK.js +79 -202
- package/lib/module/classes/HMSSDK.js.map +1 -1
- package/lib/module/classes/HMSServerRecordingState.js.map +1 -1
- package/lib/module/classes/HMSSimulcastLayerSettings.js.map +1 -1
- package/lib/module/classes/HMSSimulcastSettings.js.map +1 -1
- package/lib/module/classes/HMSSpeaker.js.map +1 -1
- package/lib/module/classes/HMSSpeakerUpdate.js.map +1 -1
- package/lib/module/classes/HMSSubscribeSettings.js.map +1 -1
- package/lib/module/classes/HMSTrack.js.map +1 -1
- package/lib/module/classes/HMSTrackSettings.js.map +1 -1
- package/lib/module/classes/HMSTrackType.js.map +1 -1
- package/lib/module/classes/HMSTrackUpdate.js.map +1 -1
- package/lib/module/classes/HMSUpdateListenerActions.js.map +1 -1
- package/lib/module/classes/HMSVideoCodec.js.map +1 -1
- package/lib/module/classes/HMSVideoResolution.js.map +1 -1
- package/lib/module/classes/HMSVideoSettings.js.map +1 -1
- package/lib/module/classes/HMSVideoTrack.js.map +1 -1
- package/lib/module/classes/HMSVideoTrackSettings.js.map +1 -1
- package/lib/module/classes/HMSVideoViewMode.js.map +1 -1
- package/lib/module/classes/HmsView.js +67 -17
- package/lib/module/classes/HmsView.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/classes/HMSConfig.d.ts +2 -0
- package/lib/typescript/classes/HMSEncoder.d.ts +7 -1
- package/lib/typescript/classes/HMSLocalPeer.d.ts +2 -0
- package/lib/typescript/classes/HMSLogger.d.ts +3 -0
- package/lib/typescript/classes/HMSNetworkQuality.d.ts +6 -0
- package/lib/typescript/classes/HMSPeer.d.ts +3 -0
- package/lib/typescript/classes/HMSPeerUpdate.d.ts +2 -1
- package/lib/typescript/classes/HMSRemotePeer.d.ts +2 -0
- package/lib/typescript/classes/HMSSDK.d.ts +7 -9
- package/lib/typescript/classes/HmsView.d.ts +7 -7
- package/lib/typescript/index.d.ts +1 -1
- package/package.json +2 -2
- package/react-native-hms.podspec +1 -1
- package/src/classes/HMSConfig.ts +3 -0
- package/src/classes/HMSEncoder.ts +20 -10
- package/src/classes/HMSLocalAudioTrack.ts +3 -3
- package/src/classes/HMSLocalPeer.ts +2 -0
- package/src/classes/HMSLocalVideoTrack.ts +3 -3
- package/src/classes/HMSLogger.ts +11 -0
- package/src/classes/HMSMessage.ts +1 -1
- package/src/classes/HMSNetworkQuality.ts +7 -0
- package/src/classes/HMSPeer.ts +4 -2
- package/src/classes/HMSPeerUpdate.ts +1 -0
- package/src/classes/HMSRemoteAudioTrack.ts +3 -3
- package/src/classes/HMSRemotePeer.ts +2 -0
- package/src/classes/HMSRemoteVideoTrack.ts +3 -3
- package/src/classes/HMSSDK.tsx +22 -30
- package/src/classes/HmsView.tsx +102 -44
- package/src/index.ts +1 -1
package/README.md
CHANGED
|
@@ -192,10 +192,9 @@ const styles = StyleSheet.create({
|
|
|
192
192
|
});
|
|
193
193
|
|
|
194
194
|
// trackId can be acquired from the method explained above
|
|
195
|
-
// sink is passed false video would be removed. It is a ios only prop, for android it is handled by the package itself.
|
|
196
195
|
// scaleType can be selected from HMSVideoViewMode as required
|
|
197
196
|
// mirror can be passed as true to flip videos horizontally
|
|
198
|
-
<HmsView
|
|
197
|
+
<HmsView style={styles.hmsView} trackId={trackId} mirror={true} scaleType={HMSVideoViewMode.ASPECT_FIT} />
|
|
199
198
|
|
|
200
199
|
...
|
|
201
200
|
```
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/android/build.gradle
CHANGED
|
@@ -63,7 +63,7 @@ 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.android-sdk:lib:2.3.
|
|
66
|
+
implementation 'com.github.100mslive.android-sdk:lib:2.3.7'
|
|
67
67
|
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0'
|
|
68
68
|
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
|
|
69
69
|
implementation 'androidx.appcompat:appcompat:1.3.1'
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
package com.reactnativehmssdk
|
|
2
2
|
|
|
3
3
|
import com.facebook.react.bridge.*
|
|
4
|
+
import live.hms.video.connection.stats.quality.HMSNetworkQuality
|
|
4
5
|
import live.hms.video.error.HMSException
|
|
5
6
|
import live.hms.video.media.settings.HMSAudioTrackSettings
|
|
6
7
|
import live.hms.video.media.settings.HMSVideoResolution
|
|
@@ -47,6 +48,7 @@ object HmsDecoder {
|
|
|
47
48
|
peer.putBoolean("isLocal", hmsPeer.isLocal)
|
|
48
49
|
peer.putString("customerUserID", hmsPeer.customerUserID)
|
|
49
50
|
peer.putString("metadata", hmsPeer.metadata)
|
|
51
|
+
peer.putMap("networkQuality", this.getHmsNetworkQuality(hmsPeer.networkQuality))
|
|
50
52
|
peer.putMap("audioTrack", this.getHmsAudioTrack(hmsPeer.audioTrack))
|
|
51
53
|
peer.putMap("videoTrack", this.getHmsVideoTrack(hmsPeer.videoTrack))
|
|
52
54
|
peer.putMap("role", this.getHmsRole(hmsPeer.hmsRole))
|
|
@@ -182,6 +184,7 @@ object HmsDecoder {
|
|
|
182
184
|
peer.putBoolean("isLocal", hmsLocalPeer.isLocal)
|
|
183
185
|
peer.putString("customerUserID", hmsLocalPeer.customerUserID)
|
|
184
186
|
peer.putString("metadata", hmsLocalPeer.metadata)
|
|
187
|
+
peer.putMap("networkQuality", this.getHmsNetworkQuality(hmsLocalPeer.networkQuality))
|
|
185
188
|
peer.putMap("audioTrack", this.getHmsAudioTrack(hmsLocalPeer.audioTrack))
|
|
186
189
|
peer.putMap("videoTrack", this.getHmsVideoTrack(hmsLocalPeer.videoTrack))
|
|
187
190
|
peer.putMap("role", this.getHmsRole(hmsLocalPeer.hmsRole))
|
|
@@ -276,6 +279,7 @@ object HmsDecoder {
|
|
|
276
279
|
peer.putBoolean("isLocal", hmsRemotePeer.isLocal)
|
|
277
280
|
peer.putString("customerUserID", hmsRemotePeer.customerUserID)
|
|
278
281
|
peer.putString("metadata", hmsRemotePeer.metadata)
|
|
282
|
+
peer.putMap("networkQuality", this.getHmsNetworkQuality(hmsRemotePeer.networkQuality))
|
|
279
283
|
peer.putMap("audioTrack", this.getHmsAudioTrack(hmsRemotePeer.audioTrack))
|
|
280
284
|
peer.putMap("videoTrack", this.getHmsVideoTrack(hmsRemotePeer.videoTrack))
|
|
281
285
|
peer.putMap("role", this.getHmsRole(hmsRemotePeer.hmsRole))
|
|
@@ -508,4 +512,12 @@ object HmsDecoder {
|
|
|
508
512
|
}
|
|
509
513
|
return hmsRecipient
|
|
510
514
|
}
|
|
515
|
+
|
|
516
|
+
private fun getHmsNetworkQuality(networkQuality: HMSNetworkQuality?): WritableMap {
|
|
517
|
+
val hmsNetworkQuality: WritableMap = Arguments.createMap()
|
|
518
|
+
if (networkQuality != null) {
|
|
519
|
+
hmsNetworkQuality.putInt("downlinkQuality", networkQuality.downlinkQuality)
|
|
520
|
+
}
|
|
521
|
+
return hmsNetworkQuality
|
|
522
|
+
}
|
|
511
523
|
}
|
|
@@ -1,17 +1,33 @@
|
|
|
1
1
|
package com.reactnativehmssdk
|
|
2
2
|
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.graphics.Bitmap
|
|
5
|
+
import android.os.Build
|
|
6
|
+
import android.os.Handler
|
|
7
|
+
import android.util.Base64
|
|
8
|
+
import android.util.Log
|
|
9
|
+
import android.view.PixelCopy
|
|
10
|
+
import androidx.annotation.RequiresApi
|
|
11
|
+
import com.facebook.react.bridge.*
|
|
3
12
|
import com.facebook.react.bridge.ReadableArray
|
|
4
13
|
import com.facebook.react.bridge.ReadableMap
|
|
14
|
+
import com.facebook.react.uimanager.events.RCTEventEmitter
|
|
15
|
+
import java.io.ByteArrayOutputStream
|
|
16
|
+
import java.util.*
|
|
17
|
+
import live.hms.video.error.HMSException
|
|
5
18
|
import live.hms.video.media.codec.HMSAudioCodec
|
|
6
19
|
import live.hms.video.media.codec.HMSVideoCodec
|
|
7
20
|
import live.hms.video.media.settings.HMSAudioTrackSettings
|
|
8
21
|
import live.hms.video.media.settings.HMSTrackSettings
|
|
9
22
|
import live.hms.video.media.settings.HMSVideoResolution
|
|
10
23
|
import live.hms.video.media.settings.HMSVideoTrackSettings
|
|
11
|
-
import live.hms.video.media.tracks
|
|
24
|
+
import live.hms.video.media.tracks.HMSRemoteAudioTrack
|
|
25
|
+
import live.hms.video.media.tracks.HMSRemoteVideoTrack
|
|
26
|
+
import live.hms.video.media.tracks.HMSTrack
|
|
12
27
|
import live.hms.video.sdk.models.*
|
|
13
|
-
import live.hms.video.sdk.models.role
|
|
28
|
+
import live.hms.video.sdk.models.role.HMSRole
|
|
14
29
|
import live.hms.video.utils.HmsUtilities
|
|
30
|
+
import org.webrtc.SurfaceViewRenderer
|
|
15
31
|
|
|
16
32
|
object HmsHelper {
|
|
17
33
|
|
|
@@ -307,4 +323,160 @@ object HmsHelper {
|
|
|
307
323
|
}
|
|
308
324
|
return meetingURLVariant
|
|
309
325
|
}
|
|
326
|
+
|
|
327
|
+
fun getHmsConfig(credentials: ReadableMap): HMSConfig {
|
|
328
|
+
var config =
|
|
329
|
+
HMSConfig(
|
|
330
|
+
credentials.getString("username") as String,
|
|
331
|
+
credentials.getString("authToken") as String,
|
|
332
|
+
)
|
|
333
|
+
|
|
334
|
+
when {
|
|
335
|
+
areAllRequiredKeysAvailable(
|
|
336
|
+
credentials,
|
|
337
|
+
arrayOf(
|
|
338
|
+
Pair("endpoint", "String"),
|
|
339
|
+
Pair("metadata", "String"),
|
|
340
|
+
Pair("captureNetworkQualityInPreview", "Boolean")
|
|
341
|
+
)
|
|
342
|
+
) -> {
|
|
343
|
+
config =
|
|
344
|
+
HMSConfig(
|
|
345
|
+
credentials.getString("username") as String,
|
|
346
|
+
credentials.getString("authToken") as String,
|
|
347
|
+
initEndpoint = credentials.getString("endpoint") as String,
|
|
348
|
+
metadata = credentials.getString("metadata") as String,
|
|
349
|
+
captureNetworkQualityInPreview =
|
|
350
|
+
credentials.getBoolean("captureNetworkQualityInPreview"),
|
|
351
|
+
)
|
|
352
|
+
}
|
|
353
|
+
areAllRequiredKeysAvailable(
|
|
354
|
+
credentials,
|
|
355
|
+
arrayOf(Pair("endpoint", "String"), Pair("metadata", "String"))
|
|
356
|
+
) -> {
|
|
357
|
+
config =
|
|
358
|
+
HMSConfig(
|
|
359
|
+
credentials.getString("username") as String,
|
|
360
|
+
credentials.getString("authToken") as String,
|
|
361
|
+
initEndpoint = credentials.getString("endpoint") as String,
|
|
362
|
+
metadata = credentials.getString("metadata") as String,
|
|
363
|
+
)
|
|
364
|
+
}
|
|
365
|
+
areAllRequiredKeysAvailable(
|
|
366
|
+
credentials,
|
|
367
|
+
arrayOf(Pair("endpoint", "String"), Pair("captureNetworkQualityInPreview", "Boolean"))
|
|
368
|
+
) -> {
|
|
369
|
+
config =
|
|
370
|
+
HMSConfig(
|
|
371
|
+
credentials.getString("username") as String,
|
|
372
|
+
credentials.getString("authToken") as String,
|
|
373
|
+
initEndpoint = credentials.getString("endpoint") as String,
|
|
374
|
+
captureNetworkQualityInPreview =
|
|
375
|
+
credentials.getBoolean("captureNetworkQualityInPreview"),
|
|
376
|
+
)
|
|
377
|
+
}
|
|
378
|
+
areAllRequiredKeysAvailable(
|
|
379
|
+
credentials,
|
|
380
|
+
arrayOf(Pair("metadata", "String"), Pair("captureNetworkQualityInPreview", "Boolean"))
|
|
381
|
+
) -> {
|
|
382
|
+
config =
|
|
383
|
+
HMSConfig(
|
|
384
|
+
credentials.getString("username") as String,
|
|
385
|
+
credentials.getString("authToken") as String,
|
|
386
|
+
metadata = credentials.getString("metadata") as String,
|
|
387
|
+
captureNetworkQualityInPreview =
|
|
388
|
+
credentials.getBoolean("captureNetworkQualityInPreview"),
|
|
389
|
+
)
|
|
390
|
+
}
|
|
391
|
+
areAllRequiredKeysAvailable(credentials, arrayOf(Pair("endpoint", "String"))) -> {
|
|
392
|
+
config =
|
|
393
|
+
HMSConfig(
|
|
394
|
+
credentials.getString("username") as String,
|
|
395
|
+
credentials.getString("authToken") as String,
|
|
396
|
+
initEndpoint = credentials.getString("endpoint") as String,
|
|
397
|
+
)
|
|
398
|
+
}
|
|
399
|
+
areAllRequiredKeysAvailable(credentials, arrayOf(Pair("metadata", "String"))) -> {
|
|
400
|
+
config =
|
|
401
|
+
HMSConfig(
|
|
402
|
+
credentials.getString("username") as String,
|
|
403
|
+
credentials.getString("authToken") as String,
|
|
404
|
+
metadata = credentials.getString("metadata") as String,
|
|
405
|
+
)
|
|
406
|
+
}
|
|
407
|
+
areAllRequiredKeysAvailable(
|
|
408
|
+
credentials,
|
|
409
|
+
arrayOf(Pair("captureNetworkQualityInPreview", "Boolean"))
|
|
410
|
+
) -> {
|
|
411
|
+
config =
|
|
412
|
+
HMSConfig(
|
|
413
|
+
credentials.getString("username") as String,
|
|
414
|
+
credentials.getString("authToken") as String,
|
|
415
|
+
captureNetworkQualityInPreview =
|
|
416
|
+
credentials.getBoolean("captureNetworkQualityInPreview")
|
|
417
|
+
)
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
return config
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
@RequiresApi(Build.VERSION_CODES.N)
|
|
424
|
+
fun captureSurfaceView(
|
|
425
|
+
surfaceView: SurfaceViewRenderer,
|
|
426
|
+
sdkId: String,
|
|
427
|
+
args: ReadableArray?,
|
|
428
|
+
context: Context,
|
|
429
|
+
id: Int
|
|
430
|
+
) {
|
|
431
|
+
val output = Arguments.createMap()
|
|
432
|
+
if (args != null) {
|
|
433
|
+
output.putInt("requestId", args.getInt(0))
|
|
434
|
+
} else {
|
|
435
|
+
output.putInt("requestId", -1)
|
|
436
|
+
}
|
|
437
|
+
val reactContext = context as ReactContext
|
|
438
|
+
try {
|
|
439
|
+
val bitmap: Bitmap =
|
|
440
|
+
Bitmap.createBitmap(surfaceView.width, surfaceView.height, Bitmap.Config.ARGB_8888)
|
|
441
|
+
PixelCopy.request(
|
|
442
|
+
surfaceView,
|
|
443
|
+
bitmap,
|
|
444
|
+
{ copyResult ->
|
|
445
|
+
if (copyResult === PixelCopy.SUCCESS) {
|
|
446
|
+
Log.d("captureSurfaceView", "bitmap: $bitmap")
|
|
447
|
+
val byteArrayOutputStream = ByteArrayOutputStream()
|
|
448
|
+
bitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream)
|
|
449
|
+
val byteArray = byteArrayOutputStream.toByteArray()
|
|
450
|
+
val encoded: String = Base64.encodeToString(byteArray, Base64.DEFAULT)
|
|
451
|
+
Log.d("captureSurfaceView", "Base64: $encoded")
|
|
452
|
+
output.putString("result", encoded)
|
|
453
|
+
reactContext
|
|
454
|
+
.getJSModule(RCTEventEmitter::class.java)
|
|
455
|
+
.receiveEvent(id, "captureFrame", output)
|
|
456
|
+
} else {
|
|
457
|
+
Log.e("captureSurfaceView", "copyResult: $copyResult")
|
|
458
|
+
HmsModule.hmsCollection[sdkId]?.emitHMSError(
|
|
459
|
+
HMSException(
|
|
460
|
+
103,
|
|
461
|
+
copyResult.toString(),
|
|
462
|
+
copyResult.toString(),
|
|
463
|
+
copyResult.toString(),
|
|
464
|
+
copyResult.toString()
|
|
465
|
+
)
|
|
466
|
+
)
|
|
467
|
+
output.putString("error", copyResult.toString())
|
|
468
|
+
reactContext
|
|
469
|
+
.getJSModule(RCTEventEmitter::class.java)
|
|
470
|
+
.receiveEvent(id, "captureFrame", output)
|
|
471
|
+
}
|
|
472
|
+
},
|
|
473
|
+
Handler()
|
|
474
|
+
)
|
|
475
|
+
} catch (e: Exception) {
|
|
476
|
+
Log.e("captureSurfaceView", "error: $e")
|
|
477
|
+
HmsModule.hmsCollection[sdkId]?.emitHMSError(e as HMSException)
|
|
478
|
+
output.putString("error", e.message)
|
|
479
|
+
reactContext.getJSModule(RCTEventEmitter::class.java).receiveEvent(id, "captureFrame", output)
|
|
480
|
+
}
|
|
481
|
+
}
|
|
310
482
|
}
|
|
@@ -97,42 +97,7 @@ class HmsSDK(
|
|
|
97
97
|
)
|
|
98
98
|
if (requiredKeys) {
|
|
99
99
|
previewInProgress = true
|
|
100
|
-
|
|
101
|
-
HMSConfig(
|
|
102
|
-
credentials.getString("username") as String,
|
|
103
|
-
credentials.getString("authToken") as String,
|
|
104
|
-
)
|
|
105
|
-
|
|
106
|
-
when {
|
|
107
|
-
HmsHelper.areAllRequiredKeysAvailable(
|
|
108
|
-
credentials,
|
|
109
|
-
arrayOf(Pair("endpoint", "String"), Pair("metadata", "String"))
|
|
110
|
-
) -> {
|
|
111
|
-
config =
|
|
112
|
-
HMSConfig(
|
|
113
|
-
credentials.getString("username") as String,
|
|
114
|
-
credentials.getString("authToken") as String,
|
|
115
|
-
initEndpoint = credentials.getString("endpoint") as String,
|
|
116
|
-
metadata = credentials.getString("metadata") as String,
|
|
117
|
-
)
|
|
118
|
-
}
|
|
119
|
-
HmsHelper.areAllRequiredKeysAvailable(credentials, arrayOf(Pair("endpoint", "String"))) -> {
|
|
120
|
-
config =
|
|
121
|
-
HMSConfig(
|
|
122
|
-
credentials.getString("username") as String,
|
|
123
|
-
credentials.getString("authToken") as String,
|
|
124
|
-
initEndpoint = credentials.getString("endpoint") as String,
|
|
125
|
-
)
|
|
126
|
-
}
|
|
127
|
-
HmsHelper.areAllRequiredKeysAvailable(credentials, arrayOf(Pair("metadata", "String"))) -> {
|
|
128
|
-
config =
|
|
129
|
-
HMSConfig(
|
|
130
|
-
credentials.getString("username") as String,
|
|
131
|
-
credentials.getString("authToken") as String,
|
|
132
|
-
metadata = credentials.getString("metadata") as String,
|
|
133
|
-
)
|
|
134
|
-
}
|
|
135
|
-
}
|
|
100
|
+
val config = HmsHelper.getHmsConfig(credentials)
|
|
136
101
|
|
|
137
102
|
hmsSDK?.preview(
|
|
138
103
|
config,
|
|
@@ -217,42 +182,7 @@ class HmsSDK(
|
|
|
217
182
|
arrayOf(Pair("username", "String"), Pair("authToken", "String"))
|
|
218
183
|
)
|
|
219
184
|
if (requiredKeys) {
|
|
220
|
-
|
|
221
|
-
HMSConfig(
|
|
222
|
-
credentials.getString("username") as String,
|
|
223
|
-
credentials.getString("authToken") as String
|
|
224
|
-
)
|
|
225
|
-
|
|
226
|
-
when {
|
|
227
|
-
HmsHelper.areAllRequiredKeysAvailable(
|
|
228
|
-
credentials,
|
|
229
|
-
arrayOf(Pair("endpoint", "String"), Pair("metadata", "String"))
|
|
230
|
-
) -> {
|
|
231
|
-
config =
|
|
232
|
-
HMSConfig(
|
|
233
|
-
credentials.getString("username") as String,
|
|
234
|
-
credentials.getString("authToken") as String,
|
|
235
|
-
initEndpoint = credentials.getString("endpoint") as String,
|
|
236
|
-
metadata = credentials.getString("metadata") as String,
|
|
237
|
-
)
|
|
238
|
-
}
|
|
239
|
-
HmsHelper.areAllRequiredKeysAvailable(credentials, arrayOf(Pair("endpoint", "String"))) -> {
|
|
240
|
-
config =
|
|
241
|
-
HMSConfig(
|
|
242
|
-
credentials.getString("username") as String,
|
|
243
|
-
credentials.getString("authToken") as String,
|
|
244
|
-
initEndpoint = credentials.getString("endpoint") as String,
|
|
245
|
-
)
|
|
246
|
-
}
|
|
247
|
-
HmsHelper.areAllRequiredKeysAvailable(credentials, arrayOf(Pair("metadata", "String"))) -> {
|
|
248
|
-
config =
|
|
249
|
-
HMSConfig(
|
|
250
|
-
credentials.getString("username") as String,
|
|
251
|
-
credentials.getString("authToken") as String,
|
|
252
|
-
metadata = credentials.getString("metadata") as String,
|
|
253
|
-
)
|
|
254
|
-
}
|
|
255
|
-
}
|
|
185
|
+
val config = HmsHelper.getHmsConfig(credentials)
|
|
256
186
|
|
|
257
187
|
HMSCoroutineScope.launch {
|
|
258
188
|
try {
|
|
@@ -375,7 +305,7 @@ class HmsSDK(
|
|
|
375
305
|
data.putMap("sender", HmsDecoder.getHmsPeer(message.sender))
|
|
376
306
|
data.putString("message", message.message)
|
|
377
307
|
data.putString("type", message.type)
|
|
378
|
-
data.putString("time", message.serverReceiveTime.toString())
|
|
308
|
+
data.putString("time", message.serverReceiveTime.time.toString())
|
|
379
309
|
data.putString("id", id)
|
|
380
310
|
data.putMap("recipient", HmsDecoder.getHmsMessageRecipient(message.recipient))
|
|
381
311
|
|
|
@@ -37,10 +37,15 @@ class HmsScreenshareActivity : ComponentActivity() {
|
|
|
37
37
|
)
|
|
38
38
|
} else {
|
|
39
39
|
val id = intent.getStringExtra("id")
|
|
40
|
-
val
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
val error = HMSException(
|
|
41
|
+
103,
|
|
42
|
+
"RESULT_CANCELED",
|
|
43
|
+
"RESULT_CANCELED",
|
|
44
|
+
"RESULT_CANCELED",
|
|
45
|
+
"RESULT_CANCELED"
|
|
46
|
+
)
|
|
47
|
+
HmsModule.hmsCollection[id]?.screenshareCallback?.reject(error)
|
|
48
|
+
HmsModule.hmsCollection[id]?.emitHMSError(error)
|
|
44
49
|
finish()
|
|
45
50
|
}
|
|
46
51
|
}
|
|
@@ -2,14 +2,17 @@ package com.reactnativehmssdk
|
|
|
2
2
|
|
|
3
3
|
import android.annotation.SuppressLint
|
|
4
4
|
import android.content.Context
|
|
5
|
+
import android.os.Build
|
|
5
6
|
import android.view.LayoutInflater
|
|
6
7
|
import android.widget.FrameLayout
|
|
8
|
+
import androidx.annotation.RequiresApi
|
|
7
9
|
import com.facebook.react.bridge.Arguments
|
|
8
10
|
import com.facebook.react.bridge.ReactContext
|
|
11
|
+
import com.facebook.react.bridge.ReadableArray
|
|
9
12
|
import com.facebook.react.bridge.WritableMap
|
|
10
13
|
import com.facebook.react.uimanager.events.RCTEventEmitter
|
|
11
|
-
import live.hms.video.media.tracks.HMSTrackType
|
|
12
14
|
import live.hms.video.media.tracks.HMSVideoTrack
|
|
15
|
+
import live.hms.video.utils.HmsUtilities
|
|
13
16
|
import live.hms.video.utils.SharedEglContext
|
|
14
17
|
import org.webrtc.RendererCommon
|
|
15
18
|
import org.webrtc.SurfaceViewRenderer
|
|
@@ -18,8 +21,8 @@ import org.webrtc.SurfaceViewRenderer
|
|
|
18
21
|
class HmsView(context: ReactContext) : FrameLayout(context) {
|
|
19
22
|
private var surfaceView: SurfaceViewRenderer = SurfaceViewRenderer(context)
|
|
20
23
|
private var videoTrack: HMSVideoTrack? = null
|
|
21
|
-
private var localTrack: String? = null
|
|
22
24
|
private var scaleTypeApplied: Boolean = false
|
|
25
|
+
private var sdkId: String = "12345"
|
|
23
26
|
private var currentScaleType: RendererCommon.ScalingType =
|
|
24
27
|
RendererCommon.ScalingType.SCALE_ASPECT_FILL
|
|
25
28
|
|
|
@@ -31,6 +34,11 @@ class HmsView(context: ReactContext) : FrameLayout(context) {
|
|
|
31
34
|
surfaceView.setEnableHardwareScaler(true)
|
|
32
35
|
}
|
|
33
36
|
|
|
37
|
+
@RequiresApi(Build.VERSION_CODES.N)
|
|
38
|
+
fun captureHmsView(args: ReadableArray?) {
|
|
39
|
+
HmsHelper.captureSurfaceView(surfaceView, sdkId, args, context, id)
|
|
40
|
+
}
|
|
41
|
+
|
|
34
42
|
private fun onReceiveNativeEvent() {
|
|
35
43
|
val event: WritableMap = Arguments.createMap()
|
|
36
44
|
event.putString("message", "MyMessage")
|
|
@@ -56,6 +64,13 @@ class HmsView(context: ReactContext) : FrameLayout(context) {
|
|
|
56
64
|
}
|
|
57
65
|
}
|
|
58
66
|
|
|
67
|
+
fun updateZOrderMediaOverlay(setZOrderMediaOverlay: Boolean?) {
|
|
68
|
+
if (setZOrderMediaOverlay != null && setZOrderMediaOverlay) {
|
|
69
|
+
// surfaceView.setZOrderOnTop(true);
|
|
70
|
+
surfaceView.setZOrderMediaOverlay(setZOrderMediaOverlay)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
59
74
|
fun updateScaleType(scaleType: String?) {
|
|
60
75
|
if (scaleType != null) {
|
|
61
76
|
when (scaleType) {
|
|
@@ -87,40 +102,16 @@ class HmsView(context: ReactContext) : FrameLayout(context) {
|
|
|
87
102
|
hmsCollection: MutableMap<String, HmsSDK>,
|
|
88
103
|
mirror: Boolean?
|
|
89
104
|
) {
|
|
90
|
-
var sdkId = "12345"
|
|
91
105
|
if (id != null) {
|
|
92
106
|
sdkId = id
|
|
93
107
|
}
|
|
94
|
-
|
|
95
108
|
val hms = hmsCollection[sdkId]?.hmsSDK
|
|
96
109
|
|
|
97
110
|
if (trackId != null && hms != null) {
|
|
98
111
|
if (mirror != null) {
|
|
99
112
|
surfaceView.setMirror(mirror)
|
|
100
113
|
}
|
|
101
|
-
|
|
102
|
-
val localTrackId = hms.getLocalPeer()?.videoTrack?.trackId
|
|
103
|
-
if (localTrackId == localTrack) {
|
|
104
|
-
videoTrack = hms.getLocalPeer()?.videoTrack
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
val remotePeers = hms.getRemotePeers()
|
|
108
|
-
for (peer in remotePeers) {
|
|
109
|
-
val videoTrackId = peer.videoTrack?.trackId
|
|
110
|
-
|
|
111
|
-
val auxiliaryTracks = peer.auxiliaryTracks
|
|
112
|
-
for (track in auxiliaryTracks) {
|
|
113
|
-
val auxTrackId = track.trackId
|
|
114
|
-
if (trackId == auxTrackId && track.type == HMSTrackType.VIDEO && !track.isMute) {
|
|
115
|
-
videoTrack = track as HMSVideoTrack
|
|
116
|
-
return
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
if (videoTrackId == localTrack) {
|
|
120
|
-
videoTrack = peer.videoTrack
|
|
121
|
-
return
|
|
122
|
-
}
|
|
123
|
-
}
|
|
114
|
+
videoTrack = hms.getRoom()?.let { HmsUtilities.getVideoTrack(trackId, it) }
|
|
124
115
|
}
|
|
125
116
|
}
|
|
126
117
|
}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
package com.reactnativehmssdk
|
|
2
2
|
|
|
3
|
+
import android.os.Build
|
|
4
|
+
import androidx.annotation.NonNull
|
|
5
|
+
import androidx.annotation.Nullable
|
|
6
|
+
import androidx.annotation.RequiresApi
|
|
7
|
+
import com.facebook.react.bridge.ReadableArray
|
|
3
8
|
import com.facebook.react.bridge.ReadableMap
|
|
4
9
|
import com.facebook.react.common.MapBuilder
|
|
5
10
|
import com.facebook.react.uimanager.SimpleViewManager
|
|
@@ -28,17 +33,41 @@ class HmssdkViewManager : SimpleViewManager<HmsView>() {
|
|
|
28
33
|
.build()
|
|
29
34
|
}
|
|
30
35
|
|
|
36
|
+
override fun getExportedCustomDirectEventTypeConstants(): MutableMap<String, Any>? {
|
|
37
|
+
return MapBuilder.of(
|
|
38
|
+
"captureFrame",
|
|
39
|
+
MapBuilder.of("registrationName", "onDataReturned"),
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@RequiresApi(Build.VERSION_CODES.N)
|
|
44
|
+
override fun receiveCommand(@NonNull root: HmsView, commandId: String?, args: ReadableArray?) {
|
|
45
|
+
when (commandId) {
|
|
46
|
+
"capture" -> root.captureHmsView(args)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@RequiresApi(Build.VERSION_CODES.N)
|
|
51
|
+
override fun receiveCommand(@NonNull root: HmsView, commandId: Int, args: ReadableArray?) {
|
|
52
|
+
when (commandId) {
|
|
53
|
+
1 -> root.captureHmsView(args)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@Nullable
|
|
58
|
+
override fun getCommandsMap(): Map<String, Int>? {
|
|
59
|
+
return MapBuilder.of("capture", 1)
|
|
60
|
+
}
|
|
61
|
+
|
|
31
62
|
@ReactProp(name = "data")
|
|
32
63
|
fun setData(view: HmsView, data: ReadableMap) {
|
|
33
64
|
val trackId = data.getString("trackId")
|
|
34
|
-
// val sink = data.getBoolean("sink")
|
|
35
65
|
val id = data.getString("id")
|
|
36
66
|
val mirror = data.getBoolean("mirror")
|
|
37
67
|
val hmsCollection = getHms()
|
|
38
68
|
if (hmsCollection != null) {
|
|
39
69
|
view.setData(id, trackId, hmsCollection, mirror)
|
|
40
70
|
}
|
|
41
|
-
// do the processing here
|
|
42
71
|
}
|
|
43
72
|
|
|
44
73
|
@ReactProp(name = "scaleType")
|
|
@@ -46,6 +75,11 @@ class HmssdkViewManager : SimpleViewManager<HmsView>() {
|
|
|
46
75
|
view.updateScaleType(data)
|
|
47
76
|
}
|
|
48
77
|
|
|
78
|
+
@ReactProp(name = "setZOrderMediaOverlay")
|
|
79
|
+
fun setZOrderMediaOverlay(view: HmsView, data: Boolean?) {
|
|
80
|
+
view.updateZOrderMediaOverlay(data)
|
|
81
|
+
}
|
|
82
|
+
|
|
49
83
|
private fun getHms(): MutableMap<String, HmsSDK>? {
|
|
50
84
|
return reactContext?.getNativeModule(HmsModule::class.java)?.getHmsInstance()
|
|
51
85
|
}
|
package/ios/HmsDecoder.swift
CHANGED
|
@@ -37,6 +37,7 @@ class HmsDecoder: NSObject {
|
|
|
37
37
|
let audioTrack = getHmsAudioTrack(peer.audioTrack)
|
|
38
38
|
let videoTrack = getHmsVideoTrack(peer.videoTrack)
|
|
39
39
|
let role = getHmsRole(peer.role)
|
|
40
|
+
let networkQuality = getHmsNetworkQuality(peer.networkQuality)
|
|
40
41
|
|
|
41
42
|
let auxiliaryTracks = getAllTracks(peer.auxiliaryTracks ?? [] )
|
|
42
43
|
|
|
@@ -49,6 +50,7 @@ class HmsDecoder: NSObject {
|
|
|
49
50
|
"audioTrack": audioTrack,
|
|
50
51
|
"videoTrack": videoTrack,
|
|
51
52
|
"auxiliaryTracks": auxiliaryTracks,
|
|
53
|
+
"networkQuality": networkQuality,
|
|
52
54
|
"role": role]
|
|
53
55
|
}
|
|
54
56
|
|
|
@@ -114,6 +116,7 @@ class HmsDecoder: NSObject {
|
|
|
114
116
|
let audioTrack = getHmsAudioTrack(peer.audioTrack)
|
|
115
117
|
let videoTrack = getHmsVideoTrack(peer.videoTrack)
|
|
116
118
|
let role = getHmsRole(peer.role)
|
|
119
|
+
let networkQuality = getHmsNetworkQuality(peer.networkQuality)
|
|
117
120
|
|
|
118
121
|
var auxiliaryTracks = [[String: Any]]()
|
|
119
122
|
for track in peer.auxiliaryTracks ?? [] {
|
|
@@ -133,7 +136,7 @@ class HmsDecoder: NSObject {
|
|
|
133
136
|
localVideoTrackData = getHmsLocalVideoTrack(localVideo)
|
|
134
137
|
}
|
|
135
138
|
|
|
136
|
-
return ["peerID": peerID, "name": name, "isLocal": isLocal, "customerUserID": customerUserID, "customerDescription": customerDescription, "metadata": metadata, "audioTrack": audioTrack, "videoTrack": videoTrack, "auxiliaryTracks": auxiliaryTracks, "localAudioTrackData": localAudioTrackData, "localVideoTrackData": localVideoTrackData, "role": role]
|
|
139
|
+
return ["peerID": peerID, "name": name, "isLocal": isLocal, "customerUserID": customerUserID, "customerDescription": customerDescription, "metadata": metadata, "audioTrack": audioTrack, "videoTrack": videoTrack, "auxiliaryTracks": auxiliaryTracks, "localAudioTrackData": localAudioTrackData, "localVideoTrackData": localVideoTrackData, "role": role, "networkQuality": networkQuality]
|
|
137
140
|
}
|
|
138
141
|
|
|
139
142
|
static func getHmsLocalAudioTrack(_ localAudio: HMSLocalAudioTrack) -> [String: Any] {
|
|
@@ -232,6 +235,7 @@ class HmsDecoder: NSObject {
|
|
|
232
235
|
let audioTrack = getHmsAudioTrack(hmsRemotePeer.audioTrack)
|
|
233
236
|
let videoTrack = getHmsVideoTrack(hmsRemotePeer.videoTrack)
|
|
234
237
|
let role = getHmsRole(hmsRemotePeer.role)
|
|
238
|
+
let networkQuality = getHmsNetworkQuality(hmsRemotePeer.networkQuality)
|
|
235
239
|
|
|
236
240
|
var auxiliaryTracks = [[String: Any]]()
|
|
237
241
|
|
|
@@ -252,7 +256,7 @@ class HmsDecoder: NSObject {
|
|
|
252
256
|
remoteVideoTrackData = getHMSRemoteVideoTrack(remoteVideo)
|
|
253
257
|
}
|
|
254
258
|
|
|
255
|
-
return ["peerID": peerID, "name": name, "isLocal": isLocal, "customerUserID": customerUserID, "customerDescription": customerDescription, "metadata": metadata, "audioTrack": audioTrack, "videoTrack": videoTrack, "auxiliaryTracks": auxiliaryTracks, "remoteAudioTrackData": remoteAudioTrackData, "remoteVideoTrackData": remoteVideoTrackData, "role": role]
|
|
259
|
+
return ["peerID": peerID, "name": name, "isLocal": isLocal, "customerUserID": customerUserID, "customerDescription": customerDescription, "metadata": metadata, "audioTrack": audioTrack, "videoTrack": videoTrack, "auxiliaryTracks": auxiliaryTracks, "remoteAudioTrackData": remoteAudioTrackData, "remoteVideoTrackData": remoteVideoTrackData, "role": role, "networkQuality": networkQuality]
|
|
256
260
|
}
|
|
257
261
|
|
|
258
262
|
static func getHMSRemoteAudioTrack(_ remoteAudio: HMSRemoteAudioTrack) -> [String: Any] {
|
|
@@ -589,6 +593,12 @@ class HmsDecoder: NSObject {
|
|
|
589
593
|
return ["recipientPeer": getHmsPeer(recipient.peerRecipient), "recipientRoles": getAllRoles(recipient.rolesRecipient), "type": self.getRecipientType(from: recipient.type)]
|
|
590
594
|
}
|
|
591
595
|
|
|
596
|
+
static func getHmsNetworkQuality(_ hmsNetworkQuality: HMSNetworkQuality?) -> [String: Any] {
|
|
597
|
+
guard let networkQuality = hmsNetworkQuality else { return [:] }
|
|
598
|
+
|
|
599
|
+
return ["downlinkQuality": networkQuality.downlinkQuality]
|
|
600
|
+
}
|
|
601
|
+
|
|
592
602
|
static private func getRecipientType(from recipientType: HMSMessageRecipientType) -> String {
|
|
593
603
|
switch recipientType {
|
|
594
604
|
case .broadcast:
|
package/ios/HmsSDK.swift
CHANGED
|
@@ -72,13 +72,15 @@ class HmsSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
let metadata = credentials.value(forKey: "metadata") as? String
|
|
75
|
+
let captureNetworkQualityInPreview = credentials.value(forKey: "captureNetworkQualityInPreview") as? Bool ?? false
|
|
76
|
+
|
|
75
77
|
DispatchQueue.main.async { [weak self] in
|
|
76
78
|
guard let strongSelf = self else { return }
|
|
77
79
|
if let endpoint = credentials.value(forKey: "endpoint") as? String {
|
|
78
|
-
strongSelf.config = HMSConfig(userName: user, authToken: authToken, metadata: metadata, endpoint: endpoint)
|
|
80
|
+
strongSelf.config = HMSConfig(userName: user, authToken: authToken, metadata: metadata, endpoint: endpoint, captureNetworkQualityInPreview: captureNetworkQualityInPreview)
|
|
79
81
|
strongSelf.hms?.preview(config: strongSelf.config!, delegate: strongSelf)
|
|
80
82
|
} else {
|
|
81
|
-
strongSelf.config = HMSConfig(userName: user, authToken: authToken, metadata: metadata)
|
|
83
|
+
strongSelf.config = HMSConfig(userName: user, authToken: authToken, metadata: metadata, captureNetworkQualityInPreview: captureNetworkQualityInPreview)
|
|
82
84
|
strongSelf.hms?.preview(config: strongSelf.config!, delegate: strongSelf)
|
|
83
85
|
}
|
|
84
86
|
strongSelf.previewInProgress = true
|
|
@@ -135,6 +137,7 @@ class HmsSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
135
137
|
}
|
|
136
138
|
|
|
137
139
|
let metadata = credentials.value(forKey: "metadata") as? String
|
|
140
|
+
let captureNetworkQualityInPreview = credentials.value(forKey: "captureNetworkQualityInPreview") as? Bool ?? false
|
|
138
141
|
|
|
139
142
|
DispatchQueue.main.async { [weak self] in
|
|
140
143
|
guard let strongSelf = self else { return }
|
|
@@ -142,10 +145,10 @@ class HmsSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
142
145
|
strongSelf.hms?.join(config: config, delegate: strongSelf)
|
|
143
146
|
} else {
|
|
144
147
|
if let endpoint = credentials.value(forKey: "endpoint") as? String {
|
|
145
|
-
strongSelf.config = HMSConfig(userName: user, authToken: authToken, metadata: metadata, endpoint: endpoint)
|
|
148
|
+
strongSelf.config = HMSConfig(userName: user, authToken: authToken, metadata: metadata, endpoint: endpoint, captureNetworkQualityInPreview: captureNetworkQualityInPreview)
|
|
146
149
|
strongSelf.hms?.join(config: strongSelf.config!, delegate: strongSelf)
|
|
147
150
|
} else {
|
|
148
|
-
strongSelf.config = HMSConfig(userName: user, authToken: authToken, metadata: metadata)
|
|
151
|
+
strongSelf.config = HMSConfig(userName: user, authToken: authToken, metadata: metadata, captureNetworkQualityInPreview: captureNetworkQualityInPreview)
|
|
149
152
|
strongSelf.hms?.join(config: strongSelf.config!, delegate: strongSelf)
|
|
150
153
|
}
|
|
151
154
|
}
|
|
@@ -950,6 +953,8 @@ class HmsSDK: HMSUpdateListener, HMSPreviewListener {
|
|
|
950
953
|
return "NAME_CHANGED"
|
|
951
954
|
case .defaultUpdate:
|
|
952
955
|
return "DEFAULT_UPDATE"
|
|
956
|
+
case .networkQualityUpdated:
|
|
957
|
+
return "NETWORK_QUALITY_UPDATED"
|
|
953
958
|
default:
|
|
954
959
|
return ""
|
|
955
960
|
}
|