Skip to content

Commit a3d185d

Browse files
authored
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
1 parent 647940f commit a3d185d

File tree

4 files changed

+43
-21
lines changed

4 files changed

+43
-21
lines changed

.changeset/chatty-jokes-float.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"client-sdk-android": patch
3+
---
4+
5+
Fix crash caused by extra simulcast layers equal to original resolution

.changeset/spicy-queens-yawn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"client-sdk-android": patch
3+
---
4+
5+
Wrap exceptions thrown in sendText and sendFile into Result

livekit-android-sdk/src/main/java/io/livekit/android/room/datastream/outgoing/OutgoingDataStreamManager.kt

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,20 @@ interface OutgoingDataStreamManager {
6161
*/
6262
@CheckResult
6363
suspend fun sendText(text: String, options: StreamTextOptions = StreamTextOptions()): Result<TextStreamInfo> {
64-
val sender = streamText(options)
65-
val result = sender.write(text)
66-
67-
if (result.isFailure) {
68-
val exception = result.exceptionOrNull() ?: Exception("Unknown error.")
69-
sender.close(exception.message)
70-
return Result.failure(exception)
71-
} else {
72-
sender.close()
73-
return Result.success(sender.info)
64+
try {
65+
val sender = streamText(options)
66+
val result = sender.write(text)
67+
68+
if (result.isFailure) {
69+
val exception = result.exceptionOrNull() ?: Exception("Unknown error.")
70+
sender.close(exception.message)
71+
return Result.failure(exception)
72+
} else {
73+
sender.close()
74+
return Result.success(sender.info)
75+
}
76+
} catch (e: Exception) {
77+
return Result.failure(e)
7478
}
7579
}
7680

@@ -79,16 +83,20 @@ interface OutgoingDataStreamManager {
7983
*/
8084
@CheckResult
8185
suspend fun sendFile(file: File, options: StreamBytesOptions = StreamBytesOptions()): Result<ByteStreamInfo> {
82-
val sender = streamBytes(options)
83-
val result = sender.writeFile(file)
84-
85-
if (result.isFailure) {
86-
val exception = result.exceptionOrNull() ?: Exception("Unknown error.")
87-
sender.close(exception.message)
88-
return Result.failure(exception)
89-
} else {
90-
sender.close()
91-
return Result.success(sender.info)
86+
try {
87+
val sender = streamBytes(options)
88+
val result = sender.writeFile(file)
89+
90+
if (result.isFailure) {
91+
val exception = result.exceptionOrNull() ?: Exception("Unknown error.")
92+
sender.close(exception.message)
93+
return Result.failure(exception)
94+
} else {
95+
sender.close()
96+
return Result.success(sender.info)
97+
}
98+
} catch (e: Exception) {
99+
return Result.failure(e)
92100
}
93101
}
94102
}

livekit-android-sdk/src/main/java/io/livekit/android/room/participant/LocalParticipant.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,11 @@ internal constructor(
786786
} else if (simulcast) {
787787
fun addEncoding(videoEncoding: VideoEncoding, scale: Double) {
788788
if (scale < 1.0) {
789-
LKLog.w { "Discarding encoding with a scale < 1.0: $scale." }
789+
LKLog.w { "Discarding encoding with a scale down < 1.0: $scale." }
790+
return
791+
}
792+
if (scale == 1.0 && videoEncoding !== originalEncoding) {
793+
LKLog.w { "Discarding duplicate encoding with a scale down == 1.0: $scale." }
790794
return
791795
}
792796
if (encodings.size >= EncodingUtils.VIDEO_RIDS.size) {

0 commit comments

Comments
 (0)