Skip to content

Commit

Permalink
update keyframe in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroSG94 committed Oct 1, 2024
1 parent 740db74 commit de0458f
Show file tree
Hide file tree
Showing 13 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion common/src/test/java/com/pedro/common/ExtensionTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ExtensionTest {
val buffer = ByteBuffer.wrap(ByteArray(256) { 0x00 }.mapIndexed { index, byte -> index.toByte() }.toByteArray())
val offset = 4
val minusLimit = 2
val info = MediaFrame.Info(4, buffer.remaining() - minusLimit, 0, 0)
val info = MediaFrame.Info(4, buffer.remaining() - minusLimit, 0, false)
val result = buffer.removeInfo(info)
assertEquals(buffer.capacity() - offset - minusLimit, result.remaining())
assertEquals(offset.toByte(), result.get(0))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class AacPacketTest {
fun `GIVEN a aac buffer WHEN call create a aac packet 2 times THEN return config and expected buffer`() = runTest {
val timestamp = 123456789L
val buffer = ByteArray(256) { 0x00 }
val info = MediaFrame.Info(0, buffer.size, timestamp, 1)
val info = MediaFrame.Info(0, buffer.size, timestamp, false)
val aacPacket = AacPacket()
aacPacket.sendAudioInfo(32000, true)
aacPacket.createFlvPacket(ByteBuffer.wrap(buffer), info) { flvPacket ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class G711PacketTest {
fun `GIVEN a G711 buffer WHEN call create a G711 packet THEN expected buffer`() = runTest {
val timestamp = 123456789L
val buffer = ByteArray(256) { 0x00 }
val info = MediaFrame.Info(0, buffer.size, timestamp, 1)
val info = MediaFrame.Info(0, buffer.size, timestamp, false)
val g711Packet = G711Packet()
g711Packet.sendAudioInfo()
g711Packet.createFlvPacket(ByteBuffer.wrap(buffer), info) { flvPacket ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Av1PacketTest {
val expectedConfig = byteArrayOf(-112, 97, 118, 48, 49, -127, 4, 12, 0, 10, 13, 0, 0, 0, 36, 79, 126, 127, 0, 104, -125, 0, -125, 2)
val expectedFlvPacket = byteArrayOf(-111, 97, 118, 48, 49, 10, 13, 0, 0, 0, 36, 79, 126, 127, 0, 104, -125, 0, -125, 2)

val info = MediaFrame.Info(0, av1data.size, timestamp, 1)
val info = MediaFrame.Info(0, av1data.size, timestamp, true)

val frames = mutableListOf<FlvPacket>()
val av1Packet = Av1Packet()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class H264PacketTest {
val expectedConfig = byteArrayOf(23, 0, 0, 0, 0, 1, 100, 0, 30, -1, -31, 0, 17, 103, 100, 0, 30, -84, -76, 15, 2, -115, 53, 2, 2, 2, 7, -117, 23, 8, 1, 0, 4, 104, -18, 13, -117)
val expectedFlvPacket = byteArrayOf(23, 1, 0, 0, 0, 0, 0, 1, 45, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)

val info = MediaFrame.Info(0, fakeH264.size, timestamp, 1)
val info = MediaFrame.Info(0, fakeH264.size, timestamp, true)
val h264Packet = H264Packet()
val sps = byteArrayOf(103, 100, 0, 30, -84, -76, 15, 2, -115, 53, 2, 2, 2, 7, -117, 23, 8)
val pps = byteArrayOf(104, -18, 13, -117)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class H265PacketTest {
val expectedConfig = byteArrayOf(-112, 104, 118, 99, 49, 1, 1, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, -103, -16, 0, -4, -3, -8, -8, 0, 0, 3, 3, -96, 0, 1, 0, 24, 64, 1, 12, 1, -1, -1, 1, 96, 0, 0, 3, 0, 0, 3, 0, 0, 3, 0, 0, 3, 0, -103, 44, 9, -95, 0, 1, 0, 35, 66, 1, 1, 1, 96, 0, 0, 3, 0, 0, 3, 0, 0, 3, 0, 0, 3, 0, -103, -96, 15, 8, 2, -127, 104, -76, -82, -55, 46, -26, -96, -64, -64, -64, 16, -94, 0, 1, 0, 8, 68, 1, -64, 102, 124, 12, -58, 64)
val expectedFlvPacket = byteArrayOf(-111, 104, 118, 99, 49, 0, 0, 0, 0, 0, 1, 45, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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ArrayOf(66, 1, 1, 1, 96, 0, 0, 3, 0, 0, 3, 0, 0, 3, 0, 0, 3, 0, -103, -96, 15, 8, 2, -127, 104, -76, -82, -55, 46, -26, -96, -64, -64, -64, 16)
Expand Down
2 changes: 1 addition & 1 deletion rtsp/src/test/java/com/pedro/rtsp/rtp/AacPacketTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class AacPacketTest {
val timestamp = 123456789L
val fakeAac = ByteArray(300) { 0x00 }

val info = MediaFrame.Info(0, fakeAac.size, timestamp, 1)
val info = MediaFrame.Info(0, fakeAac.size, timestamp, false)
val aacPacket = AacPacket().apply { setAudioInfo(44100) }
aacPacket.setSSRC(123456789)
val frames = mutableListOf<RtpFrame>()
Expand Down
2 changes: 1 addition & 1 deletion rtsp/src/test/java/com/pedro/rtsp/rtp/Av1PacketTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Av1PacketTest {
val timestamp = 123456789L
val av1data = byteArrayOf(0x0a, 0x0d, 0x00, 0x00, 0x00, 0x24, 0x4f, 0x7e, 0x7f, 0x00, 0x68, 0x83.toByte(), 0x00, 0x83.toByte(), 0x02)

val info = MediaFrame.Info(0, av1data.size, timestamp, 1)
val info = MediaFrame.Info(0, av1data.size, timestamp, true)

val frames = mutableListOf<RtpFrame>()
val av1Packet = Av1Packet()
Expand Down
2 changes: 1 addition & 1 deletion rtsp/src/test/java/com/pedro/rtsp/rtp/G711PacketTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class G711PacketTest {
val timestamp = 123456789L
val fakeG711 = ByteArray(30) { 0x05 }

val info = MediaFrame.Info(0, fakeG711.size, timestamp, 1)
val info = MediaFrame.Info(0, fakeG711.size, timestamp, false)
val g711Packet = G711Packet().apply { setAudioInfo(8000) }
g711Packet.setSSRC(123456789)
val frames = mutableListOf<RtpFrame>()
Expand Down
4 changes: 2 additions & 2 deletions rtsp/src/test/java/com/pedro/rtsp/rtp/H264PacketTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class H264PacketTest {
val header = byteArrayOf(0x00, 0x00, 0x00, 0x01, 0x05)
val fakeH264 = header.plus(ByteArray(300) { 0x00 })

val info = MediaFrame.Info(0, fakeH264.size, timestamp, 1)
val info = MediaFrame.Info(0, fakeH264.size, timestamp, true)
val fakeSps = byteArrayOf(0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04)
val fakePps = byteArrayOf(0x00, 0x00, 0x00, 0x01, 0x0A, 0x0B, 0x0C)
val h264Packet = H264Packet().apply { sendVideoInfo(ByteBuffer.wrap(fakeSps), ByteBuffer.wrap(fakePps)) }
Expand Down Expand Up @@ -67,7 +67,7 @@ class H264PacketTest {
val header = byteArrayOf(0x00, 0x00, 0x00, 0x01, 0x05)
val fakeH264 = header.plus(ByteArray(2500) { 0x00 })

val info = MediaFrame.Info(0, fakeH264.size, timestamp, 1)
val info = MediaFrame.Info(0, fakeH264.size, timestamp, true)
val fakeSps = byteArrayOf(0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04)
val fakePps = byteArrayOf(0x00, 0x00, 0x00, 0x01, 0x0A, 0x0B, 0x0C)
val h264Packet = H264Packet().apply { sendVideoInfo(ByteBuffer.wrap(fakeSps), ByteBuffer.wrap(fakePps)) }
Expand Down
4 changes: 2 additions & 2 deletions rtsp/src/test/java/com/pedro/rtsp/rtp/H265PacketTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class H265PacketTest {
val header = byteArrayOf(0x00, 0x00, 0x00, 0x01, 0x05, 0x00)
val fakeH265 = header.plus(ByteArray(300) { 0x00 })

val info = MediaFrame.Info(0, fakeH265.size, timestamp, 1)
val info = MediaFrame.Info(0, fakeH265.size, timestamp, true)

val h265Packet = H265Packet()
h265Packet.setSSRC(123456789)
Expand All @@ -63,7 +63,7 @@ class H265PacketTest {
val header = byteArrayOf(0x00, 0x00, 0x00, 0x01, 0x05, 0x00)
val fakeH265 = header.plus(ByteArray(2500) { 0x00 })

val info = MediaFrame.Info(0, fakeH265.size, timestamp, 1)
val info = MediaFrame.Info(0, fakeH265.size, timestamp, true)
val h265Packet = H265Packet()
h265Packet.setSSRC(123456789)
val frames = mutableListOf<RtpFrame>()
Expand Down
2 changes: 1 addition & 1 deletion rtsp/src/test/java/com/pedro/rtsp/rtp/OpusPacketTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class OpusPacketTest {
val timestamp = 123456789L
val fakeOpus = ByteArray(30) { 0x05 }

val info = MediaFrame.Info(0, fakeOpus.size, timestamp, 1)
val info = MediaFrame.Info(0, fakeOpus.size, timestamp, false)
val opusPacket = OpusPacket().apply { setAudioInfo(8000) }
opusPacket.setSSRC(123456789)
val frames = mutableListOf<RtpFrame>()
Expand Down
4 changes: 2 additions & 2 deletions srt/src/test/java/com/pedro/srt/srt/SrtSenderTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ class SrtSenderTest {
val videoData = ByteBuffer.wrap(header.plus(ByteArray(300) { 0x00 }))
val audioData = ByteBuffer.wrap(ByteArray(256) { 0x00 })

val videoFrame = MediaFrame(videoData, MediaFrame.Info(0, videoData.remaining(), 0, 1), MediaFrame.Type.VIDEO)
val audioFrame = MediaFrame(audioData, MediaFrame.Info(0, audioData.remaining(), 0, 1), MediaFrame.Type.AUDIO)
val videoFrame = MediaFrame(videoData, MediaFrame.Info(0, videoData.remaining(), 0, true), MediaFrame.Type.VIDEO)
val audioFrame = MediaFrame(audioData, MediaFrame.Info(0, audioData.remaining(), 0, false), MediaFrame.Type.AUDIO)
srtSender.sendMediaFrame(videoFrame)
srtSender.sendMediaFrame(audioFrame)
latch.await(1000, TimeUnit.MILLISECONDS)
Expand Down

0 comments on commit de0458f

Please sign in to comment.