Fix action playback source clock using controlled video decode
This commit is contained in:
@@ -37,6 +37,7 @@ fun actualMediaViewCheck() {
|
||||
fun rig(index: EmotionActionIndex=mediaFixtureIndex()): Triple<EmotionActionAvatarView,AvatarMediaBinding,MutableList<VideoPresentation>> {
|
||||
index.packages.values.forEach { CodecFixture.timelines[it.root+it.body.path]=it.body.ptsUs }
|
||||
index.edges.filterNot { it.nativeLoop }.forEach { CodecFixture.timelines[(it.mouthRuntime?.root ?: index.root)+(it.mouthRuntime?.body?.path ?: it.clip.path)]=it.clip.ptsUs }
|
||||
index.actionPack?.assets?.mapNotNull { it.media }?.forEach { CodecFixture.timelines[it.root+it.path]=it.ptsUs;CodecFixture.audioPaths.add(it.root+it.path) }
|
||||
val binding=AvatarMediaBinding();binding.beginTurn(7)
|
||||
val reports=mutableListOf<VideoPresentation>()
|
||||
val view=EmotionActionAvatarView(android.content.Context(),AvatarPack(fallback="fixture.png",emotionAction=index),binding,reports::add)
|
||||
@@ -113,11 +114,11 @@ fun actualMediaViewCheck() {
|
||||
stopped!!(true);val movie=MediaPlayer.created.single()
|
||||
check(!movie.started);movie.prepared!!(movie)
|
||||
TestScheduler.until { movie.started }
|
||||
check(trace.last().clipId.startsWith("f96_") && trace.last().actual=="action");cases++
|
||||
check(trace.any { it.clipId.startsWith("f96_") && it.actual=="action" } && trace.last().actual=="action_first_frame");cases++
|
||||
val textures=actionView.children.filterIsInstance<TextureView>()
|
||||
fun latch(pts: Long) { val texture=checkNotNull(textures[3].surfaceTexture);texture.timestamp=pts*1000
|
||||
textures[3].surfaceTextureListener!!.onSurfaceTextureUpdated(texture) }
|
||||
check(textures[3].alpha==0f);latch(0);check(textures[3].alpha==1f);cases++
|
||||
check(textures[3].alpha==1f);latch(0);check(textures[3].alpha==1f);cases++
|
||||
when(mode) {
|
||||
"complete","late_final_frame" -> {
|
||||
index.actionPack!!.assets.first().media!!.ptsUs.drop(1).dropLast(if(mode=="late_final_frame") 1 else 0).forEach(::latch)
|
||||
@@ -145,7 +146,7 @@ fun actualMediaViewCheck() {
|
||||
val base=mediaFixtureIndex()
|
||||
val original=base.actionPack!!.assets.first()
|
||||
val media=original.media!!.copy(ptsUs=List(241) { it*1_000_000L/24 },durationUs=10_041_667,
|
||||
sourceFrame=0,returnFrame=96)
|
||||
sourceFrame=0,returnFrame=96,audioEndUs=10_000_000)
|
||||
val asset=original.copy(durationMs=10_042,media=media)
|
||||
val index=base.copy(actionPack=base.actionPack.copy(assets=listOf(asset,asset.copy(id="asset_02"))))
|
||||
val (v,b,trace)=rig(index)
|
||||
@@ -158,8 +159,8 @@ fun actualMediaViewCheck() {
|
||||
val textures=v.children.filterIsInstance<TextureView>()
|
||||
fun latch(pts: Long) { val t=textures[3].surfaceTexture!!;t.timestamp=pts*1000;textures[3].surfaceTextureListener!!.onSurfaceTextureUpdated(t) }
|
||||
val owner=driverField.get(v) as ConversationMediaDriver
|
||||
// Delayed first frame leaves the last valid body visible, with ACTION owning it.
|
||||
TestScheduler.advanceBy(80);check(owner.layerOwner==ConversationMediaDriver.LayerOwner.ACTION && textures[3].alpha==0f);cases++
|
||||
// First source frame was decoded+latched and held before native audio could start.
|
||||
TestScheduler.advanceBy(80);check(owner.layerOwner==ConversationMediaDriver.LayerOwner.ACTION && textures[3].alpha==1f);cases++
|
||||
latch(0);TestScheduler.advanceBy(21)
|
||||
check(textures[3].alpha==1f && textures.take(3).all { it.alpha==0f } && player.started);cases++
|
||||
prepared(player) // Duplicated ready cannot start/reclaim again.
|
||||
|
||||
Reference in New Issue
Block a user