From a3c95e6864cf38fa9443761f7ff4ac4119ea254c Mon Sep 17 00:00:00 2001 From: ThibaultBee <37510686+ThibaultBee@users.noreply.github.com> Date: Wed, 8 Jan 2025 15:18:42 +0100 Subject: [PATCH] fix(core): made packet and srt packet properties non mutable --- .../streampack/core/internal/data/Packet.kt | 10 +++++++--- .../streampack/core/internal/data/SrtPacket.kt | 11 ++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/io/github/thibaultbee/streampack/core/internal/data/Packet.kt b/core/src/main/java/io/github/thibaultbee/streampack/core/internal/data/Packet.kt index 68ded2a95..6686fda4c 100644 --- a/core/src/main/java/io/github/thibaultbee/streampack/core/internal/data/Packet.kt +++ b/core/src/main/java/io/github/thibaultbee/streampack/core/internal/data/Packet.kt @@ -25,20 +25,24 @@ open class Packet( /** * Contains data. */ - var buffer: ByteBuffer, + val buffer: ByteBuffer, /** * Frame timestamp in µs. */ - var ts: Long, // in µs + val ts: Long, // in µs /** * Packet data type */ - var type: PacketType = PacketType.UNKNOWN, + val type: PacketType = PacketType.UNKNOWN, ) { val isVideo = type == PacketType.VIDEO val isAudio = type == PacketType.AUDIO + + override fun toString(): String { + return "Packet(buffer=$buffer, ts=$ts, type=$type)" + } } enum class PacketType { diff --git a/core/src/main/java/io/github/thibaultbee/streampack/core/internal/data/SrtPacket.kt b/core/src/main/java/io/github/thibaultbee/streampack/core/internal/data/SrtPacket.kt index fa8672beb..158fa1fb6 100644 --- a/core/src/main/java/io/github/thibaultbee/streampack/core/internal/data/SrtPacket.kt +++ b/core/src/main/java/io/github/thibaultbee/streampack/core/internal/data/SrtPacket.kt @@ -29,13 +29,18 @@ class SrtPacket( /** * [Boolean.true] if this is the first packet that describes a frame. */ - var isFirstPacketFrame: Boolean, + val isFirstPacketFrame: Boolean, /** * [Boolean.true] if this is the last packet that describes a frame. */ - var isLastPacketFrame: Boolean, + val isLastPacketFrame: Boolean, /** * Frame timestamp in µs. */ ts: Long, // in µs -) : Packet(buffer, ts) \ No newline at end of file + + /** + * Packet data type + */ + type: PacketType = PacketType.UNKNOWN, +) : Packet(buffer, ts, type) \ No newline at end of file