Skip to content

Commit

Permalink
fix AmfLongString
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroSG94 committed Nov 9, 2023
1 parent 8f034fc commit 2cdd1c1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions rtmp/src/main/java/com/pedro/rtmp/amf/v0/AmfLongString.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ import java.io.OutputStream
*/
open class AmfLongString(var value: String = ""): AmfData() {

private var bodySize: Int = value.toByteArray(Charsets.UTF_8).size + 2
private var bodySize: Int = value.toByteArray(Charsets.UTF_8).size + 4

@Throws(IOException::class)
override fun readBody(input: InputStream) {
//read value size as UInt32
bodySize = input.readUInt32()
//read value in UTF-8
val bytes = ByteArray(bodySize)
bodySize += 2
bodySize += 4
input.readUntil(bytes)
value = String(bytes, Charsets.UTF_8)
}
Expand All @@ -45,7 +45,7 @@ open class AmfLongString(var value: String = ""): AmfData() {
override fun writeBody(output: OutputStream) {
val bytes = value.toByteArray(Charsets.UTF_8)
//write value size as UInt32. Value size not included
output.writeUInt32(bodySize - 2)
output.writeUInt32(bodySize - 4)
//write value bytes in UTF-8
output.write(bytes)
}
Expand Down

0 comments on commit 2cdd1c1

Please sign in to comment.