Wire reviewed emotion bridges and action media playback fences
This commit is contained in:
@@ -9,9 +9,12 @@ object CodecFixture {
|
||||
var timestampOffsetUs=0L; var outputEnabled=true; var configureFails=false
|
||||
var seeks=mutableListOf<Long>(); var releases=0; var flushes=0
|
||||
var rendered=mutableListOf<Long>(); var onRender: ((Long) -> Unit)? = null
|
||||
var emitNativeSurface=false
|
||||
val timelines=mutableMapOf<String,List<Long>>()
|
||||
fun reset() {
|
||||
frames=20; fps=20; gop=4; firstPtsUs=0; timestampOffsetUs=0; outputEnabled=true; configureFails=false
|
||||
seeks.clear(); releases=0; flushes=0; rendered.clear(); onRender=null
|
||||
emitNativeSurface=false;timelines.clear()
|
||||
}
|
||||
}
|
||||
class MediaFormat {
|
||||
@@ -21,12 +24,13 @@ class MediaFormat {
|
||||
}
|
||||
class MediaExtractor {
|
||||
val trackCount=1; private var frame=0
|
||||
val sampleTime: Long get() = if (frame >= CodecFixture.frames) -1L else CodecFixture.firstPtsUs+frame*1_000_000L/CodecFixture.fps
|
||||
fun setDataSource(fd: java.io.FileDescriptor,offset: Long,length: Long) {}
|
||||
private var timeline: List<Long>?=null
|
||||
val sampleTime: Long get() = timeline?.getOrNull(frame) ?: if(frame >= (timeline?.size ?: CodecFixture.frames)) -1L else CodecFixture.firstPtsUs+frame*1_000_000L/CodecFixture.fps
|
||||
fun setDataSource(fd: java.io.FileDescriptor,offset: Long,length: Long) { timeline=CodecFixture.timelines[android.content.AssetFixture.paths[fd]] }
|
||||
fun getTrackFormat(index: Int) = MediaFormat()
|
||||
fun selectTrack(index: Int) {}
|
||||
fun seekTo(time: Long,mode: Int) { CodecFixture.seeks += time; frame=(time*CodecFixture.fps/1_000_000).toInt()/CodecFixture.gop*CodecFixture.gop }
|
||||
fun readSampleData(buffer: ByteBuffer,offset: Int): Int = if (frame >= CodecFixture.frames) -1 else 1
|
||||
fun readSampleData(buffer: ByteBuffer,offset: Int): Int = if (frame >= (timeline?.size ?: CodecFixture.frames)) -1 else 1
|
||||
fun advance() { frame++ }
|
||||
fun release() {}
|
||||
companion object { const val SEEK_TO_PREVIOUS_SYNC=0 }
|
||||
@@ -35,11 +39,12 @@ class MediaCodec {
|
||||
class BufferInfo { var presentationTimeUs=0L; var flags=0; var size=0 }
|
||||
private data class Output(val pts: Long,val flags: Int,val size: Int)
|
||||
private val queue=java.util.ArrayDeque<Output>(); private var current: Output? = null
|
||||
private var target: Surface?=null
|
||||
companion object {
|
||||
const val BUFFER_FLAG_END_OF_STREAM=4
|
||||
fun createDecoderByType(mime: String) = MediaCodec()
|
||||
}
|
||||
fun configure(format: MediaFormat,surface: Surface,crypto: Any?,flags: Int) { check(!CodecFixture.configureFails) }
|
||||
fun configure(format: MediaFormat,surface: Surface,crypto: Any?,flags: Int) { check(!CodecFixture.configureFails);target=surface }
|
||||
fun start() {}
|
||||
fun dequeueInputBuffer(timeout: Long) = 0
|
||||
fun getInputBuffer(index: Int): ByteBuffer = ByteBuffer.allocate(32)
|
||||
@@ -51,7 +56,9 @@ class MediaCodec {
|
||||
return 0
|
||||
}
|
||||
fun releaseOutputBuffer(index: Int,render: Boolean) {
|
||||
if (render) { val pts=checkNotNull(current).pts; CodecFixture.rendered += pts; CodecFixture.onRender?.invoke(pts) }
|
||||
if (render) { val pts=checkNotNull(current).pts; CodecFixture.rendered += pts; CodecFixture.onRender?.invoke(pts)
|
||||
if(CodecFixture.emitNativeSurface) target?.texture?.emit(pts*1000)
|
||||
}
|
||||
}
|
||||
fun flush() { queue.clear(); CodecFixture.flushes++ }
|
||||
fun stop() {}
|
||||
|
||||
Reference in New Issue
Block a user