Compile the real stream video worker against controlled SDK boundaries
This commit is contained in:
1 parent
e7ea997a52
commit
8043448aea
3 files changed
+22
-3
No files matched your search
@@ -7,7 +7,8 @@ kotlin {
|
||||
kotlin.srcDir("../app/src/main/java")
|
||||
kotlin.include("android/**", "com/utun/chat/data/VideoHost.kt", "com/utun/chat/data/CallVideoPlayer.kt",
|
||||
"com/utun/chat/data/CallVideoFormat.kt", "com/utun/chat/data/StreamVideoCodec.kt", "com/utun/chat/data/H264AnnexB.kt",
|
||||
"com/utun/chat/data/StreamPreview.kt", "com/utun/chat/data/VideoCodecResources.kt")
|
||||
"com/utun/chat/data/StreamPreview.kt", "com/utun/chat/data/VideoCodecResources.kt",
|
||||
"com/utun/chat/data/StreamVideoPlayback.kt", "com/utun/chat/data/StreamDecodePump.kt")
|
||||
kotlin.include("com/utun/chat/VideoHostApp.kt", "com/utun/chat/data/VideoEngineHost.kt",
|
||||
"com/utun/chat/data/CallVideoEngine.kt", "com/utun/chat/data/CallVideoBitrateRange.kt",
|
||||
"com/utun/chat/data/CallVideoCadence.kt", "com/utun/chat/data/CallVideoOrientation.kt")
|
||||
|
||||
@@ -9,15 +9,30 @@ import java.util.concurrent.ConcurrentLinkedQueue
|
||||
class MediaFormat {
|
||||
companion object {
|
||||
const val KEY_ROTATION = "rotation"; const val KEY_MAX_INPUT_SIZE = "max-input-size"
|
||||
const val KEY_LOW_LATENCY = "low-latency"
|
||||
fun createVideoFormat(mime: String, width: Int, height: Int) = MediaFormat()
|
||||
}
|
||||
val values = mutableMapOf<String, Any>()
|
||||
fun setInteger(key: String, value: Int) { values[key] = value }
|
||||
fun setByteBuffer(key: String, value: ByteBuffer) { values[key] = value }
|
||||
}
|
||||
class MediaCodecInfo { object CodecProfileLevel {
|
||||
class MediaCodecInfo(val name: String = "host.decoder") {
|
||||
val isEncoder = false
|
||||
val supportedTypes = arrayOf("video/avc", "video/hevc")
|
||||
fun getCapabilitiesForType(type: String) = CodecCapabilities()
|
||||
class CodecCapabilities {
|
||||
companion object { const val FEATURE_LowLatency = "low-latency" }
|
||||
fun isFormatSupported(format: MediaFormat) = true
|
||||
fun isFeatureSupported(name: String) = false
|
||||
}
|
||||
object CodecProfileLevel {
|
||||
const val AVCProfileBaseline = 1; const val HEVCProfileMain = 1; const val VP9Profile0 = 1; const val AV1ProfileMain8 = 1
|
||||
} }
|
||||
class MediaCodecList(kind: Int) {
|
||||
companion object { const val REGULAR_CODECS = 0; var names = listOf("host.decoder") }
|
||||
val codecInfos get() = names.map { MediaCodecInfo(it) }.toTypedArray()
|
||||
fun findDecoderForFormat(format: MediaFormat) = names.firstOrNull()
|
||||
}
|
||||
|
||||
/** Настоящий RX получает input/output и EOS; тест задаёт отказы платформенных API, без декодирования bitstream. */
|
||||
class MediaCodec private constructor(val name: String) {
|
||||
@@ -25,6 +40,7 @@ class MediaCodec private constructor(val name: String) {
|
||||
const val BUFFER_FLAG_END_OF_STREAM = 4; const val INFO_OUTPUT_FORMAT_CHANGED = -2
|
||||
val created = CopyOnWriteArrayList<MediaCodec>()
|
||||
@Volatile var nextFailures = emptySet<String>()
|
||||
@Volatile var onInput: () -> Unit = {}
|
||||
fun createByCodecName(name: String): MediaCodec {
|
||||
check("create" !in nextFailures) { "decoder create failed" }
|
||||
return MediaCodec(name).also { created.add(it) }
|
||||
@@ -63,7 +79,8 @@ class MediaCodec private constructor(val name: String) {
|
||||
released = true; started = false
|
||||
check("release after" !in failures) { "decoder release failed after effect" }
|
||||
}
|
||||
fun dequeueInputBuffer(timeout: Long): Int { access("input"); return 0 }
|
||||
fun dequeueInputBuffer(timeout: Long): Int { onInput(); access("input"); return 0 }
|
||||
fun setOnFrameRenderedListener(listener: ((MediaCodec, Long, Long) -> Unit)?, handler: android.os.Handler?) {}
|
||||
fun getInputBuffer(index: Int): ByteBuffer { access("input buffer"); input.clear(); return input }
|
||||
fun queueInputBuffer(index: Int, offset: Int, size: Int, pts: Long, flags: Int) {
|
||||
access("queue"); queued.add(Frame(pts, size, flags))
|
||||
|
||||
@@ -62,3 +62,4 @@ object SystemClock {
|
||||
fun elapsedRealtime(): Long = System.nanoTime() / 1_000_000
|
||||
fun elapsedRealtimeNanos(): Long = System.nanoTime()
|
||||
}
|
||||
object Build { object VERSION { const val SDK_INT = 36 } }
|
||||
Reference in new issue
Block a user