Skip to content

Commit

Permalink
fix psi tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroSG94 committed Sep 30, 2024
1 parent c0ed321 commit 5bd40f9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 34 deletions.
25 changes: 0 additions & 25 deletions srt/src/main/java/com/pedro/srt/mpeg2ts/psi/TableToSend.kt

This file was deleted.

20 changes: 12 additions & 8 deletions srt/src/test/java/com/pedro/srt/mpeg2ts/PsiManagerTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.pedro.srt.mpeg2ts

import com.pedro.srt.mpeg2ts.psi.PsiManager
import com.pedro.srt.mpeg2ts.psi.TableToSend
import com.pedro.srt.mpeg2ts.service.Mpeg2TsService
import org.junit.Assert.assertEquals
import org.junit.Test
Expand All @@ -27,26 +26,31 @@ import org.junit.Test
*/
class PsiManagerTest {

private val service = Mpeg2TsService()
private val service = Mpeg2TsService().apply { generatePmt() }
private val psiManager = PsiManager(service).apply {
upgradePatVersion()
upgradeSdtVersion()
}
private val mpegTsPacketizer = MpegTsPacketizer(psiManager)

@Test
fun `GIVEN a psiManager WHEN call should send is key false patPeriod times THEN return TableToSend PAT_PMT`() {
val psiManager = PsiManager(service)
var sendValue = TableToSend.NONE
var packets = listOf<MpegTsPacket>()
(0..PsiManager.patPeriod).forEach { _ ->
sendValue = psiManager.shouldSend(false)
packets = psiManager.checkSendInfo(false, mpegTsPacketizer)
}
assertEquals(TableToSend.PAT_PMT, sendValue)
assertEquals(2, packets.size)
}

@Test
fun `GIVEN a psiManager WHEN call should send is key false sdtPeriod times THEN return TableToSend ALL`() {
val psiManager = PsiManager(service)
var sendValue = TableToSend.NONE
var packets = listOf<MpegTsPacket>()
(0..PsiManager.sdtPeriod).forEach { _ ->
sendValue = psiManager.shouldSend(false)
packets = psiManager.checkSendInfo(false, mpegTsPacketizer)
}
assertEquals(TableToSend.ALL, sendValue)
assertEquals(3, packets.size)
}

@Test
Expand Down
1 change: 0 additions & 1 deletion udp/src/main/java/com/pedro/udp/UdpSender.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import com.pedro.srt.mpeg2ts.packets.BasePacket
import com.pedro.srt.mpeg2ts.packets.H26XPacket
import com.pedro.srt.mpeg2ts.packets.OpusPacket
import com.pedro.srt.mpeg2ts.psi.PsiManager
import com.pedro.srt.mpeg2ts.psi.TableToSend
import com.pedro.srt.mpeg2ts.service.Mpeg2TsService
import com.pedro.srt.srt.packets.data.PacketPosition
import com.pedro.srt.utils.Constants
Expand Down

0 comments on commit 5bd40f9

Please sign in to comment.