Use measured media tempo for sequential Android video playout
This commit is contained in:
1 parent
4e9cce8a01
commit
0a2700a387
4 files changed
+61
-117
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, valid: Boolean, audio: Long): Long
|
||||
now: Long): Long
|
||||
external fun requestKey(id: Long)
|
||||
external fun range(id: Long, minimum: Int, maximum: Int): Boolean
|
||||
external fun inspect(codec: Int, bytes: ByteArray): LongArray?
|
||||
|
||||
@@ -57,7 +57,7 @@ internal class CallVideoPlayer(private val id: Long, private val failure: (Strin
|
||||
pending = null; displayed.value = null; CallVideoNative.requestKey(id)
|
||||
LogManager.addLog("INFO", "call", "video output attached=${surface != null} call=$id")
|
||||
}
|
||||
// Два готовых output нужны для пропуска старого показа после паузы CPU, не для дополнительного запаса.
|
||||
// Малый output lookahead; основной долг остаётся в encoded FIFO.
|
||||
while (decoder != null && pictures.size < 2 && !endSeen) {
|
||||
val out = decoder!!.dequeueOutputBuffer(info, 0)
|
||||
if (out >= 0) {
|
||||
@@ -82,7 +82,7 @@ internal class CallVideoPlayer(private val id: Long, private val failure: (Strin
|
||||
val valid = NativeLib.callAudioClock(id, now / 1000, clock) && clock[5] != 0L
|
||||
val first = pictures.peekFirst(); val nextPicture = if (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, valid, clock[4])
|
||||
nextPicture?.timing?.pts ?: -1, nextPicture?.timing?.received ?: 0, now / 1000)
|
||||
if (decision > 0) wakeUs = now / 1000 + decision
|
||||
else if (first != null) {
|
||||
val render = decision == 0L
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <string.h>
|
||||
#include "../../../src/call/call_video_port.h"
|
||||
#include "../../../src/call/call_video_playout.h"
|
||||
#include "../../../src/call/call_audio.h"
|
||||
#include "../../../src/call/call_video_bitstream.h"
|
||||
#include "../../../lib/debug_config.h"
|
||||
#include "../../../lib/mem.h"
|
||||
@@ -48,8 +49,8 @@ JNIEXPORT jlongArray JNICALL Java_com_utun_chat_data_CallVideoNative_status(JNIE
|
||||
(void)o; struct call_video_port_status s;
|
||||
if (call_video_port_status(id, &s)) return NULL;
|
||||
jlong values[] = {s.key_serial, s.rate_generation, s.rate_request, s.rate_bps, s.configured_generation,
|
||||
s.error, s.minimum_bps, s.maximum_bps, s.decoded_generation, s.decoded_accepted};
|
||||
jlongArray out = (*e)->NewLongArray(e, 10); if (out) (*e)->SetLongArrayRegion(e, out, 0, 10, values); return out;
|
||||
s.error, s.minimum_bps, s.maximum_bps, s.decoded_generation, s.decoded_accepted, s.can_encode};
|
||||
jlongArray out = (*e)->NewLongArray(e, 11); if (out) (*e)->SetLongArrayRegion(e, out, 0, 11, values); return out;
|
||||
}
|
||||
JNIEXPORT jlongArray JNICALL Java_com_utun_chat_data_CallVideoNative_choose(
|
||||
JNIEnv *e, jobject o, jbyteArray local, jbyteArray remote, jlongArray desired) {
|
||||
@@ -109,11 +110,12 @@ JNIEXPORT void JNICALL Java_com_utun_chat_data_CallVideoNative_playoutReset(JNIE
|
||||
call_video_playout_init(p, p->call_id);
|
||||
}
|
||||
JNIEXPORT jlong JNICALL Java_com_utun_chat_data_CallVideoNative_playoutStep(JNIEnv *e, jobject o, jlong handle,
|
||||
jlong pts, jlong received, jlong next_pts, jlong next_received, jlong now, jboolean valid, jlong audio) {
|
||||
jlong pts, jlong received, jlong next_pts, jlong next_received, jlong now) {
|
||||
(void)e; (void)o; struct call_video_playout *p = (void *)(uintptr_t)handle;
|
||||
if (!p) { DEBUG_ERROR(DEBUG_CATEGORY_CALL, "video playout poll without handle"); return 5000; }
|
||||
struct call_video_playout_frame f = {pts, received}, next = {next_pts, next_received};
|
||||
int action = call_video_playout_poll(p, pts >= 0 ? &f : NULL, next_pts >= 0 ? &next : NULL, now, valid, audio);
|
||||
struct call_clock_snapshot clock = {0}; call_audio_get_clock(p->call_id, now, &clock);
|
||||
int action = call_video_playout_poll(p, pts >= 0 ? &f : NULL, next_pts >= 0 ? &next : NULL, now, &clock);
|
||||
if (action == CALL_VIDEO_PLAYOUT_SHOW) return 0;
|
||||
if (action != CALL_VIDEO_PLAYOUT_WAIT) return -action;
|
||||
int64_t wait = p->deadline_us - now;
|
||||
|
||||
Reference in new issue
Block a user