Skip to content

Commit 8a99fdc

Browse files
committed
read SRT data packet on received
1 parent 6f0abf3 commit 8a99fdc

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

srt/src/main/java/com/pedro/srt/srt/packets/SrtPacket.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,16 @@ abstract class SrtPacket {
4444
@Throws(IOException::class)
4545
fun getSrtPacket(buffer: ByteArray): SrtPacket {
4646
val packetType = PacketType.from((buffer[0].toInt() ushr 7) and 0x01)
47+
val input = ByteArrayInputStream(buffer)
4748
when (packetType) {
4849
PacketType.DATA -> {
49-
return DataPacket()
50+
val dataPacket = DataPacket()
51+
dataPacket.read(input)
52+
return dataPacket
5053
}
5154
PacketType.CONTROL -> {
5255
val headerData = buffer.sliceArray(0 until 4)
53-
val type = ControlPacket.getType(ByteArrayInputStream(headerData))
54-
val input = ByteArrayInputStream(buffer)
55-
when (type) {
56+
when (val type = ControlPacket.getType(ByteArrayInputStream(headerData))) {
5657
ControlType.HANDSHAKE -> {
5758
val handshake = Handshake()
5859
handshake.read(input)

0 commit comments

Comments
 (0)