Apply capture gap recovery cadence consistently on Android

This commit is contained in:
evgeny committed 2026-10-19 18:23:25 +02:00
1 parent 526ee5ec8b
commit 47033718ad
3 files changed
+6 -6

No files matched your search

@@ -17,7 +17,7 @@ internal object CallVideoNative {
external fun playoutReset(handle: Long)
/** >0: ждать микросекунды; 0: показать; <0: пропустить только показ. */
external fun playoutStep(handle: Long, pts: Long, received: Long, nextPts: Long, nextReceived: Long,
now: Long): Long
now: Long, intervalUs: Int): Long
external fun requestKey(id: Long)
external fun range(id: Long, minimum: Int, maximum: Int): Boolean
external fun inspect(codec: Int, bytes: ByteArray): LongArray?
@@ -35,7 +35,7 @@ internal class CallVideoPlayer(private val id: Long, private val failure: (Strin
fun stop() { synchronized(this) { running = false }; worker.join() }
private fun loop() {
data class Timing(val pts: Long, val received: Long)
data class Timing(val pts: Long, val received: Long, val interval: Int)
data class Picture(val index: Int, val timing: Timing)
val playout = CallVideoNative.playoutCreate(id)
if (playout == 0L) { failure("Video playout allocation failed"); return }
@@ -100,7 +100,7 @@ internal class CallVideoPlayer(private val id: Long, private val failure: (Strin
val first = if (awaitingPts < 0) pictures.peekFirst() else null
val nextPicture = if (first != null && pictures.size > 1) pictures.peekLast() else null
val decision = CallVideoNative.playoutStep(playout, first?.timing?.pts ?: -1, first?.timing?.received ?: 0,
nextPicture?.timing?.pts ?: -1, nextPicture?.timing?.received ?: 0, now / 1000)
nextPicture?.timing?.pts ?: -1, nextPicture?.timing?.received ?: 0, now / 1000, first?.timing?.interval ?: 0)
if (decision > 0) wakeUs = now / 1000 + decision
else if (first != null) {
val render = decision == 0L
@@ -153,7 +153,7 @@ internal class CallVideoPlayer(private val id: Long, private val failure: (Strin
} else data
val buffer = checkNotNull(decoder!!.getInputBuffer(index)); check(bytes.size <= buffer.capacity())
buffer.put(bytes); decoder!!.queueInputBuffer(index, 0, bytes.size, meta[10], 0)
inputs.addLast(Timing(meta[10], meta[12])); pending = null; queued++; worked = true
inputs.addLast(Timing(meta[10], meta[12], 1000000 / next.fps)); pending = null; queued++; worked = true
}
}
} else if (data != null && surface == null) { pending = null; CallVideoNative.requestKey(id) }