@@ -99,9 +99,11 @@ class SabrLivePlaybackSessionServiceTest {
9999 fun `historical live content prepares as vod` () = runTest {
100100 val audio = format(140 , isAudio = true )
101101 val video = format(137 , isAudio = false )
102+ val replacementVideo = format(248 , isAudio = false )
102103 val info = mockk<YoutubeSabrInfo >()
103104 val prepared = SabrPreparedInfo (info, token(), isLive = false , isLiveContent = true )
104105 val holder = holder(audio, video)
106+ val replacement = holder(audio, replacementVideo, initialGeneration = 1L )
105107 val state = holder.session.streamState
106108 val store = mockk<SabrSessionStore >()
107109 every {
@@ -119,19 +121,43 @@ class SabrLivePlaybackSessionServiceTest {
119121 0L ,
120122 )
121123 } returns holder
124+ every {
125+ store.getOrCreate(
126+ " video" ,
127+ " user" ,
128+ info,
129+ audio,
130+ replacementVideo,
131+ prepared.initialToken,
132+ 30_000L ,
133+ false ,
134+ SabrSessionPurpose .PLAYBACK ,
135+ false ,
136+ 1L ,
137+ )
138+ } returns replacement
122139 coEvery { store.fetchInitializationData(holder, video) } returns byteArrayOf(1 )
123140 coEvery { store.fetchInitializationData(holder, audio) } returns byteArrayOf(2 )
141+ coEvery { store.fetchInitializationData(replacement, replacementVideo) } returns byteArrayOf(3 )
142+ coEvery { store.fetchInitializationData(replacement, audio) } returns byteArrayOf(4 )
124143 every { store.startPump(holder) } returns Unit
144+ every { store.startPump(replacement) } returns Unit
125145
126- val result = SabrPlaybackSessionService (store).prepare(" video" , " user" , prepared, audio, video, 0L )
146+ val service = SabrPlaybackSessionService (store)
147+ val result = service.prepare(" video" , " user" , prepared, audio, video, 0L )
148+ service.seek(holder, prepared, audio, replacementVideo, 30_000L )
127149
128150 assertEquals(0L , result.startTimeMs)
129151 assertFalse(holder.expectsLive())
152+ assertFalse(replacement.expectsLive())
130153 verify(exactly = 0 ) { state.setPlayerTimeMs(9_007_199_254_740_991L ) }
131154 coVerify(exactly = 0 ) { store.ensureWarmed(any(), any()) }
132155 coVerify(exactly = 1 ) { store.fetchInitializationData(holder, video) }
133156 coVerify(exactly = 1 ) { store.fetchInitializationData(holder, audio) }
157+ coVerify(exactly = 1 ) { store.fetchInitializationData(replacement, replacementVideo) }
158+ coVerify(exactly = 1 ) { store.fetchInitializationData(replacement, audio) }
134159 verify(exactly = 1 ) { store.startPump(holder) }
160+ verify(exactly = 1 ) { store.startPump(replacement) }
135161 }
136162
137163 @Test
0 commit comments