@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
|
@@ -8,6 +8,7 @@ import kotlinx.coroutines.launch
|
|
|
8
8
|
import live.hms.video.audio.HMSAudioManager
|
|
9
9
|
import live.hms.video.connection.stats.*
|
|
10
10
|
import live.hms.video.error.HMSException
|
|
11
|
+
import live.hms.video.media.settings.HMSLayer
|
|
11
12
|
import live.hms.video.media.tracks.*
|
|
12
13
|
import live.hms.video.sdk.*
|
|
13
14
|
import live.hms.video.sdk.models.*
|
|
@@ -16,8 +17,13 @@ import live.hms.video.sdk.models.enums.HMSPeerUpdate
|
|
|
16
17
|
import live.hms.video.sdk.models.enums.HMSRoomUpdate
|
|
17
18
|
import live.hms.video.sdk.models.enums.HMSTrackUpdate
|
|
18
19
|
import live.hms.video.sdk.models.trackchangerequest.HMSChangeTrackStateRequest
|
|
20
|
+
import live.hms.video.signal.init.HMSTokenListener
|
|
21
|
+
import live.hms.video.signal.init.TokenRequest
|
|
22
|
+
import live.hms.video.signal.init.TokenRequestOptions
|
|
19
23
|
import live.hms.video.utils.HMSCoroutineScope
|
|
20
24
|
import live.hms.video.utils.HmsUtilities
|
|
25
|
+
import java.io.File
|
|
26
|
+
import java.util.Date
|
|
21
27
|
|
|
22
28
|
class HMSRNSDK(
|
|
23
29
|
data: ReadableMap?,
|
|
@@ -34,7 +40,6 @@ class HMSRNSDK(
|
|
|
34
40
|
private var context: ReactApplicationContext = reactApplicationContext
|
|
35
41
|
private var previewInProgress: Boolean = false
|
|
36
42
|
private var reconnectingStage: Boolean = false
|
|
37
|
-
private var rtcStatsAttached: Boolean = false
|
|
38
43
|
private var networkQualityUpdatesAttached: Boolean = false
|
|
39
44
|
private var audioMixingMode: AudioMixingMode = AudioMixingMode.TALK_AND_MUSIC
|
|
40
45
|
private var id: String = sdkId
|
|
@@ -430,18 +435,15 @@ class HMSRNSDK(
|
|
|
430
435
|
hmsTrack: HMSTrack?,
|
|
431
436
|
hmsPeer: HMSPeer?
|
|
432
437
|
) {
|
|
433
|
-
if (eventsEnableStatus["ON_LOCAL_AUDIO_STATS"] != true) {
|
|
438
|
+
if (eventsEnableStatus["ON_LOCAL_AUDIO_STATS"] != true || hmsPeer == null || hmsTrack == null) {
|
|
434
439
|
return
|
|
435
440
|
}
|
|
436
|
-
|
|
437
|
-
return
|
|
438
|
-
}
|
|
439
|
-
val localAudioStats = HMSDecoder.getLocalAudioStats(audioStats)
|
|
441
|
+
val localAudioStats = HMSDecoder.getLocalAudioStats(audioStats) // [bitrate, bytesSent, roundTripTime]
|
|
440
442
|
val track = HMSDecoder.getHmsLocalAudioTrack(hmsTrack as HMSLocalAudioTrack)
|
|
441
443
|
val peer = HMSDecoder.getHmsPeerSubset(hmsPeer)
|
|
442
444
|
|
|
443
445
|
val data: WritableMap = Arguments.createMap()
|
|
444
|
-
data.
|
|
446
|
+
data.putArray("localAudioStats", localAudioStats)
|
|
445
447
|
data.putMap("track", track)
|
|
446
448
|
data.putMap("peer", peer)
|
|
447
449
|
data.putString("id", id)
|
|
@@ -453,14 +455,10 @@ class HMSRNSDK(
|
|
|
453
455
|
hmsTrack: HMSTrack?,
|
|
454
456
|
hmsPeer: HMSPeer?
|
|
455
457
|
) {
|
|
456
|
-
if (eventsEnableStatus["ON_LOCAL_VIDEO_STATS"] != true) {
|
|
458
|
+
if (eventsEnableStatus["ON_LOCAL_VIDEO_STATS"] != true || hmsPeer == null || hmsTrack == null) {
|
|
457
459
|
return
|
|
458
460
|
}
|
|
459
|
-
|
|
460
|
-
return
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
val localVideoStats = HMSDecoder.getLocalVideoStats(videoStats)
|
|
461
|
+
val localVideoStats = HMSDecoder.getLocalVideoStats(videoStats) // List<[bitrate, bytesSent, roundTripTime, frameRate, resolution]>
|
|
464
462
|
val track = HMSDecoder.getHmsLocalVideoTrack(hmsTrack as HMSLocalVideoTrack)
|
|
465
463
|
val peer = HMSDecoder.getHmsPeerSubset(hmsPeer)
|
|
466
464
|
|
|
@@ -476,17 +474,14 @@ class HMSRNSDK(
|
|
|
476
474
|
if (eventsEnableStatus["ON_RTC_STATS"] != true) {
|
|
477
475
|
return
|
|
478
476
|
}
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
val video = HMSDecoder.getHMSRTCStats(rtcStats.video)
|
|
483
|
-
val audio = HMSDecoder.getHMSRTCStats(rtcStats.audio)
|
|
484
|
-
val combined = HMSDecoder.getHMSRTCStats(rtcStats.combined)
|
|
477
|
+
val video = HMSDecoder.getHMSRTCStats(rtcStats.video) // [bitrateReceived, bitrateSent, bytesReceived, bytesSent, packetsLost, packetsReceived, roundTripTime]
|
|
478
|
+
val audio = HMSDecoder.getHMSRTCStats(rtcStats.audio) // [bitrateReceived, bitrateSent, bytesReceived, bytesSent, packetsLost, packetsReceived, roundTripTime]
|
|
479
|
+
val combined = HMSDecoder.getHMSRTCStats(rtcStats.combined) // [bitrateReceived, bitrateSent, bytesReceived, bytesSent, packetsLost, packetsReceived, roundTripTime]
|
|
485
480
|
|
|
486
481
|
val data: WritableMap = Arguments.createMap()
|
|
487
|
-
data.
|
|
488
|
-
data.
|
|
489
|
-
data.
|
|
482
|
+
data.putArray("video", video)
|
|
483
|
+
data.putArray("audio", audio)
|
|
484
|
+
data.putArray("combined", combined)
|
|
490
485
|
data.putString("id", id)
|
|
491
486
|
delegate.emitEvent("ON_RTC_STATS", data)
|
|
492
487
|
}
|
|
@@ -496,19 +491,15 @@ class HMSRNSDK(
|
|
|
496
491
|
hmsTrack: HMSTrack?,
|
|
497
492
|
hmsPeer: HMSPeer?
|
|
498
493
|
) {
|
|
499
|
-
if (eventsEnableStatus["ON_REMOTE_AUDIO_STATS"] != true) {
|
|
500
|
-
return
|
|
501
|
-
}
|
|
502
|
-
if (!rtcStatsAttached) {
|
|
494
|
+
if (eventsEnableStatus["ON_REMOTE_AUDIO_STATS"] != true || hmsPeer == null || hmsTrack == null) {
|
|
503
495
|
return
|
|
504
496
|
}
|
|
505
|
-
|
|
506
|
-
val remoteAudioStats = HMSDecoder.getRemoteAudioStats(audioStats)
|
|
497
|
+
val remoteAudioStats = HMSDecoder.getRemoteAudioStats(audioStats) // [bitrate, bytesReceived, jitter, packetsLost, packetsReceived]
|
|
507
498
|
val track = HMSDecoder.getHmsRemoteAudioTrack(hmsTrack as HMSRemoteAudioTrack)
|
|
508
499
|
val peer = HMSDecoder.getHmsPeerSubset(hmsPeer)
|
|
509
500
|
|
|
510
501
|
val data: WritableMap = Arguments.createMap()
|
|
511
|
-
data.
|
|
502
|
+
data.putArray("remoteAudioStats", remoteAudioStats)
|
|
512
503
|
data.putMap("track", track)
|
|
513
504
|
data.putMap("peer", peer)
|
|
514
505
|
data.putString("id", id)
|
|
@@ -520,19 +511,15 @@ class HMSRNSDK(
|
|
|
520
511
|
hmsTrack: HMSTrack?,
|
|
521
512
|
hmsPeer: HMSPeer?
|
|
522
513
|
) {
|
|
523
|
-
if (eventsEnableStatus["ON_REMOTE_VIDEO_STATS"] != true) {
|
|
524
|
-
return
|
|
525
|
-
}
|
|
526
|
-
if (!rtcStatsAttached) {
|
|
514
|
+
if (eventsEnableStatus["ON_REMOTE_VIDEO_STATS"] != true || hmsPeer == null || hmsTrack == null) {
|
|
527
515
|
return
|
|
528
516
|
}
|
|
529
|
-
|
|
530
|
-
val remoteVideoStats = HMSDecoder.getRemoteVideoStats(videoStats)
|
|
517
|
+
val remoteVideoStats = HMSDecoder.getRemoteVideoStats(videoStats) // [bitrate, bytesReceived, frameRate, jitter, packetsLost, packetsReceived, resolution]
|
|
531
518
|
val track = HMSDecoder.getHmsRemoteVideoTrack(hmsTrack as HMSRemoteVideoTrack)
|
|
532
519
|
val peer = HMSDecoder.getHmsPeerSubset(hmsPeer)
|
|
533
520
|
|
|
534
521
|
val data: WritableMap = Arguments.createMap()
|
|
535
|
-
data.
|
|
522
|
+
data.putArray("remoteVideoStats", remoteVideoStats)
|
|
536
523
|
data.putMap("track", track)
|
|
537
524
|
data.putMap("peer", peer)
|
|
538
525
|
data.putString("id", id)
|
|
@@ -547,6 +534,41 @@ class HMSRNSDK(
|
|
|
547
534
|
}
|
|
548
535
|
}
|
|
549
536
|
|
|
537
|
+
fun getAuthTokenByRoomCode(data: ReadableMap, promise: Promise) {
|
|
538
|
+
val requiredKeys =
|
|
539
|
+
HMSHelper.getUnavailableRequiredKey(
|
|
540
|
+
data,
|
|
541
|
+
arrayOf(Pair("roomCode", "String"))
|
|
542
|
+
)
|
|
543
|
+
|
|
544
|
+
if (requiredKeys === null) {
|
|
545
|
+
val roomCode = data.getString("roomCode")!!
|
|
546
|
+
val userId = data.getString("userId")
|
|
547
|
+
val endpoint = data.getString("endpoint")
|
|
548
|
+
|
|
549
|
+
val tokenRequest = TokenRequest(roomCode, userId)
|
|
550
|
+
val tokenRequestOptions: TokenRequestOptions? = endpoint?.let { TokenRequestOptions(endpoint = it) }
|
|
551
|
+
|
|
552
|
+
hmsSDK?.getAuthTokenByRoomCode(
|
|
553
|
+
tokenRequest,
|
|
554
|
+
tokenRequestOptions,
|
|
555
|
+
object : HMSTokenListener {
|
|
556
|
+
override fun onError(error: HMSException) {
|
|
557
|
+
promise.reject(error.code.toString(), "${error.message}: ${error.description}")
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
override fun onTokenSuccess(string: String) {
|
|
561
|
+
promise.resolve(string)
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
)
|
|
565
|
+
} else {
|
|
566
|
+
val errorMessage = "getAuthTokenByRoomCode: $requiredKeys"
|
|
567
|
+
self.emitRequiredKeysError(errorMessage)
|
|
568
|
+
rejectCallback(promise, errorMessage)
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
|
|
550
572
|
fun setLocalMute(data: ReadableMap) {
|
|
551
573
|
val isMute = data.getBoolean("isMute")
|
|
552
574
|
hmsSDK?.getLocalPeer()?.audioTrack?.setMute(isMute)
|
|
@@ -580,7 +602,6 @@ class HMSRNSDK(
|
|
|
580
602
|
screenshareCallback = null
|
|
581
603
|
audioshareCallback = null
|
|
582
604
|
networkQualityUpdatesAttached = false
|
|
583
|
-
rtcStatsAttached = false
|
|
584
605
|
HMSDecoder.clearRestrictDataStates()
|
|
585
606
|
if (fromPIP) {
|
|
586
607
|
context.currentActivity?.moveTaskToBack(false)
|
|
@@ -1363,14 +1384,6 @@ class HMSRNSDK(
|
|
|
1363
1384
|
}
|
|
1364
1385
|
}
|
|
1365
1386
|
|
|
1366
|
-
fun enableRTCStats() {
|
|
1367
|
-
rtcStatsAttached = true
|
|
1368
|
-
}
|
|
1369
|
-
|
|
1370
|
-
fun disableRTCStats() {
|
|
1371
|
-
rtcStatsAttached = false
|
|
1372
|
-
}
|
|
1373
|
-
|
|
1374
1387
|
fun enableNetworkQualityUpdates() {
|
|
1375
1388
|
networkQualityUpdatesAttached = true
|
|
1376
1389
|
}
|
|
@@ -1544,7 +1557,9 @@ class HMSRNSDK(
|
|
|
1544
1557
|
val peerId = data.getString("peerId")!!
|
|
1545
1558
|
val property = data.getString("property")!!
|
|
1546
1559
|
|
|
1547
|
-
val
|
|
1560
|
+
val hmsRoom = nativeHmsSDK.getRoom()
|
|
1561
|
+
|
|
1562
|
+
val peer = HMSHelper.getPeerFromPeerId(peerId, hmsRoom)
|
|
1548
1563
|
|
|
1549
1564
|
if (peer !== null) {
|
|
1550
1565
|
val result: WritableMap = Arguments.createMap()
|
|
@@ -1702,4 +1717,183 @@ class HMSRNSDK(
|
|
|
1702
1717
|
rejectCallback(promise, errorMessage)
|
|
1703
1718
|
}
|
|
1704
1719
|
}
|
|
1720
|
+
|
|
1721
|
+
fun getRemoteVideoTrackFromTrackId(data: ReadableMap, promise: Promise) {
|
|
1722
|
+
val requiredKeys = HMSHelper.getUnavailableRequiredKey(data, arrayOf(Pair("trackId", "String")))
|
|
1723
|
+
if (requiredKeys === null) {
|
|
1724
|
+
val trackId = data.getString("trackId")
|
|
1725
|
+
val remoteVideoTrack = HMSHelper.getRemoteVideoTrackFromTrackId(trackId, hmsSDK?.getRoom())
|
|
1726
|
+
if (remoteVideoTrack === null) {
|
|
1727
|
+
promise.reject("101", "TRACK_NOT_FOUND")
|
|
1728
|
+
} else {
|
|
1729
|
+
promise.resolve(HMSDecoder.getHmsRemoteVideoTrack(remoteVideoTrack))
|
|
1730
|
+
}
|
|
1731
|
+
} else {
|
|
1732
|
+
val errorMessage = "getRemoteVideoTrackFromTrackId: $requiredKeys"
|
|
1733
|
+
self.emitRequiredKeysError(errorMessage)
|
|
1734
|
+
rejectCallback(promise, errorMessage)
|
|
1735
|
+
}
|
|
1736
|
+
}
|
|
1737
|
+
|
|
1738
|
+
fun getRemoteAudioTrackFromTrackId(data: ReadableMap, promise: Promise) {
|
|
1739
|
+
val requiredKeys = HMSHelper.getUnavailableRequiredKey(data, arrayOf(Pair("trackId", "String")))
|
|
1740
|
+
if (requiredKeys === null) {
|
|
1741
|
+
val trackId = data.getString("trackId")
|
|
1742
|
+
val remoteAudioTrack = HMSHelper.getRemoteAudioTrackFromTrackId(trackId, hmsSDK?.getRoom())
|
|
1743
|
+
if (remoteAudioTrack === null) {
|
|
1744
|
+
promise.reject("101", "TRACK_NOT_FOUND")
|
|
1745
|
+
} else {
|
|
1746
|
+
promise.resolve(HMSDecoder.getHmsRemoteAudioTrack(remoteAudioTrack))
|
|
1747
|
+
}
|
|
1748
|
+
} else {
|
|
1749
|
+
val errorMessage = "getRemoteAudioTrackFromTrackId: $requiredKeys"
|
|
1750
|
+
self.emitRequiredKeysError(errorMessage)
|
|
1751
|
+
rejectCallback(promise, errorMessage)
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1754
|
+
|
|
1755
|
+
fun getVideoTrackLayer(data: ReadableMap, promise: Promise) {
|
|
1756
|
+
val requiredKeys = HMSHelper.getUnavailableRequiredKey(data, arrayOf(Pair("trackId", "String")))
|
|
1757
|
+
if (requiredKeys === null) {
|
|
1758
|
+
val trackId = data.getString("trackId")
|
|
1759
|
+
val remoteVideoTrack = HMSHelper.getRemoteVideoTrackFromTrackId(trackId, hmsSDK?.getRoom())
|
|
1760
|
+
if (remoteVideoTrack === null) {
|
|
1761
|
+
promise.reject("101", "TRACK_NOT_FOUND")
|
|
1762
|
+
} else {
|
|
1763
|
+
val layer = remoteVideoTrack.getLayer()
|
|
1764
|
+
promise.resolve(layer.name)
|
|
1765
|
+
}
|
|
1766
|
+
} else {
|
|
1767
|
+
val errorMessage = "getVideoTrackLayer: $requiredKeys"
|
|
1768
|
+
self.emitRequiredKeysError(errorMessage)
|
|
1769
|
+
rejectCallback(promise, errorMessage)
|
|
1770
|
+
}
|
|
1771
|
+
}
|
|
1772
|
+
|
|
1773
|
+
fun getVideoTrackLayerDefinition(data: ReadableMap, promise: Promise) {
|
|
1774
|
+
val requiredKeys = HMSHelper.getUnavailableRequiredKey(data, arrayOf(Pair("trackId", "String")))
|
|
1775
|
+
if (requiredKeys === null) {
|
|
1776
|
+
val trackId = data.getString("trackId")
|
|
1777
|
+
val remoteVideoTrack = HMSHelper.getRemoteVideoTrackFromTrackId(trackId, hmsSDK?.getRoom())
|
|
1778
|
+
if (remoteVideoTrack === null) {
|
|
1779
|
+
promise.reject("101", "TRACK_NOT_FOUND")
|
|
1780
|
+
} else {
|
|
1781
|
+
val layerDefinition = remoteVideoTrack.getLayerDefinition()
|
|
1782
|
+
|
|
1783
|
+
promise.resolve(HMSDecoder.getSimulcastLayerDefinitions(layerDefinition))
|
|
1784
|
+
}
|
|
1785
|
+
} else {
|
|
1786
|
+
val errorMessage = "getVideoTrackLayerDefinition: $requiredKeys"
|
|
1787
|
+
self.emitRequiredKeysError(errorMessage)
|
|
1788
|
+
rejectCallback(promise, errorMessage)
|
|
1789
|
+
}
|
|
1790
|
+
}
|
|
1791
|
+
|
|
1792
|
+
fun setVideoTrackLayer(data: ReadableMap, promise: Promise?) {
|
|
1793
|
+
val requiredKeys = HMSHelper.getUnavailableRequiredKey(data, arrayOf(Pair("trackId", "String"), Pair("layer", "String")))
|
|
1794
|
+
if (requiredKeys === null) {
|
|
1795
|
+
val trackId = data.getString("trackId")
|
|
1796
|
+
val layerString = data.getString("layer")
|
|
1797
|
+
|
|
1798
|
+
if (HMSLayer.values().find { it.name == layerString } === null) {
|
|
1799
|
+
// DOUBT: which error to throw here?
|
|
1800
|
+
// emitError or 101 or 6000?
|
|
1801
|
+
promise?.reject("6000", "INVALID_LAYER")
|
|
1802
|
+
return
|
|
1803
|
+
}
|
|
1804
|
+
|
|
1805
|
+
val remoteVideoTrack = HMSHelper.getRemoteVideoTrackFromTrackId(trackId, hmsSDK?.getRoom())
|
|
1806
|
+
|
|
1807
|
+
if (remoteVideoTrack === null) {
|
|
1808
|
+
promise?.reject("101", "TRACK_NOT_FOUND")
|
|
1809
|
+
} else {
|
|
1810
|
+
val layer = HMSLayer.valueOf(layerString!!)
|
|
1811
|
+
remoteVideoTrack.setLayer(layer)
|
|
1812
|
+
promise?.resolve(true)
|
|
1813
|
+
}
|
|
1814
|
+
} else {
|
|
1815
|
+
val errorMessage = "setVideoTrackLayer: $requiredKeys"
|
|
1816
|
+
self.emitRequiredKeysError(errorMessage)
|
|
1817
|
+
rejectCallback(promise, errorMessage)
|
|
1818
|
+
}
|
|
1819
|
+
}
|
|
1820
|
+
|
|
1821
|
+
fun captureImageAtMaxSupportedResolution(data: ReadableMap, promise: Promise?) {
|
|
1822
|
+
val requiredKeys = HMSHelper.getUnavailableRequiredKey(data, arrayOf(Pair("flash", "Boolean")))
|
|
1823
|
+
if (requiredKeys === null) {
|
|
1824
|
+
val localPeer = hmsSDK?.getLocalPeer().let {
|
|
1825
|
+
if (it == null) {
|
|
1826
|
+
promise?.reject("6004", "An instance of Local Peer could not be found! Please check if a Room is joined.")
|
|
1827
|
+
return
|
|
1828
|
+
} else {
|
|
1829
|
+
it
|
|
1830
|
+
}
|
|
1831
|
+
}
|
|
1832
|
+
val localVideoTrack = localPeer.videoTrack.let {
|
|
1833
|
+
if (it == null) {
|
|
1834
|
+
promise?.reject("6004", "Video Track of Local Peer could not be found! Please check if the Local Peer has permission to publish video & video is unmuted currently.")
|
|
1835
|
+
return
|
|
1836
|
+
} else {
|
|
1837
|
+
it
|
|
1838
|
+
}
|
|
1839
|
+
}
|
|
1840
|
+
val cameraControl = localVideoTrack.getCameraControl().let {
|
|
1841
|
+
if (it == null) {
|
|
1842
|
+
promise?.reject("6004", "Camera Controls not available!")
|
|
1843
|
+
return
|
|
1844
|
+
} else {
|
|
1845
|
+
it
|
|
1846
|
+
}
|
|
1847
|
+
}
|
|
1848
|
+
|
|
1849
|
+
val flashSupported = cameraControl.isFlashSupported()
|
|
1850
|
+
var flashActionOnSuccess = 0 // 0 - Do nothing on success, 1 - set flash on, 2 - set flash off
|
|
1851
|
+
if (flashSupported) {
|
|
1852
|
+
val useFlash = data.getBoolean("flash")
|
|
1853
|
+
|
|
1854
|
+
val flashEnabled = cameraControl.isFlashEnabled()
|
|
1855
|
+
|
|
1856
|
+
// if flash option is true, and flash is already on
|
|
1857
|
+
// -> do nothing now and on success
|
|
1858
|
+
|
|
1859
|
+
// if flash option is true, and flash is off
|
|
1860
|
+
// -> turn it on and later turn it off
|
|
1861
|
+
if (useFlash && !flashEnabled) {
|
|
1862
|
+
cameraControl.setFlash(true)
|
|
1863
|
+
flashActionOnSuccess = 2
|
|
1864
|
+
}
|
|
1865
|
+
|
|
1866
|
+
// if flash option is false, and flash is on
|
|
1867
|
+
// -> turn it off and later turn it on
|
|
1868
|
+
if (!useFlash && flashEnabled) {
|
|
1869
|
+
cameraControl.setFlash(false)
|
|
1870
|
+
flashActionOnSuccess = 1
|
|
1871
|
+
}
|
|
1872
|
+
|
|
1873
|
+
// if flash option is false, and flash is off
|
|
1874
|
+
// -> do nothing now and on success
|
|
1875
|
+
}
|
|
1876
|
+
|
|
1877
|
+
val dir = context.getExternalFilesDir("images")
|
|
1878
|
+
val imagePath = "$dir/hms_${Date().time}.jpg"
|
|
1879
|
+
val savePath = File(imagePath)
|
|
1880
|
+
|
|
1881
|
+
cameraControl.captureImageAtMaxSupportedResolution(
|
|
1882
|
+
savePath
|
|
1883
|
+
) { success ->
|
|
1884
|
+
if (flashActionOnSuccess > 0) {
|
|
1885
|
+
cameraControl.setFlash(flashActionOnSuccess === 1)
|
|
1886
|
+
}
|
|
1887
|
+
if (success) {
|
|
1888
|
+
promise?.resolve(imagePath)
|
|
1889
|
+
} else {
|
|
1890
|
+
promise?.reject("6004", "Could Not Capture Image!")
|
|
1891
|
+
}
|
|
1892
|
+
}
|
|
1893
|
+
} else {
|
|
1894
|
+
val errorMessage = "captureImageAtMaxSupportedResolution: $requiredKeys"
|
|
1895
|
+
self.emitRequiredKeysError(errorMessage)
|
|
1896
|
+
rejectCallback(promise, errorMessage)
|
|
1897
|
+
}
|
|
1898
|
+
}
|
|
1705
1899
|
}
|
|
@@ -80,6 +80,11 @@ class HMSSDKViewManager : SimpleViewManager<HMSView>() {
|
|
|
80
80
|
view.updateZOrderMediaOverlay(data)
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
@ReactProp(name = "autoSimulcast")
|
|
84
|
+
fun setAutoSimulcast(view: HMSView, data: Boolean?) {
|
|
85
|
+
data?.let { view.updateAutoSimulcast(it) }
|
|
86
|
+
}
|
|
87
|
+
|
|
83
88
|
private fun getHms(): MutableMap<String, HMSRNSDK>? {
|
|
84
89
|
return reactContext?.getNativeModule(HMSManager::class.java)?.getHmsInstance()
|
|
85
90
|
}
|
|
@@ -13,30 +13,33 @@ import com.facebook.react.bridge.WritableMap
|
|
|
13
13
|
import com.facebook.react.uimanager.events.RCTEventEmitter
|
|
14
14
|
import live.hms.video.media.tracks.HMSVideoTrack
|
|
15
15
|
import live.hms.video.utils.HmsUtilities
|
|
16
|
-
import live.hms.
|
|
16
|
+
import live.hms.videoview.HMSVideoView
|
|
17
17
|
import org.webrtc.RendererCommon
|
|
18
|
-
import org.webrtc.SurfaceViewRenderer
|
|
19
18
|
|
|
20
19
|
@SuppressLint("ViewConstructor")
|
|
21
20
|
class HMSView(context: ReactContext) : FrameLayout(context) {
|
|
22
|
-
private var
|
|
21
|
+
private var hmsVideoView: HMSVideoView = HMSVideoView(context)
|
|
23
22
|
private var videoTrack: HMSVideoTrack? = null
|
|
24
23
|
private var scaleTypeApplied: Boolean = false
|
|
25
24
|
private var sdkId: String = "12345"
|
|
26
25
|
private var currentScaleType: RendererCommon.ScalingType =
|
|
27
|
-
|
|
26
|
+
RendererCommon.ScalingType.SCALE_ASPECT_FILL
|
|
27
|
+
private var disableAutoSimulcastLayerSelect = false
|
|
28
28
|
|
|
29
29
|
init {
|
|
30
30
|
val inflater = getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
|
|
31
31
|
val view = inflater.inflate(R.layout.hms_view, this)
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
hmsVideoView = view.findViewById(R.id.hmsVideoView)
|
|
34
|
+
hmsVideoView.setEnableHardwareScaler(false)
|
|
35
|
+
hmsVideoView.setScalingType(currentScaleType)
|
|
36
|
+
hmsVideoView.setMirror(false)
|
|
37
|
+
hmsVideoView.disableAutoSimulcastLayerSelect(disableAutoSimulcastLayerSelect)
|
|
35
38
|
}
|
|
36
39
|
|
|
37
40
|
@RequiresApi(Build.VERSION_CODES.N)
|
|
38
41
|
fun captureHmsView(args: ReadableArray?) {
|
|
39
|
-
HMSHelper.captureSurfaceView(
|
|
42
|
+
HMSHelper.captureSurfaceView(hmsVideoView, sdkId, args, context, id)
|
|
40
43
|
}
|
|
41
44
|
|
|
42
45
|
private fun onReceiveNativeEvent() {
|
|
@@ -48,14 +51,12 @@ class HMSView(context: ReactContext) : FrameLayout(context) {
|
|
|
48
51
|
|
|
49
52
|
override fun onDetachedFromWindow() {
|
|
50
53
|
super.onDetachedFromWindow()
|
|
51
|
-
|
|
52
|
-
surfaceView.release()
|
|
54
|
+
hmsVideoView.removeTrack()
|
|
53
55
|
}
|
|
54
56
|
|
|
55
57
|
override fun onAttachedToWindow() {
|
|
56
58
|
super.onAttachedToWindow()
|
|
57
|
-
|
|
58
|
-
videoTrack?.addSink(surfaceView)
|
|
59
|
+
hmsVideoView.addTrack(videoTrack!!) // DOUBT: Handle case when videoTrack is null
|
|
59
60
|
if (!scaleTypeApplied) {
|
|
60
61
|
if (currentScaleType != RendererCommon.ScalingType.SCALE_ASPECT_FILL) {
|
|
61
62
|
onReceiveNativeEvent()
|
|
@@ -66,8 +67,8 @@ class HMSView(context: ReactContext) : FrameLayout(context) {
|
|
|
66
67
|
|
|
67
68
|
fun updateZOrderMediaOverlay(setZOrderMediaOverlay: Boolean?) {
|
|
68
69
|
if (setZOrderMediaOverlay != null && setZOrderMediaOverlay) {
|
|
69
|
-
//
|
|
70
|
-
|
|
70
|
+
// hmsVideoView.setZOrderOnTop(true);
|
|
71
|
+
hmsVideoView.setZOrderMediaOverlay(setZOrderMediaOverlay)
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
74
|
|
|
@@ -75,17 +76,17 @@ class HMSView(context: ReactContext) : FrameLayout(context) {
|
|
|
75
76
|
if (scaleType != null) {
|
|
76
77
|
when (scaleType) {
|
|
77
78
|
"ASPECT_FIT" -> {
|
|
78
|
-
|
|
79
|
+
hmsVideoView.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FIT)
|
|
79
80
|
currentScaleType = RendererCommon.ScalingType.SCALE_ASPECT_FIT
|
|
80
81
|
return
|
|
81
82
|
}
|
|
82
83
|
"ASPECT_FILL" -> {
|
|
83
|
-
|
|
84
|
+
hmsVideoView.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FILL)
|
|
84
85
|
currentScaleType = RendererCommon.ScalingType.SCALE_ASPECT_FILL
|
|
85
86
|
return
|
|
86
87
|
}
|
|
87
88
|
"ASPECT_BALANCED" -> {
|
|
88
|
-
|
|
89
|
+
hmsVideoView.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_BALANCED)
|
|
89
90
|
currentScaleType = RendererCommon.ScalingType.SCALE_ASPECT_BALANCED
|
|
90
91
|
return
|
|
91
92
|
}
|
|
@@ -97,10 +98,10 @@ class HMSView(context: ReactContext) : FrameLayout(context) {
|
|
|
97
98
|
}
|
|
98
99
|
|
|
99
100
|
fun setData(
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
id: String?,
|
|
102
|
+
trackId: String?,
|
|
103
|
+
hmsCollection: MutableMap<String, HMSRNSDK>,
|
|
104
|
+
mirror: Boolean?
|
|
104
105
|
) {
|
|
105
106
|
if (id != null) {
|
|
106
107
|
sdkId = id
|
|
@@ -109,9 +110,16 @@ class HMSView(context: ReactContext) : FrameLayout(context) {
|
|
|
109
110
|
|
|
110
111
|
if (trackId != null && hms != null) {
|
|
111
112
|
if (mirror != null) {
|
|
112
|
-
|
|
113
|
+
hmsVideoView.setMirror(mirror)
|
|
113
114
|
}
|
|
115
|
+
// TODO: can be optimized here
|
|
114
116
|
videoTrack = hms.getRoom()?.let { HmsUtilities.getVideoTrack(trackId, it) }
|
|
115
117
|
}
|
|
116
118
|
}
|
|
119
|
+
|
|
120
|
+
fun updateAutoSimulcast(autoSimulcast: Boolean?) {
|
|
121
|
+
autoSimulcast?.let {
|
|
122
|
+
hmsVideoView.disableAutoSimulcastLayerSelect(!it)
|
|
123
|
+
}
|
|
124
|
+
}
|
|
117
125
|
}
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
android:layout_height="match_parent"
|
|
7
7
|
android:background="#000">
|
|
8
8
|
|
|
9
|
-
<
|
|
10
|
-
android:id="@+id/
|
|
9
|
+
<live.hms.videoview.HMSVideoView
|
|
10
|
+
android:id="@+id/hmsVideoView"
|
|
11
11
|
android:layout_width="wrap_content"
|
|
12
12
|
android:layout_height="wrap_content"
|
|
13
13
|
android:layout_gravity="center"
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
//
|
|
2
|
+
// HMSConstants.swift
|
|
3
|
+
// HMSSDK
|
|
4
|
+
//
|
|
5
|
+
// Created by Yogesh Singh on 27/12/22.
|
|
6
|
+
// Copyright © 2023 100ms. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
import Foundation
|
|
10
|
+
|
|
11
|
+
struct HMSConstants {
|
|
12
|
+
|
|
13
|
+
static let ON_PREVIEW = "ON_PREVIEW"
|
|
14
|
+
static let ON_JOIN = "ON_JOIN"
|
|
15
|
+
static let ON_ROOM_UPDATE = "ON_ROOM_UPDATE"
|
|
16
|
+
static let ON_PEER_UPDATE = "3"
|
|
17
|
+
static let ON_TRACK_UPDATE = "ON_TRACK_UPDATE"
|
|
18
|
+
static let ON_ROLE_CHANGE_REQUEST = "ON_ROLE_CHANGE_REQUEST"
|
|
19
|
+
static let ON_CHANGE_TRACK_STATE_REQUEST = "ON_CHANGE_TRACK_STATE_REQUEST" // new
|
|
20
|
+
static let ON_REMOVED_FROM_ROOM = "ON_REMOVED_FROM_ROOM"
|
|
21
|
+
static let ON_ERROR = "ON_ERROR"
|
|
22
|
+
static let ON_MESSAGE = "ON_MESSAGE"
|
|
23
|
+
static let ON_SPEAKER = "ON_SPEAKER"
|
|
24
|
+
static let RECONNECTING = "RECONNECTING"
|
|
25
|
+
static let RECONNECTED = "RECONNECTED"
|
|
26
|
+
static let ON_RTC_STATS = "ON_RTC_STATS"
|
|
27
|
+
static let ON_LOCAL_AUDIO_STATS = "ON_LOCAL_AUDIO_STATS"
|
|
28
|
+
static let ON_LOCAL_VIDEO_STATS = "ON_LOCAL_VIDEO_STATS"
|
|
29
|
+
static let ON_REMOTE_AUDIO_STATS = "ON_REMOTE_AUDIO_STATS"
|
|
30
|
+
static let ON_REMOTE_VIDEO_STATS = "ON_REMOTE_VIDEO_STATS"
|
|
31
|
+
}
|