|
|
|
|
@ -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) } |
|
|
|
|
|