Skip to content

Commit 2d2621d

Browse files
committed
fix(core): made packet and srt packet properties non mutable
1 parent 2e4db6c commit 2d2621d

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

core/src/main/java/io/github/thibaultbee/streampack/core/internal/data/Packet.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,24 @@ open class Packet(
2525
/**
2626
* Contains data.
2727
*/
28-
var buffer: ByteBuffer,
28+
val buffer: ByteBuffer,
2929

3030
/**
3131
* Frame timestamp in µs.
3232
*/
33-
var ts: Long, // in µs
33+
val ts: Long, // in µs
3434

3535
/**
3636
* Packet data type
3737
*/
38-
var type: PacketType = PacketType.UNKNOWN,
38+
val type: PacketType = PacketType.UNKNOWN,
3939
) {
4040
val isVideo = type == PacketType.VIDEO
4141
val isAudio = type == PacketType.AUDIO
42+
43+
override fun toString(): String {
44+
return "Packet(buffer=$buffer, ts=$ts, type=$type)"
45+
}
4246
}
4347

4448
enum class PacketType {

core/src/main/java/io/github/thibaultbee/streampack/core/internal/data/SrtPacket.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,18 @@ class SrtPacket(
2929
/**
3030
* [Boolean.true] if this is the first packet that describes a frame.
3131
*/
32-
var isFirstPacketFrame: Boolean,
32+
val isFirstPacketFrame: Boolean,
3333
/**
3434
* [Boolean.true] if this is the last packet that describes a frame.
3535
*/
36-
var isLastPacketFrame: Boolean,
36+
val isLastPacketFrame: Boolean,
3737
/**
3838
* Frame timestamp in µs.
3939
*/
4040
ts: Long, // in µs
41-
) : Packet(buffer, ts)
41+
42+
/**
43+
* Packet data type
44+
*/
45+
type: PacketType = PacketType.UNKNOWN,
46+
) : Packet(buffer, ts, type)

0 commit comments

Comments
 (0)