Skip to content

Commit 245ee3a

Browse files
committed
add small MPEGTS aac buffer test
1 parent 4ba166e commit 245ee3a

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

srt/src/test/java/com/pedro/srt/mpeg2ts/PesTest.kt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,27 @@ class PesTest {
6363
assertArrayEquals(expected.array(), buffer.array())
6464
}
6565
}
66+
67+
@Test
68+
fun `GIVEN a fake aac buffer small WHEN create a mpegts packet with pes packet THEN get the expected buffer`() = runTest {
69+
Utils.useStatics(listOf(timeUtilsMock)) {
70+
val data = ByteBuffer.wrap(
71+
ByteArray(10) { 0xAA.toByte() }
72+
)
73+
val expected = ByteBuffer.wrap(
74+
byteArrayOf(71, 65, 0, 16, 7, 80, 0, 0, 123, 12, 126, 0, 0, 0, 1, -64, 0, 18, -127, -128, 5, 33, 0, 7, -40, 97, -86, -86, -86, -86, -86, -86, -86, -86, -86, -86, -105, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1)
75+
)
76+
val psiManager = PsiManager(service)
77+
val mpegTsPacketizer = MpegTsPacketizer(psiManager)
78+
val pes = Pes(256, true, PesType.AUDIO, 1400000, data)
79+
val mpeg2tsPackets = mpegTsPacketizer.write(listOf(pes))
80+
val chunked = mpeg2tsPackets
81+
val size = chunked.sumOf { it.size }
82+
val buffer = ByteBuffer.allocate(size)
83+
chunked.forEach {
84+
buffer.put(it)
85+
}
86+
assertArrayEquals(expected.array(), buffer.array())
87+
}
88+
}
6689
}

0 commit comments

Comments
 (0)