@100mslive/react-native-hms 1.4.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/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 +42 -14
- package/android/src/main/java/com/reactnativehmssdk/HMSRNSDK.kt +202 -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 +9 -2
- package/ios/HMSManager.swift +142 -74
- package/ios/HMSRNSDK.swift +393 -181
- package/ios/HMSView.m +1 -0
- package/ios/HMSView.swift +21 -19
- 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/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/HMSPeer.js +1 -1
- 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 -3
- 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 +32 -45
- 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/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/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/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/HMSPeer.js +1 -1
- 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 -3
- 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 +33 -45
- 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/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 +5 -31
- 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 +1 -1
- 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 +54 -48
- 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.*
|
|
@@ -21,6 +22,8 @@ import live.hms.video.signal.init.TokenRequest
|
|
|
21
22
|
import live.hms.video.signal.init.TokenRequestOptions
|
|
22
23
|
import live.hms.video.utils.HMSCoroutineScope
|
|
23
24
|
import live.hms.video.utils.HmsUtilities
|
|
25
|
+
import java.io.File
|
|
26
|
+
import java.util.Date
|
|
24
27
|
|
|
25
28
|
class HMSRNSDK(
|
|
26
29
|
data: ReadableMap?,
|
|
@@ -37,7 +40,6 @@ class HMSRNSDK(
|
|
|
37
40
|
private var context: ReactApplicationContext = reactApplicationContext
|
|
38
41
|
private var previewInProgress: Boolean = false
|
|
39
42
|
private var reconnectingStage: Boolean = false
|
|
40
|
-
private var rtcStatsAttached: Boolean = false
|
|
41
43
|
private var networkQualityUpdatesAttached: Boolean = false
|
|
42
44
|
private var audioMixingMode: AudioMixingMode = AudioMixingMode.TALK_AND_MUSIC
|
|
43
45
|
private var id: String = sdkId
|
|
@@ -433,18 +435,15 @@ class HMSRNSDK(
|
|
|
433
435
|
hmsTrack: HMSTrack?,
|
|
434
436
|
hmsPeer: HMSPeer?
|
|
435
437
|
) {
|
|
436
|
-
if (eventsEnableStatus["ON_LOCAL_AUDIO_STATS"] != true) {
|
|
438
|
+
if (eventsEnableStatus["ON_LOCAL_AUDIO_STATS"] != true || hmsPeer == null || hmsTrack == null) {
|
|
437
439
|
return
|
|
438
440
|
}
|
|
439
|
-
|
|
440
|
-
return
|
|
441
|
-
}
|
|
442
|
-
val localAudioStats = HMSDecoder.getLocalAudioStats(audioStats)
|
|
441
|
+
val localAudioStats = HMSDecoder.getLocalAudioStats(audioStats) // [bitrate, bytesSent, roundTripTime]
|
|
443
442
|
val track = HMSDecoder.getHmsLocalAudioTrack(hmsTrack as HMSLocalAudioTrack)
|
|
444
443
|
val peer = HMSDecoder.getHmsPeerSubset(hmsPeer)
|
|
445
444
|
|
|
446
445
|
val data: WritableMap = Arguments.createMap()
|
|
447
|
-
data.
|
|
446
|
+
data.putArray("localAudioStats", localAudioStats)
|
|
448
447
|
data.putMap("track", track)
|
|
449
448
|
data.putMap("peer", peer)
|
|
450
449
|
data.putString("id", id)
|
|
@@ -456,14 +455,10 @@ class HMSRNSDK(
|
|
|
456
455
|
hmsTrack: HMSTrack?,
|
|
457
456
|
hmsPeer: HMSPeer?
|
|
458
457
|
) {
|
|
459
|
-
if (eventsEnableStatus["ON_LOCAL_VIDEO_STATS"] != true) {
|
|
460
|
-
return
|
|
461
|
-
}
|
|
462
|
-
if (!rtcStatsAttached && hmsPeer != null && hmsTrack != null) {
|
|
458
|
+
if (eventsEnableStatus["ON_LOCAL_VIDEO_STATS"] != true || hmsPeer == null || hmsTrack == null) {
|
|
463
459
|
return
|
|
464
460
|
}
|
|
465
|
-
|
|
466
|
-
val localVideoStats = HMSDecoder.getLocalVideoStats(videoStats)
|
|
461
|
+
val localVideoStats = HMSDecoder.getLocalVideoStats(videoStats) // List<[bitrate, bytesSent, roundTripTime, frameRate, resolution]>
|
|
467
462
|
val track = HMSDecoder.getHmsLocalVideoTrack(hmsTrack as HMSLocalVideoTrack)
|
|
468
463
|
val peer = HMSDecoder.getHmsPeerSubset(hmsPeer)
|
|
469
464
|
|
|
@@ -479,17 +474,14 @@ class HMSRNSDK(
|
|
|
479
474
|
if (eventsEnableStatus["ON_RTC_STATS"] != true) {
|
|
480
475
|
return
|
|
481
476
|
}
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
val video = HMSDecoder.getHMSRTCStats(rtcStats.video)
|
|
486
|
-
val audio = HMSDecoder.getHMSRTCStats(rtcStats.audio)
|
|
487
|
-
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]
|
|
488
480
|
|
|
489
481
|
val data: WritableMap = Arguments.createMap()
|
|
490
|
-
data.
|
|
491
|
-
data.
|
|
492
|
-
data.
|
|
482
|
+
data.putArray("video", video)
|
|
483
|
+
data.putArray("audio", audio)
|
|
484
|
+
data.putArray("combined", combined)
|
|
493
485
|
data.putString("id", id)
|
|
494
486
|
delegate.emitEvent("ON_RTC_STATS", data)
|
|
495
487
|
}
|
|
@@ -499,19 +491,15 @@ class HMSRNSDK(
|
|
|
499
491
|
hmsTrack: HMSTrack?,
|
|
500
492
|
hmsPeer: HMSPeer?
|
|
501
493
|
) {
|
|
502
|
-
if (eventsEnableStatus["ON_REMOTE_AUDIO_STATS"] != true) {
|
|
494
|
+
if (eventsEnableStatus["ON_REMOTE_AUDIO_STATS"] != true || hmsPeer == null || hmsTrack == null) {
|
|
503
495
|
return
|
|
504
496
|
}
|
|
505
|
-
|
|
506
|
-
return
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
val remoteAudioStats = HMSDecoder.getRemoteAudioStats(audioStats)
|
|
497
|
+
val remoteAudioStats = HMSDecoder.getRemoteAudioStats(audioStats) // [bitrate, bytesReceived, jitter, packetsLost, packetsReceived]
|
|
510
498
|
val track = HMSDecoder.getHmsRemoteAudioTrack(hmsTrack as HMSRemoteAudioTrack)
|
|
511
499
|
val peer = HMSDecoder.getHmsPeerSubset(hmsPeer)
|
|
512
500
|
|
|
513
501
|
val data: WritableMap = Arguments.createMap()
|
|
514
|
-
data.
|
|
502
|
+
data.putArray("remoteAudioStats", remoteAudioStats)
|
|
515
503
|
data.putMap("track", track)
|
|
516
504
|
data.putMap("peer", peer)
|
|
517
505
|
data.putString("id", id)
|
|
@@ -523,19 +511,15 @@ class HMSRNSDK(
|
|
|
523
511
|
hmsTrack: HMSTrack?,
|
|
524
512
|
hmsPeer: HMSPeer?
|
|
525
513
|
) {
|
|
526
|
-
if (eventsEnableStatus["ON_REMOTE_VIDEO_STATS"] != true) {
|
|
527
|
-
return
|
|
528
|
-
}
|
|
529
|
-
if (!rtcStatsAttached) {
|
|
514
|
+
if (eventsEnableStatus["ON_REMOTE_VIDEO_STATS"] != true || hmsPeer == null || hmsTrack == null) {
|
|
530
515
|
return
|
|
531
516
|
}
|
|
532
|
-
|
|
533
|
-
val remoteVideoStats = HMSDecoder.getRemoteVideoStats(videoStats)
|
|
517
|
+
val remoteVideoStats = HMSDecoder.getRemoteVideoStats(videoStats) // [bitrate, bytesReceived, frameRate, jitter, packetsLost, packetsReceived, resolution]
|
|
534
518
|
val track = HMSDecoder.getHmsRemoteVideoTrack(hmsTrack as HMSRemoteVideoTrack)
|
|
535
519
|
val peer = HMSDecoder.getHmsPeerSubset(hmsPeer)
|
|
536
520
|
|
|
537
521
|
val data: WritableMap = Arguments.createMap()
|
|
538
|
-
data.
|
|
522
|
+
data.putArray("remoteVideoStats", remoteVideoStats)
|
|
539
523
|
data.putMap("track", track)
|
|
540
524
|
data.putMap("peer", peer)
|
|
541
525
|
data.putString("id", id)
|
|
@@ -618,7 +602,6 @@ class HMSRNSDK(
|
|
|
618
602
|
screenshareCallback = null
|
|
619
603
|
audioshareCallback = null
|
|
620
604
|
networkQualityUpdatesAttached = false
|
|
621
|
-
rtcStatsAttached = false
|
|
622
605
|
HMSDecoder.clearRestrictDataStates()
|
|
623
606
|
if (fromPIP) {
|
|
624
607
|
context.currentActivity?.moveTaskToBack(false)
|
|
@@ -1401,14 +1384,6 @@ class HMSRNSDK(
|
|
|
1401
1384
|
}
|
|
1402
1385
|
}
|
|
1403
1386
|
|
|
1404
|
-
fun enableRTCStats() {
|
|
1405
|
-
rtcStatsAttached = true
|
|
1406
|
-
}
|
|
1407
|
-
|
|
1408
|
-
fun disableRTCStats() {
|
|
1409
|
-
rtcStatsAttached = false
|
|
1410
|
-
}
|
|
1411
|
-
|
|
1412
1387
|
fun enableNetworkQualityUpdates() {
|
|
1413
1388
|
networkQualityUpdatesAttached = true
|
|
1414
1389
|
}
|
|
@@ -1582,7 +1557,9 @@ class HMSRNSDK(
|
|
|
1582
1557
|
val peerId = data.getString("peerId")!!
|
|
1583
1558
|
val property = data.getString("property")!!
|
|
1584
1559
|
|
|
1585
|
-
val
|
|
1560
|
+
val hmsRoom = nativeHmsSDK.getRoom()
|
|
1561
|
+
|
|
1562
|
+
val peer = HMSHelper.getPeerFromPeerId(peerId, hmsRoom)
|
|
1586
1563
|
|
|
1587
1564
|
if (peer !== null) {
|
|
1588
1565
|
val result: WritableMap = Arguments.createMap()
|
|
@@ -1740,4 +1717,183 @@ class HMSRNSDK(
|
|
|
1740
1717
|
rejectCallback(promise, errorMessage)
|
|
1741
1718
|
}
|
|
1742
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
|
+
}
|
|
1743
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
|
+
}
|