Explain unavailable video decoders and restored capture settings
This commit is contained in:
1 parent
de67de33df
commit
39297d1a07
3 files changed
+10
-4
No files matched your search
@@ -22,6 +22,7 @@ import kotlin.concurrent.withLock
|
||||
class StreamPlayerEngine(private val group: Long, private val source: Long, private val epoch: Long,
|
||||
private val localPreview: StreamPreview? = null, private val displayDegrees: Int = 0) {
|
||||
companion object { private val viewerLock = ReentrantLock() }
|
||||
private class UnsupportedCodec(message: String) : IllegalStateException(message)
|
||||
private data class Frame(val pts: Long, val key: Boolean, val width: Int, val height: Int,
|
||||
val rotation: Int, val top: Int?, val revision: Long, val codec: StreamVideoCodec,
|
||||
val config: ByteArray, val data: ByteArray)
|
||||
@@ -230,7 +231,7 @@ class StreamPlayerEngine(private val group: Long, private val source: Long, priv
|
||||
check(frame.key)
|
||||
val format = frame.codec.decoderFormat(frame.width, frame.height, frame.rotation, frame.config)
|
||||
val name = android.media.MediaCodecList(android.media.MediaCodecList.REGULAR_CODECS).findDecoderForFormat(format)
|
||||
?: error("Unsupported decoder ${frame.codec.label} ${frame.width}x${frame.height}")
|
||||
?: throw UnsupportedCodec("Unsupported decoder ${frame.codec.label} ${frame.width}x${frame.height}")
|
||||
decoder = MediaCodec.createByCodecName(name)
|
||||
LogManager.addLog("INFO", "video", "viewer codec id=$id type=${frame.codec.label} decoder=$name config=${frame.config.size}")
|
||||
decoder!!.configure(format, surface, null, 0); decoder!!.start()
|
||||
@@ -282,7 +283,10 @@ class StreamPlayerEngine(private val group: Long, private val source: Long, priv
|
||||
Thread.sleep(5)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
if (running) { mutableStatus.value = R.string.stream_failed; LogManager.addLog("ERROR", "stream", "viewer failed id=$id: ${e.message}") }
|
||||
if (running) {
|
||||
mutableStatus.value = if (e is UnsupportedCodec) R.string.stream_decoder_unsupported else R.string.stream_failed
|
||||
LogManager.addLog("ERROR", "stream", "viewer failed id=$id: ${e.message}")
|
||||
}
|
||||
} finally {
|
||||
NativeLib.streamStop(id)
|
||||
try { decoder?.stop(); decoder?.release() }
|
||||
|
||||
Reference in new issue
Block a user