Fix action playback source clock using controlled video decode
This commit is contained in:
@@ -11,23 +11,26 @@ object CodecFixture {
|
||||
var rendered=mutableListOf<Long>(); var onRender: ((Long) -> Unit)? = null
|
||||
var emitNativeSurface=false
|
||||
val timelines=mutableMapOf<String,List<Long>>()
|
||||
val audioPaths=mutableSetOf<String>()
|
||||
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()
|
||||
emitNativeSurface=false;timelines.clear();audioPaths.clear()
|
||||
}
|
||||
}
|
||||
class MediaFormat {
|
||||
class MediaFormat(private val mime: String="video/avc") {
|
||||
companion object { const val KEY_MIME="mime"; const val KEY_WIDTH="width"; const val KEY_HEIGHT="height" }
|
||||
fun getString(key: String): String? = "video/avc"
|
||||
fun getString(key: String): String? = mime
|
||||
fun getInteger(key: String): Int = if (key == KEY_WIDTH) 480 else 848
|
||||
}
|
||||
class MediaExtractor {
|
||||
val trackCount=1; private var frame=0
|
||||
private var av=false
|
||||
val trackCount get()=if(av) 2 else 1
|
||||
private var frame=0
|
||||
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 setDataSource(fd: java.io.FileDescriptor,offset: Long,length: Long) { val path=android.content.AssetFixture.paths[fd];timeline=CodecFixture.timelines[path];av=path in CodecFixture.audioPaths }
|
||||
fun getTrackFormat(index: Int) = MediaFormat(if(av && index==1) "audio/mp4a-latm" else "video/avc")
|
||||
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 >= (timeline?.size ?: CodecFixture.frames)) -1 else 1
|
||||
|
||||
Reference in New Issue
Block a user