davidliu
Committed by GitHub

Simulcast layer and datastream hotfixes (#749)

* Discard extra simulcast layers equal to original resolution

* amend changeset description

* Wrap exceptions thrown in sendText and sendFile into Result
---
"client-sdk-android": patch
---
Fix crash caused by extra simulcast layers equal to original resolution
... ...
---
"client-sdk-android": patch
---
Wrap exceptions thrown in sendText and sendFile into Result
... ...
... ... @@ -61,16 +61,20 @@ interface OutgoingDataStreamManager {
*/
@CheckResult
suspend fun sendText(text: String, options: StreamTextOptions = StreamTextOptions()): Result<TextStreamInfo> {
val sender = streamText(options)
val result = sender.write(text)
if (result.isFailure) {
val exception = result.exceptionOrNull() ?: Exception("Unknown error.")
sender.close(exception.message)
return Result.failure(exception)
} else {
sender.close()
return Result.success(sender.info)
try {
val sender = streamText(options)
val result = sender.write(text)
if (result.isFailure) {
val exception = result.exceptionOrNull() ?: Exception("Unknown error.")
sender.close(exception.message)
return Result.failure(exception)
} else {
sender.close()
return Result.success(sender.info)
}
} catch (e: Exception) {
return Result.failure(e)
}
}
... ... @@ -79,16 +83,20 @@ interface OutgoingDataStreamManager {
*/
@CheckResult
suspend fun sendFile(file: File, options: StreamBytesOptions = StreamBytesOptions()): Result<ByteStreamInfo> {
val sender = streamBytes(options)
val result = sender.writeFile(file)
if (result.isFailure) {
val exception = result.exceptionOrNull() ?: Exception("Unknown error.")
sender.close(exception.message)
return Result.failure(exception)
} else {
sender.close()
return Result.success(sender.info)
try {
val sender = streamBytes(options)
val result = sender.writeFile(file)
if (result.isFailure) {
val exception = result.exceptionOrNull() ?: Exception("Unknown error.")
sender.close(exception.message)
return Result.failure(exception)
} else {
sender.close()
return Result.success(sender.info)
}
} catch (e: Exception) {
return Result.failure(e)
}
}
}
... ...
... ... @@ -786,7 +786,11 @@ internal constructor(
} else if (simulcast) {
fun addEncoding(videoEncoding: VideoEncoding, scale: Double) {
if (scale < 1.0) {
LKLog.w { "Discarding encoding with a scale < 1.0: $scale." }
LKLog.w { "Discarding encoding with a scale down < 1.0: $scale." }
return
}
if (scale == 1.0 && videoEncoding !== originalEncoding) {
LKLog.w { "Discarding duplicate encoding with a scale down == 1.0: $scale." }
return
}
if (encodings.size >= EncodingUtils.VIDEO_RIDS.size) {
... ...