Committed by
GitHub
Dedupe supported codecs to provide valid SDP (#643)
* Dedupe supported codecs to provide valid SDP * changeset
正在显示
2 个修改的文件
包含
34 行增加
和
2 行删除
.changeset/thirty-rocks-agree.md
0 → 100644
| 1 | /* | 1 | /* |
| 2 | - * Copyright 2023-2024 LiveKit, Inc. | 2 | + * Copyright 2023-2025 LiveKit, Inc. |
| 3 | * | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. | 5 | * you may not use this file except in compliance with the License. |
| @@ -268,6 +268,33 @@ open class SimulcastVideoEncoderFactoryWrapper( | @@ -268,6 +268,33 @@ open class SimulcastVideoEncoderFactoryWrapper( | ||
| 268 | } | 268 | } |
| 269 | 269 | ||
| 270 | override fun getSupportedCodecs(): Array<VideoCodecInfo> { | 270 | override fun getSupportedCodecs(): Array<VideoCodecInfo> { |
| 271 | - return native.supportedCodecs | 271 | + val codecs = native.supportedCodecs |
| 272 | + val dedupeSet = mutableSetOf<HashableVideoCodecInfo>() | ||
| 273 | + for (c in codecs) { | ||
| 274 | + if (c.name.equals("vp9", ignoreCase = true) && c.params.isNullOrEmpty()) { | ||
| 275 | + // Ignore VP9 codecs reported from HardwareVideoEncoderFactory. | ||
| 276 | + // If allowed, will cause duplicate rtmps in the SDP. | ||
| 277 | + // SoftwareVideoEncoderFactory will report correct params, so we use those. | ||
| 278 | + continue | ||
| 279 | + } | ||
| 280 | + dedupeSet.add(HashableVideoCodecInfo.fromVideoCodecInfo(c)) | ||
| 281 | + } | ||
| 282 | + | ||
| 283 | + return dedupeSet.map { it.originalInfo }.toTypedArray() | ||
| 284 | + } | ||
| 285 | + | ||
| 286 | + private data class HashableVideoCodecInfo( | ||
| 287 | + val name: String, | ||
| 288 | + val params: Map<String, String>, | ||
| 289 | + val scalabilityModes: List<String>, | ||
| 290 | + ) { | ||
| 291 | + lateinit var originalInfo: VideoCodecInfo | ||
| 292 | + | ||
| 293 | + companion object { | ||
| 294 | + fun fromVideoCodecInfo(codecInfo: VideoCodecInfo): HashableVideoCodecInfo { | ||
| 295 | + return HashableVideoCodecInfo(codecInfo.name, codecInfo.params, codecInfo.scalabilityModes) | ||
| 296 | + .apply { originalInfo = codecInfo } | ||
| 297 | + } | ||
| 298 | + } | ||
| 272 | } | 299 | } |
| 273 | } | 300 | } |
-
请 注册 或 登录 后发表评论