Surface failed video configuration and camera capture stalls
This commit is contained in:
1 parent
fd6eba0206
commit
9c35def4ea
2 files changed
+7
-2
No files matched your search
@@ -60,6 +60,7 @@ class CallVideoEngine(private val context: Context, private val id: Long) {
|
||||
private var realtime = false
|
||||
private var sensorOffset: Long? = null
|
||||
private var openedAt = 0L
|
||||
private var lastCaptureAt = 0L
|
||||
private var reportAt = 0L
|
||||
private var encodedBytes = 0L
|
||||
private var encodedFrames = 0
|
||||
@@ -119,6 +120,7 @@ class CallVideoEngine(private val context: Context, private val id: Long) {
|
||||
if (stopped) return
|
||||
try {
|
||||
val s = CallVideoNative.status(id) ?: return
|
||||
check(s[5] == 0L) { "Core rejected video format" }
|
||||
if (s[6] >= 300000 && s[7] >= s[6]) mutable.value = mutable.value.copy(range = CallVideoBitrateRange((s[6] / 1000).toInt(), (s[7] / 1000).toInt()))
|
||||
if (keySerial != s[0]) { keySerial = s[0]; needKey = true }
|
||||
val current = format
|
||||
@@ -145,7 +147,8 @@ class CallVideoEngine(private val context: Context, private val id: Long) {
|
||||
if (peer != null) change(peer)
|
||||
}
|
||||
drain()
|
||||
if (active != null && System.nanoTime() - openedAt > 8_000_000_000 && lastPts < 0) fail("Camera produced no frames")
|
||||
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}") }
|
||||
if (!stopped) handler.postDelayed(::tick, 10)
|
||||
}
|
||||
@@ -202,6 +205,7 @@ class CallVideoEngine(private val context: Context, private val id: Long) {
|
||||
try {
|
||||
if (stopped || token != cameraToken || !wanted.enabled) return@setOnImageAvailableListener
|
||||
val now = System.nanoTime()
|
||||
lastCaptureAt = now
|
||||
val offset = if (realtime) now - SystemClock.elapsedRealtimeNanos() else sensorOffset ?: (now - image.timestamp).also {
|
||||
sensorOffset = it; LogManager.addLog("WARN", "call", "camera timestamp calibrated from arrival id=$id offset=$it")
|
||||
}
|
||||
@@ -229,7 +233,7 @@ class CallVideoEngine(private val context: Context, private val id: Long) {
|
||||
} catch (e: Exception) { fail("Camera encode: ${e.message}") }
|
||||
finally { image.close() }
|
||||
}, handler)
|
||||
opening = true; openedAt = System.nanoTime()
|
||||
opening = true; openedAt = System.nanoTime(); lastCaptureAt = openedAt
|
||||
manager.openCamera(settings.camera, object : CameraDevice.StateCallback() {
|
||||
override fun onOpened(device: CameraDevice) {
|
||||
opening = false; camera = device
|
||||
|
||||
@@ -153,6 +153,7 @@ void CallVideoEngine::transmit() {
|
||||
while (m->running) {
|
||||
struct call_video_port_status state{};
|
||||
if (call_video_port_status(m->id, &state) < 0) break;
|
||||
if (state.error) { m->report(tr("Core rejected video format")); break; }
|
||||
uint64_t revision; bool enabled; int width, height, codec; int64_t pts;
|
||||
#ifdef HAVE_STREAM_CAPTURE
|
||||
QVideoFrame raw;
|
||||
|
||||
Reference in new issue
Block a user