rtmp: Implement afmDecodeInt16

This commit is contained in:
Jake Lane 2018-07-19 16:22:35 +09:30
parent cc616b12d4
commit 6903276a18
1 changed files with 7 additions and 1 deletions

View File

@ -794,7 +794,7 @@ func sendPacket(r *C.RTMP, packet *C.RTMPPacket, queue int) int {
// afmDecodeString decodes data into a string inside a AVal
func afmDecodeString(data *byte, bv *C.AVal) {
dataPtr := unsafe.Pointer(data)
bv.av_len = C.int(C.AMF_DecodeInt16((*C.char)(dataPtr)))
bv.av_len = C.int(afmDecodeInt16((*byte)(dataPtr)))
if bv.av_len > 0 {
bv.av_val = (*C.char)(incBytePtr(dataPtr, 2))
@ -803,6 +803,12 @@ func afmDecodeString(data *byte, bv *C.AVal) {
}
}
// afmDecodeInt16 decodes data into a 16 bit number
func afmDecodeInt16(data *byte) uint16 {
c := unsafe.Pointer(data)
return (uint16(*(*uint8)(c)) << 8) | *(*uint16)(incBytePtr(c, 1))
}
func writeN(r *C.RTMP, buffer unsafe.Pointer, n int) int {
ptr := buffer
for n > 0 {