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
  1 +---
  2 +"client-sdk-android": patch
  3 +---
  4 +
  5 +Fix crash caused by extra simulcast layers equal to original resolution
  1 +---
  2 +"client-sdk-android": patch
  3 +---
  4 +
  5 +Wrap exceptions thrown in sendText and sendFile into Result
@@ -61,6 +61,7 @@ interface OutgoingDataStreamManager { @@ -61,6 +61,7 @@ interface OutgoingDataStreamManager {
61 */ 61 */
62 @CheckResult 62 @CheckResult
63 suspend fun sendText(text: String, options: StreamTextOptions = StreamTextOptions()): Result<TextStreamInfo> { 63 suspend fun sendText(text: String, options: StreamTextOptions = StreamTextOptions()): Result<TextStreamInfo> {
  64 + try {
64 val sender = streamText(options) 65 val sender = streamText(options)
65 val result = sender.write(text) 66 val result = sender.write(text)
66 67
@@ -72,6 +73,9 @@ interface OutgoingDataStreamManager { @@ -72,6 +73,9 @@ interface OutgoingDataStreamManager {
72 sender.close() 73 sender.close()
73 return Result.success(sender.info) 74 return Result.success(sender.info)
74 } 75 }
  76 + } catch (e: Exception) {
  77 + return Result.failure(e)
  78 + }
75 } 79 }
76 80
77 /** 81 /**
@@ -79,6 +83,7 @@ interface OutgoingDataStreamManager { @@ -79,6 +83,7 @@ interface OutgoingDataStreamManager {
79 */ 83 */
80 @CheckResult 84 @CheckResult
81 suspend fun sendFile(file: File, options: StreamBytesOptions = StreamBytesOptions()): Result<ByteStreamInfo> { 85 suspend fun sendFile(file: File, options: StreamBytesOptions = StreamBytesOptions()): Result<ByteStreamInfo> {
  86 + try {
82 val sender = streamBytes(options) 87 val sender = streamBytes(options)
83 val result = sender.writeFile(file) 88 val result = sender.writeFile(file)
84 89
@@ -90,6 +95,9 @@ interface OutgoingDataStreamManager { @@ -90,6 +95,9 @@ interface OutgoingDataStreamManager {
90 sender.close() 95 sender.close()
91 return Result.success(sender.info) 96 return Result.success(sender.info)
92 } 97 }
  98 + } catch (e: Exception) {
  99 + return Result.failure(e)
  100 + }
93 } 101 }
94 } 102 }
95 103
@@ -786,7 +786,11 @@ internal constructor( @@ -786,7 +786,11 @@ internal constructor(
786 } else if (simulcast) { 786 } else if (simulcast) {
787 fun addEncoding(videoEncoding: VideoEncoding, scale: Double) { 787 fun addEncoding(videoEncoding: VideoEncoding, scale: Double) {
788 if (scale < 1.0) { 788 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." }
790 return 794 return
791 } 795 }
792 if (encodings.size >= EncodingUtils.VIDEO_RIDS.size) { 796 if (encodings.size >= EncodingUtils.VIDEO_RIDS.size) {