Skip to content

Commit

Permalink
Merge pull request #605 from 100mslive/develop
Browse files Browse the repository at this point in the history
Release 0.9.3: Develop to main
  • Loading branch information
ygit authored Apr 5, 2022
2 parents 1ba691a + d7e2c25 commit 81bde18
Show file tree
Hide file tree
Showing 37 changed files with 2,658 additions and 1,047 deletions.
12 changes: 12 additions & 0 deletions android/src/main/java/com/reactnativehmssdk/HmsDecoder.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.reactnativehmssdk

import com.facebook.react.bridge.*
import live.hms.video.connection.stats.quality.HMSNetworkQuality
import live.hms.video.error.HMSException
import live.hms.video.media.settings.HMSAudioTrackSettings
import live.hms.video.media.settings.HMSVideoResolution
Expand Down Expand Up @@ -47,6 +48,7 @@ object HmsDecoder {
peer.putBoolean("isLocal", hmsPeer.isLocal)
peer.putString("customerUserID", hmsPeer.customerUserID)
peer.putString("metadata", hmsPeer.metadata)
peer.putMap("networkQuality", this.getHmsNetworkQuality(hmsPeer.networkQuality))
peer.putMap("audioTrack", this.getHmsAudioTrack(hmsPeer.audioTrack))
peer.putMap("videoTrack", this.getHmsVideoTrack(hmsPeer.videoTrack))
peer.putMap("role", this.getHmsRole(hmsPeer.hmsRole))
Expand Down Expand Up @@ -182,6 +184,7 @@ object HmsDecoder {
peer.putBoolean("isLocal", hmsLocalPeer.isLocal)
peer.putString("customerUserID", hmsLocalPeer.customerUserID)
peer.putString("metadata", hmsLocalPeer.metadata)
peer.putMap("networkQuality", this.getHmsNetworkQuality(hmsLocalPeer.networkQuality))
peer.putMap("audioTrack", this.getHmsAudioTrack(hmsLocalPeer.audioTrack))
peer.putMap("videoTrack", this.getHmsVideoTrack(hmsLocalPeer.videoTrack))
peer.putMap("role", this.getHmsRole(hmsLocalPeer.hmsRole))
Expand Down Expand Up @@ -276,6 +279,7 @@ object HmsDecoder {
peer.putBoolean("isLocal", hmsRemotePeer.isLocal)
peer.putString("customerUserID", hmsRemotePeer.customerUserID)
peer.putString("metadata", hmsRemotePeer.metadata)
peer.putMap("networkQuality", this.getHmsNetworkQuality(hmsRemotePeer.networkQuality))
peer.putMap("audioTrack", this.getHmsAudioTrack(hmsRemotePeer.audioTrack))
peer.putMap("videoTrack", this.getHmsVideoTrack(hmsRemotePeer.videoTrack))
peer.putMap("role", this.getHmsRole(hmsRemotePeer.hmsRole))
Expand Down Expand Up @@ -508,4 +512,12 @@ object HmsDecoder {
}
return hmsRecipient
}

private fun getHmsNetworkQuality(networkQuality: HMSNetworkQuality?): WritableMap {
val hmsNetworkQuality: WritableMap = Arguments.createMap()
if (networkQuality != null) {
hmsNetworkQuality.putInt("downlinkQuality", networkQuality.downlinkQuality)
}
return hmsNetworkQuality
}
}
96 changes: 96 additions & 0 deletions android/src/main/java/com/reactnativehmssdk/HmsHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -307,4 +307,100 @@ object HmsHelper {
}
return meetingURLVariant
}

