Publish verified encoder modes only after successful probe cleanup
This commit is contained in:
1 parent
3e442256a9
commit
cf075080d2
2 files changed
+10
-4
No files matched your search
@@ -301,9 +301,10 @@ internal class CallVideoCodec(requested: CallVideoFormat, bitrate: Int, val name
|
||||
for (level in (if (type.id == 2) listOf(f.level, maxOf(f.level, 120)) else listOf(f.level)).distinct()) {
|
||||
if (!keepRunning()) return emptyMap()
|
||||
try {
|
||||
CallVideoCodec(f.copy(level = level), 1_000_000, entry.name).use { encoder ->
|
||||
encoder.prepare(keepRunning); verified = encoder.format
|
||||
val actual = CallVideoCodec(f.copy(level = level), 1_000_000, entry.name).use { encoder ->
|
||||
encoder.prepare(keepRunning); encoder.format
|
||||
}
|
||||
verified = actual // Публикуем только после подтверждённого close пробного codec.
|
||||
break
|
||||
} catch (e: Exception) {
|
||||
LogManager.addLog("WARN", "call", "video encoder level probe rejected name=${entry.name} size=${w}x$h level=$level: ${e.message}")
|
||||
|
||||
@@ -58,7 +58,10 @@ data class CallVideoState(val ready: Boolean = false, val settings: CallVideoSet
|
||||
fun sizes(camera: String = settings.camera, codec: Int = settings.codec) = modes(camera, codec).map { Size(it.width, it.height) }.distinct()
|
||||
}
|
||||
|
||||
/** Сервис владеет capture и RX; экран только выбирает режим и передаёт Surface. */
|
||||
/** Сервис сначала сохраняет пассивный engine, затем вызывает start на main.
|
||||
* Capture/encode/probe принадлежат TX worker, decode — RX; экран передаёт Surface и выбирает режим.
|
||||
* stop на main возвращает true после полного cleanup, false сохраняет владельца у сервиса для повторного stop.
|
||||
*/
|
||||
class CallVideoEngine(private val context: Context, private val id: Long) {
|
||||
companion object { private val retained = ConcurrentHashMap.newKeySet<CallVideoEngine>() }
|
||||
private val createdAt = System.nanoTime()
|
||||
@@ -380,7 +383,9 @@ class CallVideoEngine(private val context: Context, private val id: Long) {
|
||||
if (active != null && !opening && !closing && lastCaptureAt != 0L
|
||||
&& System.nanoTime() - lastCaptureAt > 8_000_000_000) fail("Camera stopped producing frames")
|
||||
} catch (e: Exception) { fail("Video worker: ${e.message}") }
|
||||
finally { if (!stopped && !nativeUnavailable) handler.postDelayed(::tick, 10) }
|
||||
finally {
|
||||
if (!stopped && !nativeUnavailable && !handler.postDelayed(::tick, 10)) fail("Video worker rejected next tick")
|
||||
}
|
||||
}
|
||||
|
||||
/** Проба кандидата не меняет камеру, порт или видимое состояние. */
|
||||
|
||||
Reference in new issue
Block a user