Skip to content

Commit

Permalink
Merge pull request #430 from 100mslive/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
ygit authored Dec 29, 2021
2 parents 482e276 + 198639c commit 680c42b
Show file tree
Hide file tree
Showing 49 changed files with 1,446 additions and 870 deletions.
3 changes: 1 addition & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ def safeExtGet(prop, fallback) {

android {
compileSdkVersion safeExtGet('Hmssdk_compileSdkVersion', 29)
buildToolsVersion safeExtGet('Hmssdk_buildToolsVersion', '29.0.2')
defaultConfig {
minSdkVersion safeExtGet('Hmssdk_minSdkVersion', 21)
targetSdkVersion safeExtGet('Hmssdk_targetSdkVersion', 29)
Expand Down Expand Up @@ -64,6 +63,6 @@ dependencies {
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" // From node_modules
implementation 'com.github.100mslive:android-sdk:2.2.3'
implementation 'com.github.100mslive:android-sdk:2.2.4'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0'
}
452 changes: 198 additions & 254 deletions android/src/main/java/com/reactnativehmssdk/HmsDecoder.kt

Large diffs are not rendered by default.

48 changes: 18 additions & 30 deletions android/src/main/java/com/reactnativehmssdk/HmsHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,11 @@ object HmsHelper {
return false
}
}
"Float" -> {
if (map.getDouble(key) == null) {
return false
}
}
"Boolean" -> {
if (map.getBoolean(key) == null) {
return false
}
}
"Array" -> {
if (map.getArray(key) == null) {
return false
}
}
"Int" -> {
if (map.getInt(key) == null) {
return false
}
}
"Map" -> {
if (map.getMap(key) == null) {
return false
Expand Down Expand Up @@ -174,13 +159,17 @@ object HmsHelper {
return null
}

fun getAudioTrackSettings(data: ReadableMap?): HMSAudioTrackSettings {
val builder = HMSAudioTrackSettings.Builder()
fun getAudioTrackSettings(
data: ReadableMap?,
useHardwareEchoCancellation: Boolean
): HMSAudioTrackSettings {
val builder =
HMSAudioTrackSettings.Builder()
.setUseHardwareAcousticEchoCanceler(useHardwareEchoCancellation)

if (data != null) {
val maxBitrate = data.getInt("maxBitrate")
val codec = getAudioCodec(data.getString("codec"))
val trackDescription = data.getString("trackDescription")

builder.maxBitrate(maxBitrate)
builder.codec(codec)
Expand All @@ -189,7 +178,7 @@ object HmsHelper {
return builder.build()
}

// TODO: find out a way to set settings required to create HMSVideTrackSettings
// TODO: find out a way to set settings required to create HMSVideoTrackSettings

fun getVideoTrackSettings(data: ReadableMap?): HMSVideoTrackSettings {
val builder = HMSVideoTrackSettings.Builder()
Expand All @@ -199,7 +188,6 @@ object HmsHelper {
val maxBitrate = data.getInt("maxBitrate")
val maxFrameRate = data.getInt("maxFrameRate")
val cameraFacing = getCameraFacing(data.getString("cameraFacing"))
val trackDescription = data.getString("trackDescription")

builder.codec(codec)
builder.cameraFacing(cameraFacing)
Expand All @@ -212,7 +200,7 @@ object HmsHelper {
return builder.build()
}

fun getVideoResolution(map: ReadableMap?): HMSVideoResolution? {
private fun getVideoResolution(map: ReadableMap?): HMSVideoResolution? {
val width = map?.getDouble("width")
val height = map?.getDouble("height")

Expand All @@ -223,7 +211,7 @@ object HmsHelper {
}
}

fun getAudioCodec(codecString: String?): HMSAudioCodec {
private fun getAudioCodec(codecString: String?): HMSAudioCodec {
when (codecString) {
"opus" -> {
return HMSAudioCodec.OPUS
Expand All @@ -232,22 +220,22 @@ object HmsHelper {
return HMSAudioCodec.OPUS
}

fun getVideoCodec(codecString: String?): HMSVideoCodec {
private fun getVideoCodec(codecString: String?): HMSVideoCodec {
when (codecString) {
"h264" -> {
"H264" -> {
return HMSVideoCodec.H264
}
"vp8" -> {
"VP8" -> {
return HMSVideoCodec.VP8
}
"vp9" -> {
"VP9" -> {
return HMSVideoCodec.VP9
}
}
return HMSVideoCodec.H264
}

fun getCameraFacing(cameraFacing: String?): HMSVideoTrackSettings.CameraFacing {
private fun getCameraFacing(cameraFacing: String?): HMSVideoTrackSettings.CameraFacing {
when (cameraFacing) {
"FRONT" -> {
return HMSVideoTrackSettings.CameraFacing.FRONT
Expand All @@ -262,10 +250,10 @@ object HmsHelper {
fun getHms(credentials: ReadableMap, hmsCollection: MutableMap<String, HmsSDK>): HmsSDK? {
val id = credentials.getString("id")

if (id != null) {
return hmsCollection[id]
return if (id != null) {
hmsCollection[id]
} else {
return null
null
}
}

Expand Down
36 changes: 18 additions & 18 deletions android/src/main/java/com/reactnativehmssdk/HmsModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ class HmsModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMod
if (hasItem) {
val uuid = UUID.randomUUID()
val randomUUIDString = uuid.toString()
val sdkInstance: HmsSDK = HmsSDK(data, this, randomUUIDString, reactApplicationContext)
val sdkInstance = HmsSDK(data, this, randomUUIDString, reactApplicationContext)

hmsCollection[randomUUIDString] = sdkInstance

callback?.resolve(randomUUIDString)
} else {
val randomUUIDString = "12345"
val sdkInstance: HmsSDK = HmsSDK(data, this, randomUUIDString, reactApplicationContext)
val sdkInstance = HmsSDK(data, this, randomUUIDString, reactApplicationContext)

hmsCollection[randomUUIDString] = sdkInstance

Expand Down Expand Up @@ -86,45 +86,45 @@ class HmsModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMod
}

@ReactMethod
fun sendBroadcastMessage(data: ReadableMap) {
fun sendBroadcastMessage(data: ReadableMap, callback: Promise?) {
val hms = HmsHelper.getHms(data, hmsCollection)

hms?.sendBroadcastMessage(data)
hms?.sendBroadcastMessage(data, callback)
}

@ReactMethod
fun sendGroupMessage(data: ReadableMap) {
fun sendGroupMessage(data: ReadableMap, callback: Promise?) {
val hms = HmsHelper.getHms(data, hmsCollection)

hms?.sendGroupMessage(data)
hms?.sendGroupMessage(data, callback)
}

@ReactMethod
fun sendDirectMessage(data: ReadableMap) {
fun sendDirectMessage(data: ReadableMap, callback: Promise?) {
val hms = HmsHelper.getHms(data, hmsCollection)

hms?.sendDirectMessage(data)
hms?.sendDirectMessage(data, callback)
}

@ReactMethod
fun changeRole(data: ReadableMap) {
fun changeRole(data: ReadableMap, callback: Promise?) {
val hms = HmsHelper.getHms(data, hmsCollection)

hms?.changeRole(data)
hms?.changeRole(data, callback)
}

@ReactMethod
fun changeTrackState(data: ReadableMap) {
fun changeTrackState(data: ReadableMap, callback: Promise?) {
val hms = HmsHelper.getHms(data, hmsCollection)

hms?.changeTrackState(data)
hms?.changeTrackState(data, callback)
}

@ReactMethod
fun changeTrackStateRoles(data: ReadableMap) {
fun changeTrackStateRoles(data: ReadableMap, callback: Promise?) {
val hms = HmsHelper.getHms(data, hmsCollection)

hms?.changeTrackStateRoles(data)
hms?.changeTrackStateRoles(data, callback)
}

@ReactMethod
Expand All @@ -135,10 +135,10 @@ class HmsModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMod
}

@ReactMethod
fun removePeer(data: ReadableMap) {
fun removePeer(data: ReadableMap, callback: Promise?) {
val hms = HmsHelper.getHms(data, hmsCollection)

hms?.removePeer(data)
hms?.removePeer(data, callback)
}

@ReactMethod
Expand All @@ -163,10 +163,10 @@ class HmsModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMod
}

@ReactMethod
fun endRoom(data: ReadableMap) {
fun endRoom(data: ReadableMap, callback: Promise?) {
val hms = HmsHelper.getHms(data, hmsCollection)

hms?.endRoom(data)
hms?.endRoom(data, callback)
}

@ReactMethod
Expand Down
Loading

0 comments on commit 680c42b

Please sign in to comment.