fun getHmsConfig(credentials: ReadableMap): HMSConfig {
var config =
HMSConfig(
credentials.getString("username") as String,
credentials.getString("authToken") as String,
)

when {
areAllRequiredKeysAvailable(
credentials,
arrayOf(
Pair("endpoint", "String"),
Pair("metadata", "String"),
Pair("captureNetworkQualityInPreview", "Boolean")
)
) -> {
config =
HMSConfig(
credentials.getString("username") as String,
credentials.getString("authToken") as String,
initEndpoint = credentials.getString("endpoint") as String,
metadata = credentials.getString("metadata") as String,
captureNetworkQualityInPreview =
credentials.getBoolean("captureNetworkQualityInPreview"),
)
}
areAllRequiredKeysAvailable(
credentials,
arrayOf(Pair("endpoint", "String"), Pair("metadata", "String"))
) -> {
config =
HMSConfig(
credentials.getString("username") as String,
credentials.getString("authToken") as String,
initEndpoint = credentials.getString("endpoint") as String,
metadata = credentials.getString("metadata") as String,
)
}
areAllRequiredKeysAvailable(
credentials,
arrayOf(Pair("endpoint", "String"), Pair("captureNetworkQualityInPreview", "Boolean"))
) -> {
config =
HMSConfig(
credentials.getString("username") as String,
credentials.getString("authToken") as String,
initEndpoint = credentials.getString("endpoint") as String,
captureNetworkQualityInPreview =
credentials.getBoolean("captureNetworkQualityInPreview"),
)
}
areAllRequiredKeysAvailable(
credentials,
arrayOf(Pair("metadata", "String"), Pair("captureNetworkQualityInPreview", "Boolean"))
) -> {
config =
HMSConfig(
credentials.getString("username") as String,
credentials.getString("authToken") as String,
metadata = credentials.getString("metadata") as String,
captureNetworkQualityInPreview =
credentials.getBoolean("captureNetworkQualityInPreview"),
)
}
areAllRequiredKeysAvailable(credentials, arrayOf(Pair("endpoint", "String"))) -> {
config =
HMSConfig(
credentials.getString("username") as String,
credentials.getString("authToken") as String,
initEndpoint = credentials.getString("endpoint") as String,
)
}
areAllRequiredKeysAvailable(credentials, arrayOf(Pair("metadata", "String"))) -> {
config =
HMSConfig(
credentials.getString("username") as String,
credentials.getString("authToken") as String,
metadata = credentials.getString("metadata") as String,
)
}
areAllRequiredKeysAvailable(
credentials,
arrayOf(Pair("captureNetworkQualityInPreview", "Boolean"))
) -> {
config =
HMSConfig(
credentials.getString("username") as String,
credentials.getString("authToken") as String,
captureNetworkQualityInPreview =
credentials.getBoolean("captureNetworkQualityInPreview")
)
}
}
return config
}
}
74 changes: 2 additions & 72 deletions android/src/main/java/com/reactnativehmssdk/HmsSDK.kt
Original file line number Diff line number Diff line change
Expand Up @@ -97,42 +97,7 @@ class HmsSDK(
)
if (requiredKeys) {
previewInProgress = true
var config =
HMSConfig(
credentials.getString("username") as String,
credentials.getString("authToken") as String,
)

when {
HmsHelper.areAllRequiredKeysAvailable(
credentials,
arrayOf(Pair("endpoint", "String"), Pair("metadata", "String"))
) -> {
config =
HMSConfig(
credentials.getString("username") as String,
credentials.getString("authToken") as String,
initEndpoint = credentials.getString("endpoint") as String,
metadata = credentials.getString("metadata") as String,
)
}
HmsHelper.areAllRequiredKeysAvailable(credentials, arrayOf(Pair("endpoint", "String"))) -> {
config =
HMSConfig(
credentials.getString("username") as String,
credentials.getString("authToken") as String,
initEndpoint = credentials.getString("endpoint") as String,
)
}
HmsHelper.areAllRequiredKeysAvailable(credentials, arrayOf(Pair("metadata", "String"))) -> {
config =
HMSConfig(
credentials.getString("username") as String,
credentials.getString("authToken") as String,
metadata = credentials.getString("metadata") as String,
)
}
}
val config = HmsHelper.getHmsConfig(credentials)

hmsSDK?.preview(
config,
Expand Down Expand Up @@ -217,42 +182,7 @@ class HmsSDK(
arrayOf(Pair("username", "String"), Pair("authToken", "String"))
)
if (requiredKeys) {
var config =
HMSConfig(
credentials.getString("username") as String,
credentials.getString("authToken") as String
)

when {
HmsHelper.areAllRequiredKeysAvailable(
credentials,
arrayOf(Pair("endpoint", "String"), Pair("metadata", "String"))
) -> {
config =
HMSConfig(
credentials.getString("username") as String,
credentials.getString("authToken") as String,
initEndpoint = credentials.getString("endpoint") as String,
metadata = credentials.getString("metadata") as String,
)
}
HmsHelper.areAllRequiredKeysAvailable(credentials, arrayOf(Pair("endpoint", "String"))) -> {
config =
HMSConfig(
credentials.getString("username") as String,
credentials.getString("authToken") as String,
initEndpoint = credentials.getString("endpoint") as String,
)
}
HmsHelper.areAllRequiredKeysAvailable(credentials, arrayOf(Pair("metadata", "String"))) -> {
config =
HMSConfig(
credentials.getString("username") as String,
credentials.getString("authToken") as String,
metadata = credentials.getString("metadata") as String,
)
}
}
val config = HmsHelper.getHmsConfig(credentials)

HMSCoroutineScope.launch {
try {
Expand Down
28 changes: 2 additions & 26 deletions android/src/main/java/com/reactnativehmssdk/HmsView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.ReactContext
import com.facebook.react.bridge.WritableMap
import com.facebook.react.uimanager.events.RCTEventEmitter
import live.hms.video.media.tracks.HMSTrackType
import live.hms.video.media.tracks.HMSVideoTrack
import live.hms.video.utils.HmsUtilities
import live.hms.video.utils.SharedEglContext
import org.webrtc.RendererCommon
import org.webrtc.SurfaceViewRenderer
Expand All @@ -18,7 +18,6 @@ import org.webrtc.SurfaceViewRenderer
class HmsView(context: ReactContext) : FrameLayout(context) {
private var surfaceView: SurfaceViewRenderer = SurfaceViewRenderer(context)
private var videoTrack: HMSVideoTrack? = null
private var localTrack: String? = null
private var scaleTypeApplied: Boolean = false
private var currentScaleType: RendererCommon.ScalingType =
RendererCommon.ScalingType.SCALE_ASPECT_FILL
Expand Down Expand Up @@ -91,36 +90,13 @@ class HmsView(context: ReactContext) : FrameLayout(context) {
if (id != null) {
sdkId = id
}

val hms = hmsCollection[sdkId]?.hmsSDK

if (trackId != null && hms != null) {
if (mirror != null) {
surfaceView.setMirror(mirror)
}
localTrack = trackId
val localTrackId = hms.getLocalPeer()?.videoTrack?.trackId
if (localTrackId == localTrack) {
videoTrack = hms.getLocalPeer()?.videoTrack
}

val remotePeers = hms.getRemotePeers()
for (peer in remotePeers) {
val videoTrackId = peer.videoTrack?.trackId

val auxiliaryTracks = peer.auxiliaryTracks
for (track in auxiliaryTracks) {
val auxTrackId = track.trackId
if (trackId == auxTrackId && track.type == HMSTrackType.VIDEO && !track.isMute) {
videoTrack = track as HMSVideoTrack
return
}
}
if (videoTrackId == localTrack) {
videoTrack = peer.videoTrack
return
}
}
videoTrack = hms.getRoom()?.let { HmsUtilities.getVideoTrack(trackId, it) }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,12 @@ class HmssdkViewManager : SimpleViewManager<HmsView>() {
@ReactProp(name = "data")
fun setData(view: HmsView, data: ReadableMap) {
val trackId = data.getString("trackId")
// val sink = data.getBoolean("sink")
val id = data.getString("id")
val mirror = data.getBoolean("mirror")
val hmsCollection = getHms()
if (hmsCollection != null) {
view.setData(id, trackId, hmsCollection, mirror)
}
// do the processing here
}

@ReactProp(name = "scaleType")
Expand Down
16 changes: 8 additions & 8 deletions example/android/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ GEM
artifactory (3.0.15)
atomos (0.1.3)
aws-eventstream (1.2.0)
aws-partitions (1.568.0)
aws-partitions (1.572.0)
aws-sdk-core (3.130.0)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.525.0)
Expand Down Expand Up @@ -36,7 +36,7 @@ GEM
unf (>= 0.0.5, < 1.0.0)
dotenv (2.7.6)
emoji_regex (3.2.3)
excon (0.92.1)
excon (0.92.2)
faraday (1.10.0)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
Expand Down Expand Up @@ -66,7 +66,7 @@ GEM
faraday_middleware (1.2.0)
faraday (~> 1.0)
fastimage (2.2.6)
fastlane (2.205.0)
fastlane (2.205.1)
CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.8, < 3.0.0)
artifactory (~> 3.0)
Expand Down Expand Up @@ -105,9 +105,9 @@ GEM
xcodeproj (>= 1.13.0, < 2.0.0)
xcpretty (~> 0.3.0)
xcpretty-travis-formatter (>= 0.0.3)
fastlane-plugin-firebase_app_distribution (0.3.2)
fastlane-plugin-firebase_app_distribution (0.3.3)
gh_inspector (1.1.3)
google-apis-androidpublisher_v3 (0.16.0)
google-apis-androidpublisher_v3 (0.17.0)
google-apis-core (>= 0.4, < 2.a)
google-apis-core (0.4.2)
addressable (~> 2.5, >= 2.5.1)
Expand All @@ -127,8 +127,8 @@ GEM
google-cloud-core (1.6.0)
google-cloud-env (~> 1.0)
google-cloud-errors (~> 1.0)
google-cloud-env (1.5.0)
faraday (>= 0.17.3, < 2.0)
google-cloud-env (1.6.0)
faraday (>= 0.17.3, < 3.0)
google-cloud-errors (1.2.0)
google-cloud-storage (1.36.1)
addressable (~> 2.8)
Expand Down Expand Up @@ -219,4 +219,4 @@ DEPENDENCIES
fastlane-plugin-firebase_app_distribution

BUNDLED WITH
2.3.8
2.3.10
4 changes: 2 additions & 2 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ android {
applicationId "live.hms.rn"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 49
versionName "1.0.49"
versionCode 52
versionName "1.0.52"
}
splits {
abi {
Expand Down
6 changes: 3 additions & 3 deletions example/ios/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ GEM
artifactory (3.0.15)
atomos (0.1.3)
aws-eventstream (1.2.0)
aws-partitions (1.570.0)
aws-partitions (1.572.0)
aws-sdk-core (3.130.0)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.525.0)
Expand Down Expand Up @@ -36,7 +36,7 @@ GEM
unf (>= 0.0.5, < 1.0.0)
dotenv (2.7.6)
emoji_regex (3.2.3)
excon (0.92.1)
excon (0.92.2)
faraday (1.10.0)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
Expand Down Expand Up @@ -219,4 +219,4 @@ DEPENDENCIES
fastlane-plugin-firebase_app_distribution

BUNDLED WITH
2.3.8
2.3.10
Loading

0 comments on commit 81bde18

Please sign in to comment.