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
正在显示
4 个修改的文件
包含
43 行增加
和
21 行删除
.changeset/chatty-jokes-float.md
0 → 100644
.changeset/spicy-queens-yawn.md
0 → 100644
| @@ -61,16 +61,20 @@ interface OutgoingDataStreamManager { | @@ -61,16 +61,20 @@ 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 | - 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) | ||
| 74 | } | 78 | } |
| 75 | } | 79 | } |
| 76 | 80 | ||
| @@ -79,16 +83,20 @@ interface OutgoingDataStreamManager { | @@ -79,16 +83,20 @@ 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> { |
| 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) | ||
| 92 | } | 100 | } |
| 93 | } | 101 | } |
| 94 | } | 102 | } |
| @@ -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) { |
-
请 注册 或 登录 后发表评论