@100mslive/react-native-hms 1.6.0 → 1.6.2
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 +1 -1
- package/android/src/main/java/com/reactnativehmssdk/HMSAudioshareActivity.kt +44 -44
- package/android/src/main/java/com/reactnativehmssdk/HMSDecoder.kt +12 -12
- package/android/src/main/java/com/reactnativehmssdk/HMSHelper.kt +35 -35
- package/android/src/main/java/com/reactnativehmssdk/HMSRNSDK.kt +11 -3
- package/android/src/main/java/com/reactnativehmssdk/HMSSDKViewManager.kt +4 -3
- package/android/src/main/java/com/reactnativehmssdk/HMSView.kt +31 -33
- package/android/src/main/java/com/reactnativehmssdk/HmsScreenshareActivity.kt +41 -41
- package/android/src/main/java/com/reactnativehmssdk/PipActionReceiver.kt +2 -2
- package/ios/HMSRNSDK.swift +4 -4
- package/lib/commonjs/classes/HMSAudioMixerSource.js.map +1 -1
- package/lib/commonjs/classes/HMSEncoder.js +1 -0
- package/lib/commonjs/classes/HMSEncoder.js.map +1 -1
- package/lib/commonjs/classes/HMSLocalAudioTrack.js.map +1 -1
- package/lib/commonjs/classes/HMSLocalVideoTrack.js.map +1 -1
- package/lib/commonjs/classes/HMSLogger.js.map +1 -1
- package/lib/commonjs/classes/HMSMessage.js +2 -1
- package/lib/commonjs/classes/HMSMessage.js.map +1 -1
- package/lib/commonjs/classes/HMSNativeEventEmitter.js.map +1 -1
- package/lib/commonjs/classes/HMSPeer.js.map +1 -1
- package/lib/commonjs/classes/HMSPeersCache.js.map +1 -1
- package/lib/commonjs/classes/HMSRemoteAudioTrack.js.map +1 -1
- package/lib/commonjs/classes/HMSRemoteVideoTrack.js.map +1 -1
- package/lib/commonjs/classes/HMSRoom.js.map +1 -1
- package/lib/commonjs/classes/HMSRoomCache.js.map +1 -1
- package/lib/commonjs/classes/HMSSDK.js +6 -3
- package/lib/commonjs/classes/HMSSDK.js.map +1 -1
- package/lib/commonjs/classes/HMSSessionStore.js.map +1 -1
- package/lib/commonjs/classes/HmsView.js +19 -29
- package/lib/commonjs/classes/HmsView.js.map +1 -1
- package/lib/commonjs/utils/emitter/EventEmitter.js.map +1 -1
- package/lib/module/classes/HMSAudioMixerSource.js.map +1 -1
- package/lib/module/classes/HMSEncoder.js +1 -0
- package/lib/module/classes/HMSEncoder.js.map +1 -1
- package/lib/module/classes/HMSLocalAudioTrack.js.map +1 -1
- package/lib/module/classes/HMSLocalVideoTrack.js.map +1 -1
- package/lib/module/classes/HMSLogger.js.map +1 -1
- package/lib/module/classes/HMSMessage.js +2 -1
- package/lib/module/classes/HMSMessage.js.map +1 -1
- package/lib/module/classes/HMSNativeEventEmitter.js.map +1 -1
- package/lib/module/classes/HMSPeer.js.map +1 -1
- package/lib/module/classes/HMSPeersCache.js.map +1 -1
- package/lib/module/classes/HMSRemoteAudioTrack.js.map +1 -1
- package/lib/module/classes/HMSRemoteVideoTrack.js.map +1 -1
- package/lib/module/classes/HMSRoom.js.map +1 -1
- package/lib/module/classes/HMSRoomCache.js.map +1 -1
- package/lib/module/classes/HMSSDK.js +6 -3
- package/lib/module/classes/HMSSDK.js.map +1 -1
- package/lib/module/classes/HMSSessionStore.js.map +1 -1
- package/lib/module/classes/HmsView.js +21 -31
- package/lib/module/classes/HmsView.js.map +1 -1
- package/lib/module/utils/emitter/EventEmitter.js.map +1 -1
- package/lib/typescript/classes/HMSMessage.d.ts +2 -0
- package/lib/typescript/classes/HMSSDK.d.ts +9 -3
- package/package.json +7 -5
- package/sdk-versions.json +2 -2
- package/src/classes/HMSEncoder.ts +1 -0
- package/src/classes/HMSMessage.ts +3 -1
- package/src/classes/HMSSDK.tsx +26 -17
- package/src/classes/HmsView.tsx +21 -32
package/android/build.gradle
CHANGED
|
@@ -13,44 +13,44 @@ import live.hms.video.sdk.HMSActionResultListener
|
|
|
13
13
|
|
|
14
14
|
class HMSAudioshareActivity : ComponentActivity() {
|
|
15
15
|
private var resultLauncher: ActivityResultLauncher<Intent> =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
)
|
|
33
|
-
finish()
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
mediaProjectionPermissionResultData,
|
|
37
|
-
HMSHelper.getAudioMixingMode(audioMixingMode)
|
|
38
|
-
)
|
|
39
|
-
} else {
|
|
40
|
-
val id = intent.getStringExtra("id")
|
|
41
|
-
val error =
|
|
42
|
-
HMSException(
|
|
43
|
-
103,
|
|
44
|
-
"RESULT_CANCELED",
|
|
45
|
-
"RESULT_CANCELED",
|
|
46
|
-
"RESULT_CANCELED",
|
|
47
|
-
"RESULT_CANCELED"
|
|
16
|
+
this.registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
|
|
17
|
+
if (result.resultCode == Activity.RESULT_OK) {
|
|
18
|
+
val mediaProjectionPermissionResultData: Intent? = result.data
|
|
19
|
+
val id = intent.getStringExtra("id")
|
|
20
|
+
val audioMixingMode = intent.getStringExtra("audioMixingMode")
|
|
21
|
+
HMSManager.hmsCollection[id]?.hmsSDK?.startAudioshare(
|
|
22
|
+
object : HMSActionResultListener {
|
|
23
|
+
override fun onError(error: HMSException) {
|
|
24
|
+
finish()
|
|
25
|
+
HMSManager.hmsCollection[id]?.audioshareCallback?.reject(error)
|
|
26
|
+
HMSManager.hmsCollection[id]?.emitHMSError(error)
|
|
27
|
+
}
|
|
28
|
+
override fun onSuccess() {
|
|
29
|
+
HMSManager.hmsCollection[id]?.isAudioSharing = true
|
|
30
|
+
HMSManager.hmsCollection[id]?.audioshareCallback?.resolve(
|
|
31
|
+
HMSManager.hmsCollection[id]?.emitHMSSuccess(),
|
|
48
32
|
)
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
33
|
+
finish()
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
mediaProjectionPermissionResultData,
|
|
37
|
+
HMSHelper.getAudioMixingMode(audioMixingMode),
|
|
38
|
+
)
|
|
39
|
+
} else {
|
|
40
|
+
val id = intent.getStringExtra("id")
|
|
41
|
+
val error =
|
|
42
|
+
HMSException(
|
|
43
|
+
103,
|
|
44
|
+
"RESULT_CANCELED",
|
|
45
|
+
"RESULT_CANCELED",
|
|
46
|
+
"RESULT_CANCELED",
|
|
47
|
+
"RESULT_CANCELED",
|
|
48
|
+
)
|
|
49
|
+
HMSManager.hmsCollection[id]?.audioshareCallback?.reject(error)
|
|
50
|
+
HMSManager.hmsCollection[id]?.emitHMSError(error)
|
|
51
|
+
finish()
|
|
53
52
|
}
|
|
53
|
+
}
|
|
54
54
|
|
|
55
55
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
56
56
|
super.onCreate(savedInstanceState)
|
|
@@ -63,20 +63,20 @@ class HMSAudioshareActivity : ComponentActivity() {
|
|
|
63
63
|
if (isAudioShared !== null && !isAudioShared) {
|
|
64
64
|
try {
|
|
65
65
|
val mediaProjectionManager =
|
|
66
|
-
|
|
66
|
+
getSystemService(Context.MEDIA_PROJECTION_SERVICE) as MediaProjectionManager
|
|
67
67
|
resultLauncher.launch(mediaProjectionManager.createScreenCaptureIntent())
|
|
68
68
|
} catch (e: Exception) {
|
|
69
69
|
println(e)
|
|
70
70
|
}
|
|
71
71
|
} else {
|
|
72
72
|
HMSManager.hmsCollection[id]?.emitHMSError(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
73
|
+
HMSException(
|
|
74
|
+
103,
|
|
75
|
+
"AUDIOSHARE_IS_ALREADY_RUNNING",
|
|
76
|
+
"AUDIOSHARE_IS_ALREADY_RUNNING",
|
|
77
|
+
"AUDIOSHARE_IS_ALREADY_RUNNING",
|
|
78
|
+
"AUDIOSHARE_IS_ALREADY_RUNNING",
|
|
79
|
+
),
|
|
80
80
|
)
|
|
81
81
|
finish()
|
|
82
82
|
}
|
|
@@ -42,7 +42,7 @@ object HMSDecoder {
|
|
|
42
42
|
hmsRoom.browserRecordingState?.let {
|
|
43
43
|
room.putMap(
|
|
44
44
|
"browserRecordingState",
|
|
45
|
-
this.getHMSBrowserRecordingState(it)
|
|
45
|
+
this.getHMSBrowserRecordingState(it),
|
|
46
46
|
)
|
|
47
47
|
}
|
|
48
48
|
}
|
|
@@ -55,7 +55,7 @@ object HMSDecoder {
|
|
|
55
55
|
hmsRoom.rtmpHMSRtmpStreamingState?.let {
|
|
56
56
|
room.putMap(
|
|
57
57
|
"rtmpHMSRtmpStreamingState",
|
|
58
|
-
this.getHMSRtmpStreamingState(it)
|
|
58
|
+
this.getHMSRtmpStreamingState(it),
|
|
59
59
|
)
|
|
60
60
|
}
|
|
61
61
|
}
|
|
@@ -63,7 +63,7 @@ object HMSDecoder {
|
|
|
63
63
|
hmsRoom.serverRecordingState?.let {
|
|
64
64
|
room.putMap(
|
|
65
65
|
"serverRecordingState",
|
|
66
|
-
this.getHMSServerRecordingState(it)
|
|
66
|
+
this.getHMSServerRecordingState(it),
|
|
67
67
|
)
|
|
68
68
|
}
|
|
69
69
|
}
|
|
@@ -88,21 +88,21 @@ object HMSDecoder {
|
|
|
88
88
|
hmsRoom.browserRecordingState?.let {
|
|
89
89
|
room.putMap(
|
|
90
90
|
"browserRecordingState",
|
|
91
|
-
this.getHMSBrowserRecordingState(it)
|
|
91
|
+
this.getHMSBrowserRecordingState(it),
|
|
92
92
|
)
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
hmsRoom.rtmpHMSRtmpStreamingState?.let {
|
|
96
96
|
room.putMap(
|
|
97
97
|
"rtmpHMSRtmpStreamingState",
|
|
98
|
-
this.getHMSRtmpStreamingState(it)
|
|
98
|
+
this.getHMSRtmpStreamingState(it),
|
|
99
99
|
)
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
hmsRoom.serverRecordingState?.let {
|
|
103
103
|
room.putMap(
|
|
104
104
|
"serverRecordingState",
|
|
105
|
-
this.getHMSServerRecordingState(it)
|
|
105
|
+
this.getHMSServerRecordingState(it),
|
|
106
106
|
)
|
|
107
107
|
}
|
|
108
108
|
|
|
@@ -445,7 +445,7 @@ object HMSDecoder {
|
|
|
445
445
|
if (hmsAudioTrackSettings != null) {
|
|
446
446
|
settings.putBoolean(
|
|
447
447
|
"useHardwareAcousticEchoCanceler",
|
|
448
|
-
hmsAudioTrackSettings.useHardwareAcousticEchoCanceler
|
|
448
|
+
hmsAudioTrackSettings.useHardwareAcousticEchoCanceler,
|
|
449
449
|
)
|
|
450
450
|
settings.putString("initialState", hmsAudioTrackSettings.initialState.name)
|
|
451
451
|
}
|
|
@@ -689,28 +689,28 @@ object HMSDecoder {
|
|
|
689
689
|
|
|
690
690
|
subscribeSettings.putArray(
|
|
691
691
|
"subscribeTo",
|
|
692
|
-
this.getWriteableArray(hmsSubscribeSettings.subscribeTo)
|
|
692
|
+
this.getWriteableArray(hmsSubscribeSettings.subscribeTo),
|
|
693
693
|
)
|
|
694
694
|
}
|
|
695
695
|
return subscribeSettings
|
|
696
696
|
}
|
|
697
697
|
|
|
698
698
|
private fun getHmsSubscribeDegradationSettings(
|
|
699
|
-
hmsSubscribeDegradationParams: SubscribeDegradationParams
|
|
699
|
+
hmsSubscribeDegradationParams: SubscribeDegradationParams?,
|
|
700
700
|
): WritableMap {
|
|
701
701
|
val subscribeDegradationParams: WritableMap = Arguments.createMap()
|
|
702
702
|
if (hmsSubscribeDegradationParams != null) {
|
|
703
703
|
subscribeDegradationParams.putString(
|
|
704
704
|
"degradeGracePeriodSeconds",
|
|
705
|
-
hmsSubscribeDegradationParams.degradeGracePeriodSeconds.toString()
|
|
705
|
+
hmsSubscribeDegradationParams.degradeGracePeriodSeconds.toString(),
|
|
706
706
|
)
|
|
707
707
|
subscribeDegradationParams.putString(
|
|
708
708
|
"packetLossThreshold",
|
|
709
|
-
hmsSubscribeDegradationParams.packetLossThreshold.toString()
|
|
709
|
+
hmsSubscribeDegradationParams.packetLossThreshold.toString(),
|
|
710
710
|
)
|
|
711
711
|
subscribeDegradationParams.putString(
|
|
712
712
|
"recoverGracePeriodSeconds",
|
|
713
|
-
hmsSubscribeDegradationParams.recoverGracePeriodSeconds.toString()
|
|
713
|
+
hmsSubscribeDegradationParams.recoverGracePeriodSeconds.toString(),
|
|
714
714
|
)
|
|
715
715
|
}
|
|
716
716
|
return subscribeDegradationParams
|
|
@@ -32,7 +32,7 @@ object HMSHelper {
|
|
|
32
32
|
|
|
33
33
|
fun areAllRequiredKeysAvailable(
|
|
34
34
|
map: ReadableMap?,
|
|
35
|
-
requiredKeys: Array<Pair<String, String
|
|
35
|
+
requiredKeys: Array<Pair<String, String>>,
|
|
36
36
|
): Boolean {
|
|
37
37
|
if (map == null) {
|
|
38
38
|
return false
|
|
@@ -65,7 +65,7 @@ object HMSHelper {
|
|
|
65
65
|
|
|
66
66
|
fun getUnavailableRequiredKey(
|
|
67
67
|
map: ReadableMap?,
|
|
68
|
-
requiredKeys: Array<Pair<String, String
|
|
68
|
+
requiredKeys: Array<Pair<String, String>>,
|
|
69
69
|
): String? {
|
|
70
70
|
if (map == null) {
|
|
71
71
|
return "Object_Is_Null"
|
|
@@ -112,7 +112,7 @@ object HMSHelper {
|
|
|
112
112
|
|
|
113
113
|
fun getRolesFromRoleNames(
|
|
114
114
|
targetedRoles: ArrayList<String>?,
|
|
115
|
-
roles: List<HMSRole
|
|
115
|
+
roles: List<HMSRole>?,
|
|
116
116
|
): List<HMSRole> {
|
|
117
117
|
val encodedRoles: MutableList<HMSRole> = mutableListOf()
|
|
118
118
|
|
|
@@ -163,9 +163,9 @@ object HMSHelper {
|
|
|
163
163
|
fun getFrameworkInfo(data: ReadableMap?): FrameworkInfo? {
|
|
164
164
|
if (data != null &&
|
|
165
165
|
this.areAllRequiredKeysAvailable(
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
166
|
+
data,
|
|
167
|
+
arrayOf(Pair("version", "String"), Pair("sdkVersion", "String")),
|
|
168
|
+
)
|
|
169
169
|
) {
|
|
170
170
|
val version = data.getString("version") as String
|
|
171
171
|
val sdkVersion = data.getString("sdkVersion") as String
|
|
@@ -177,13 +177,13 @@ object HMSHelper {
|
|
|
177
177
|
fun getLogSettings(data: ReadableMap?): HMSLogSettings? {
|
|
178
178
|
if (data != null &&
|
|
179
179
|
this.areAllRequiredKeysAvailable(
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
180
|
+
data,
|
|
181
|
+
arrayOf(
|
|
182
|
+
Pair("level", "String"),
|
|
183
|
+
Pair("maxDirSizeInBytes", "String"),
|
|
184
|
+
Pair("isLogStorageEnabled", "Boolean"),
|
|
185
|
+
),
|
|
186
|
+
)
|
|
187
187
|
) {
|
|
188
188
|
val level = getLogLevel(data.getString("level"))
|
|
189
189
|
val maxDirSizeInBytes = getLogAlarmManager(data.getString("maxDirSizeInBytes"))
|
|
@@ -370,7 +370,7 @@ object HMSHelper {
|
|
|
370
370
|
}
|
|
371
371
|
|
|
372
372
|
private fun getHMSHLSMeetingURLVariants(
|
|
373
|
-
hmsMeetingURLVariants: ArrayList<HashMap<String, String
|
|
373
|
+
hmsMeetingURLVariants: ArrayList<HashMap<String, String>>?,
|
|
374
374
|
): List<HMSHLSMeetingURLVariant> {
|
|
375
375
|
val meetingURLVariants = mutableListOf<HMSHLSMeetingURLVariant>()
|
|
376
376
|
if (hmsMeetingURLVariants !== null) {
|
|
@@ -388,14 +388,14 @@ object HMSHelper {
|
|
|
388
388
|
var videoOnDemand = false
|
|
389
389
|
if (areAllRequiredKeysAvailable(
|
|
390
390
|
hmsHlsRecordingConfig,
|
|
391
|
-
arrayOf(Pair("singleFilePerLayer", "Boolean"))
|
|
391
|
+
arrayOf(Pair("singleFilePerLayer", "Boolean")),
|
|
392
392
|
)
|
|
393
393
|
) {
|
|
394
394
|
singleFilePerLayer = hmsHlsRecordingConfig.getBoolean("singleFilePerLayer")
|
|
395
395
|
}
|
|
396
396
|
if (areAllRequiredKeysAvailable(
|
|
397
397
|
hmsHlsRecordingConfig,
|
|
398
|
-
arrayOf(Pair("videoOnDemand", "Boolean"))
|
|
398
|
+
arrayOf(Pair("videoOnDemand", "Boolean")),
|
|
399
399
|
)
|
|
400
400
|
) {
|
|
401
401
|
videoOnDemand = hmsHlsRecordingConfig.getBoolean("videoOnDemand")
|
|
@@ -406,7 +406,7 @@ object HMSHelper {
|
|
|
406
406
|
}
|
|
407
407
|
|
|
408
408
|
private fun getHMSHLSMeetingURLVariant(
|
|
409
|
-
hmsMeetingURLVariant: HashMap<String, String
|
|
409
|
+
hmsMeetingURLVariant: HashMap<String, String>?,
|
|
410
410
|
): HMSHLSMeetingURLVariant {
|
|
411
411
|
var meetingURLVariant = HMSHLSMeetingURLVariant("", "")
|
|
412
412
|
if (hmsMeetingURLVariant !== null) {
|
|
@@ -453,7 +453,7 @@ object HMSHelper {
|
|
|
453
453
|
var config =
|
|
454
454
|
HMSConfig(
|
|
455
455
|
credentials.getString("username") as String,
|
|
456
|
-
credentials.getString("authToken") as String
|
|
456
|
+
credentials.getString("authToken") as String,
|
|
457
457
|
)
|
|
458
458
|
|
|
459
459
|
when {
|
|
@@ -462,8 +462,8 @@ object HMSHelper {
|
|
|
462
462
|
arrayOf(
|
|
463
463
|
Pair("endpoint", "String"),
|
|
464
464
|
Pair("metadata", "String"),
|
|
465
|
-
Pair("captureNetworkQualityInPreview", "Boolean")
|
|
466
|
-
)
|
|
465
|
+
Pair("captureNetworkQualityInPreview", "Boolean"),
|
|
466
|
+
),
|
|
467
467
|
) -> {
|
|
468
468
|
config =
|
|
469
469
|
HMSConfig(
|
|
@@ -472,24 +472,24 @@ object HMSHelper {
|
|
|
472
472
|
initEndpoint = credentials.getString("endpoint") as String,
|
|
473
473
|
metadata = credentials.getString("metadata") as String,
|
|
474
474
|
captureNetworkQualityInPreview =
|
|
475
|
-
credentials.getBoolean("captureNetworkQualityInPreview")
|
|
475
|
+
credentials.getBoolean("captureNetworkQualityInPreview"),
|
|
476
476
|
)
|
|
477
477
|
}
|
|
478
478
|
areAllRequiredKeysAvailable(
|
|
479
479
|
credentials,
|
|
480
|
-
arrayOf(Pair("endpoint", "String"), Pair("metadata", "String"))
|
|
480
|
+
arrayOf(Pair("endpoint", "String"), Pair("metadata", "String")),
|
|
481
481
|
) -> {
|
|
482
482
|
config =
|
|
483
483
|
HMSConfig(
|
|
484
484
|
credentials.getString("username") as String,
|
|
485
485
|
credentials.getString("authToken") as String,
|
|
486
486
|
initEndpoint = credentials.getString("endpoint") as String,
|
|
487
|
-
metadata = credentials.getString("metadata") as String
|
|
487
|
+
metadata = credentials.getString("metadata") as String,
|
|
488
488
|
)
|
|
489
489
|
}
|
|
490
490
|
areAllRequiredKeysAvailable(
|
|
491
491
|
credentials,
|
|
492
|
-
arrayOf(Pair("endpoint", "String"), Pair("captureNetworkQualityInPreview", "Boolean"))
|
|
492
|
+
arrayOf(Pair("endpoint", "String"), Pair("captureNetworkQualityInPreview", "Boolean")),
|
|
493
493
|
) -> {
|
|
494
494
|
config =
|
|
495
495
|
HMSConfig(
|
|
@@ -497,12 +497,12 @@ object HMSHelper {
|
|
|
497
497
|
credentials.getString("authToken") as String,
|
|
498
498
|
initEndpoint = credentials.getString("endpoint") as String,
|
|
499
499
|
captureNetworkQualityInPreview =
|
|
500
|
-
credentials.getBoolean("captureNetworkQualityInPreview")
|
|
500
|
+
credentials.getBoolean("captureNetworkQualityInPreview"),
|
|
501
501
|
)
|
|
502
502
|
}
|
|
503
503
|
areAllRequiredKeysAvailable(
|
|
504
504
|
credentials,
|
|
505
|
-
arrayOf(Pair("metadata", "String"), Pair("captureNetworkQualityInPreview", "Boolean"))
|
|
505
|
+
arrayOf(Pair("metadata", "String"), Pair("captureNetworkQualityInPreview", "Boolean")),
|
|
506
506
|
) -> {
|
|
507
507
|
config =
|
|
508
508
|
HMSConfig(
|
|
@@ -510,7 +510,7 @@ object HMSHelper {
|
|
|
510
510
|
credentials.getString("authToken") as String,
|
|
511
511
|
metadata = credentials.getString("metadata") as String,
|
|
512
512
|
captureNetworkQualityInPreview =
|
|
513
|
-
credentials.getBoolean("captureNetworkQualityInPreview")
|
|
513
|
+
credentials.getBoolean("captureNetworkQualityInPreview"),
|
|
514
514
|
)
|
|
515
515
|
}
|
|
516
516
|
areAllRequiredKeysAvailable(credentials, arrayOf(Pair("endpoint", "String"))) -> {
|
|
@@ -518,7 +518,7 @@ object HMSHelper {
|
|
|
518
518
|
HMSConfig(
|
|
519
519
|
credentials.getString("username") as String,
|
|
520
520
|
credentials.getString("authToken") as String,
|
|
521
|
-
initEndpoint = credentials.getString("endpoint") as String
|
|
521
|
+
initEndpoint = credentials.getString("endpoint") as String,
|
|
522
522
|
)
|
|
523
523
|
}
|
|
524
524
|
areAllRequiredKeysAvailable(credentials, arrayOf(Pair("metadata", "String"))) -> {
|
|
@@ -526,19 +526,19 @@ object HMSHelper {
|
|
|
526
526
|
HMSConfig(
|
|
527
527
|
credentials.getString("username") as String,
|
|
528
528
|
credentials.getString("authToken") as String,
|
|
529
|
-
metadata = credentials.getString("metadata") as String
|
|
529
|
+
metadata = credentials.getString("metadata") as String,
|
|
530
530
|
)
|
|
531
531
|
}
|
|
532
532
|
areAllRequiredKeysAvailable(
|
|
533
533
|
credentials,
|
|
534
|
-
arrayOf(Pair("captureNetworkQualityInPreview", "Boolean"))
|
|
534
|
+
arrayOf(Pair("captureNetworkQualityInPreview", "Boolean")),
|
|
535
535
|
) -> {
|
|
536
536
|
config =
|
|
537
537
|
HMSConfig(
|
|
538
538
|
credentials.getString("username") as String,
|
|
539
539
|
credentials.getString("authToken") as String,
|
|
540
540
|
captureNetworkQualityInPreview =
|
|
541
|
-
credentials.getBoolean("captureNetworkQualityInPreview")
|
|
541
|
+
credentials.getBoolean("captureNetworkQualityInPreview"),
|
|
542
542
|
)
|
|
543
543
|
}
|
|
544
544
|
}
|
|
@@ -552,7 +552,7 @@ object HMSHelper {
|
|
|
552
552
|
sdkId: String,
|
|
553
553
|
args: ReadableArray?,
|
|
554
554
|
context: Context,
|
|
555
|
-
id: Int
|
|
555
|
+
id: Int,
|
|
556
556
|
) {
|
|
557
557
|
val output = Arguments.createMap()
|
|
558
558
|
if (args != null) {
|
|
@@ -587,8 +587,8 @@ object HMSHelper {
|
|
|
587
587
|
copyResult.toString(),
|
|
588
588
|
copyResult.toString(),
|
|
589
589
|
copyResult.toString(),
|
|
590
|
-
copyResult.toString()
|
|
591
|
-
)
|
|
590
|
+
copyResult.toString(),
|
|
591
|
+
),
|
|
592
592
|
)
|
|
593
593
|
output.putString("error", copyResult.toString())
|
|
594
594
|
reactContext
|
|
@@ -596,7 +596,7 @@ object HMSHelper {
|
|
|
596
596
|
.receiveEvent(id, "captureFrame", output)
|
|
597
597
|
}
|
|
598
598
|
},
|
|
599
|
-
Handler()
|
|
599
|
+
Handler(),
|
|
600
600
|
)
|
|
601
601
|
} catch (e: Exception) {
|
|
602
602
|
Log.e("captureSurfaceView", "error: $e")
|
|
@@ -150,6 +150,13 @@ class HMSRNSDK(
|
|
|
150
150
|
return data
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
+
fun emitHMSMessageSuccess(hmsMessage: HMSMessage): ReadableMap {
|
|
154
|
+
val data: WritableMap = Arguments.createMap()
|
|
155
|
+
data.putString("message", hmsMessage.message)
|
|
156
|
+
data.putString("messageId", hmsMessage.messageId)
|
|
157
|
+
return data
|
|
158
|
+
}
|
|
159
|
+
|
|
153
160
|
fun preview(credentials: ReadableMap) {
|
|
154
161
|
if (previewInProgress) {
|
|
155
162
|
self.emitCustomError("PREVIEW_IS_IN_PROGRESS")
|
|
@@ -377,6 +384,7 @@ class HMSRNSDK(
|
|
|
377
384
|
|
|
378
385
|
data.putMap("sender", HMSDecoder.getHmsPeerSubset(message.sender))
|
|
379
386
|
data.putString("message", message.message)
|
|
387
|
+
data.putString("messageId", message.messageId)
|
|
380
388
|
data.putString("type", message.type)
|
|
381
389
|
data.putString("time", message.serverReceiveTime.toString())
|
|
382
390
|
data.putString("id", id)
|
|
@@ -670,7 +678,7 @@ class HMSRNSDK(
|
|
|
670
678
|
callback?.reject(error.code.toString(), error.message)
|
|
671
679
|
}
|
|
672
680
|
override fun onSuccess(hmsMessage: HMSMessage) {
|
|
673
|
-
callback?.resolve(
|
|
681
|
+
callback?.resolve(emitHMSMessageSuccess(hmsMessage))
|
|
674
682
|
}
|
|
675
683
|
},
|
|
676
684
|
)
|
|
@@ -702,7 +710,7 @@ class HMSRNSDK(
|
|
|
702
710
|
callback?.reject(error.code.toString(), error.message)
|
|
703
711
|
}
|
|
704
712
|
override fun onSuccess(hmsMessage: HMSMessage) {
|
|
705
|
-
callback?.resolve(
|
|
713
|
+
callback?.resolve(emitHMSMessageSuccess(hmsMessage))
|
|
706
714
|
}
|
|
707
715
|
},
|
|
708
716
|
)
|
|
@@ -733,7 +741,7 @@ class HMSRNSDK(
|
|
|
733
741
|
callback?.reject(error.code.toString(), error.message)
|
|
734
742
|
}
|
|
735
743
|
override fun onSuccess(hmsMessage: HMSMessage) {
|
|
736
|
-
callback?.resolve(
|
|
744
|
+
callback?.resolve(emitHMSMessageSuccess(hmsMessage))
|
|
737
745
|
}
|
|
738
746
|
},
|
|
739
747
|
)
|
|
@@ -28,7 +28,7 @@ class HMSSDKViewManager : SimpleViewManager<HMSView>() {
|
|
|
28
28
|
return MapBuilder.builder<String, Any>()
|
|
29
29
|
.put(
|
|
30
30
|
"topChange",
|
|
31
|
-
MapBuilder.of("phasedRegistrationNames", MapBuilder.of("bubbled", "onChange"))
|
|
31
|
+
MapBuilder.of("phasedRegistrationNames", MapBuilder.of("bubbled", "onChange")),
|
|
32
32
|
)
|
|
33
33
|
.build()
|
|
34
34
|
}
|
|
@@ -36,7 +36,7 @@ class HMSSDKViewManager : SimpleViewManager<HMSView>() {
|
|
|
36
36
|
override fun getExportedCustomDirectEventTypeConstants(): MutableMap<String, Any>? {
|
|
37
37
|
return MapBuilder.of(
|
|
38
38
|
"captureFrame",
|
|
39
|
-
MapBuilder.of("registrationName", "onDataReturned")
|
|
39
|
+
MapBuilder.of("registrationName", "onDataReturned"),
|
|
40
40
|
)
|
|
41
41
|
}
|
|
42
42
|
|
|
@@ -64,9 +64,10 @@ class HMSSDKViewManager : SimpleViewManager<HMSView>() {
|
|
|
64
64
|
val trackId = data.getString("trackId")
|
|
65
65
|
val id = data.getString("id")
|
|
66
66
|
val mirror = data.getBoolean("mirror")
|
|
67
|
+
val scaleType = data.getString("scaleType")
|
|
67
68
|
val hmsCollection = getHms()
|
|
68
69
|
if (hmsCollection != null) {
|
|
69
|
-
view.setData(id, trackId, hmsCollection, mirror)
|
|
70
|
+
view.setData(id, trackId, hmsCollection, mirror, scaleType)
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
73
|
|
|
@@ -15,57 +15,56 @@ import com.facebook.react.uimanager.events.RCTEventEmitter
|
|
|
15
15
|
import live.hms.video.media.tracks.HMSVideoTrack
|
|
16
16
|
import live.hms.video.utils.HmsUtilities
|
|
17
17
|
import live.hms.videoview.HMSVideoView
|
|
18
|
+
import live.hms.videoview.VideoViewStateChangeListener
|
|
18
19
|
import org.webrtc.RendererCommon
|
|
19
20
|
|
|
20
21
|
@SuppressLint("ViewConstructor")
|
|
21
22
|
class HMSView(context: ReactContext) : FrameLayout(context) {
|
|
22
|
-
private var hmsVideoView: HMSVideoView =
|
|
23
|
+
private var hmsVideoView: HMSVideoView? = null
|
|
23
24
|
private var videoTrack: HMSVideoTrack? = null
|
|
24
|
-
private var scaleTypeApplied: Boolean = false
|
|
25
25
|
private var sdkId: String = "12345"
|
|
26
|
-
private var currentScaleType: RendererCommon.ScalingType =
|
|
27
|
-
RendererCommon.ScalingType.SCALE_ASPECT_FILL
|
|
28
26
|
private var disableAutoSimulcastLayerSelect = false
|
|
27
|
+
private var jsCanApplyStyles = false
|
|
29
28
|
|
|
30
29
|
init {
|
|
31
30
|
val inflater = getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
|
|
32
31
|
val view = inflater.inflate(R.layout.hms_view, this)
|
|
33
32
|
|
|
34
33
|
hmsVideoView = view.findViewById(R.id.hmsVideoView)
|
|
35
|
-
hmsVideoView
|
|
36
|
-
|
|
37
|
-
hmsVideoView
|
|
38
|
-
hmsVideoView
|
|
34
|
+
hmsVideoView?.setEnableHardwareScaler(false)
|
|
35
|
+
|
|
36
|
+
hmsVideoView?.setMirror(false)
|
|
37
|
+
hmsVideoView?.disableAutoSimulcastLayerSelect(disableAutoSimulcastLayerSelect)
|
|
38
|
+
|
|
39
|
+
hmsVideoView?.addVideoViewStateChangeListener(object : VideoViewStateChangeListener {
|
|
40
|
+
override fun onResolutionChange(newWidth: Int, newHeight: Int) {
|
|
41
|
+
super.onResolutionChange(newWidth, newHeight)
|
|
42
|
+
if (!jsCanApplyStyles) {
|
|
43
|
+
val event: WritableMap = Arguments.createMap()
|
|
44
|
+
context.getJSModule(RCTEventEmitter::class.java).receiveEvent(id, "topChange", event)
|
|
45
|
+
jsCanApplyStyles = true
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
})
|
|
39
49
|
}
|
|
40
50
|
|
|
41
51
|
@RequiresApi(Build.VERSION_CODES.N)
|
|
42
52
|
fun captureHmsView(args: ReadableArray?) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
private fun onReceiveNativeEvent() {
|
|
47
|
-
val event: WritableMap = Arguments.createMap()
|
|
48
|
-
event.putString("message", "MyMessage")
|
|
49
|
-
val reactContext = context as ReactContext
|
|
50
|
-
reactContext.getJSModule(RCTEventEmitter::class.java).receiveEvent(id, "topChange", event)
|
|
53
|
+
hmsVideoView?.let {
|
|
54
|
+
HMSHelper.captureSurfaceView(it, sdkId, args, context, id)
|
|
55
|
+
}
|
|
51
56
|
}
|
|
52
57
|
|
|
53
58
|
override fun onDetachedFromWindow() {
|
|
54
59
|
super.onDetachedFromWindow()
|
|
55
|
-
hmsVideoView
|
|
60
|
+
hmsVideoView?.removeTrack()
|
|
56
61
|
}
|
|
57
62
|
|
|
58
63
|
override fun onAttachedToWindow() {
|
|
59
64
|
super.onAttachedToWindow()
|
|
60
65
|
|
|
61
66
|
videoTrack?.let { // Safe Call Operator to check if videoTrack is not null
|
|
62
|
-
hmsVideoView
|
|
63
|
-
if (!scaleTypeApplied) { // check if the scaleTypeApplied flag is false
|
|
64
|
-
if (currentScaleType != RendererCommon.ScalingType.SCALE_ASPECT_FILL) { // check if the currentScaleType is not SCALE_ASPECT_FILL
|
|
65
|
-
onReceiveNativeEvent() // call the onReceiveNativeEvent function
|
|
66
|
-
}
|
|
67
|
-
scaleTypeApplied = true // set the scaleTypeApplied flag to true
|
|
68
|
-
}
|
|
67
|
+
hmsVideoView?.addTrack(it) // add the videoTrack to the hmsVideoView
|
|
69
68
|
} ?: run { // Elvis Operator to handle the case when videoTrack is null
|
|
70
69
|
Log.e(
|
|
71
70
|
"HMSView",
|
|
@@ -77,7 +76,7 @@ class HMSView(context: ReactContext) : FrameLayout(context) {
|
|
|
77
76
|
fun updateZOrderMediaOverlay(setZOrderMediaOverlay: Boolean?) {
|
|
78
77
|
if (setZOrderMediaOverlay != null && setZOrderMediaOverlay) {
|
|
79
78
|
// hmsVideoView.setZOrderOnTop(true);
|
|
80
|
-
hmsVideoView
|
|
79
|
+
hmsVideoView?.setZOrderMediaOverlay(setZOrderMediaOverlay)
|
|
81
80
|
}
|
|
82
81
|
}
|
|
83
82
|
|
|
@@ -85,18 +84,15 @@ class HMSView(context: ReactContext) : FrameLayout(context) {
|
|
|
85
84
|
if (scaleType != null) {
|
|
86
85
|
when (scaleType) {
|
|
87
86
|
"ASPECT_FIT" -> {
|
|
88
|
-
hmsVideoView
|
|
89
|
-
currentScaleType = RendererCommon.ScalingType.SCALE_ASPECT_FIT
|
|
87
|
+
hmsVideoView?.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FIT)
|
|
90
88
|
return
|
|
91
89
|
}
|
|
92
90
|
"ASPECT_FILL" -> {
|
|
93
|
-
hmsVideoView
|
|
94
|
-
currentScaleType = RendererCommon.ScalingType.SCALE_ASPECT_FILL
|
|
91
|
+
hmsVideoView?.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FILL)
|
|
95
92
|
return
|
|
96
93
|
}
|
|
97
94
|
"ASPECT_BALANCED" -> {
|
|
98
|
-
hmsVideoView
|
|
99
|
-
currentScaleType = RendererCommon.ScalingType.SCALE_ASPECT_BALANCED
|
|
95
|
+
hmsVideoView?.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_BALANCED)
|
|
100
96
|
return
|
|
101
97
|
}
|
|
102
98
|
else -> {
|
|
@@ -111,6 +107,7 @@ class HMSView(context: ReactContext) : FrameLayout(context) {
|
|
|
111
107
|
trackId: String?,
|
|
112
108
|
hmsCollection: MutableMap<String, HMSRNSDK>,
|
|
113
109
|
mirror: Boolean?,
|
|
110
|
+
scaleType: String?,
|
|
114
111
|
) {
|
|
115
112
|
if (id != null) {
|
|
116
113
|
sdkId = id
|
|
@@ -119,8 +116,9 @@ class HMSView(context: ReactContext) : FrameLayout(context) {
|
|
|
119
116
|
|
|
120
117
|
if (trackId != null && hms != null) {
|
|
121
118
|
if (mirror != null) {
|
|
122
|
-
hmsVideoView
|
|
119
|
+
hmsVideoView?.setMirror(mirror)
|
|
123
120
|
}
|
|
121
|
+
updateScaleType(scaleType)
|
|
124
122
|
// TODO: can be optimized here
|
|
125
123
|
videoTrack = hms.getRoom()?.let { HmsUtilities.getVideoTrack(trackId, it) }
|
|
126
124
|
}
|
|
@@ -128,7 +126,7 @@ class HMSView(context: ReactContext) : FrameLayout(context) {
|
|
|
128
126
|
|
|
129
127
|
fun updateAutoSimulcast(autoSimulcast: Boolean?) {
|
|
130
128
|
autoSimulcast?.let {
|
|
131
|
-
hmsVideoView
|
|
129
|
+
hmsVideoView?.disableAutoSimulcastLayerSelect(!it)
|
|
132
130
|
}
|
|
133
131
|
}
|
|
134
132
|
}
|