From 9cde6f49f7c57cf8c376cca576f7642011f9d658 Mon Sep 17 00:00:00 2001 From: saxon Date: Sat, 11 Aug 2018 13:59:55 +0930 Subject: [PATCH] ported EncodeInt32LE and now using - tested and working --- rtmp/rtmp.go | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/rtmp/rtmp.go b/rtmp/rtmp.go index c0646622..edd939ba 100644 --- a/rtmp/rtmp.go +++ b/rtmp/rtmp.go @@ -1948,14 +1948,27 @@ func C_RTMP_ReadPacket(r *C.RTMP, packet *C.RTMPPacket) int32 { // static int DecodeInt32LE(const char* data); // rtmp.c +3527 -func C_DecodeInt32LE(data *byte) int { +func C_DecodeInt32LE(data *byte) int32 { var c *uint8 = (*uint8)(data) - return int((*indxBytePtr(unsafe.Pointer(c), 3) << 24) | + return int32((*indxBytePtr(unsafe.Pointer(c), 3) << 24) | (*indxBytePtr(unsafe.Pointer(c), 2) << 16) | (*indxBytePtr(unsafe.Pointer(c), 1) << 8) | *c) } +// int EncodeInt32LE(char* output, int nVal); +// rtmp.c +3537 +func C_EncodeInt32LE(output *byte, nVal int32) int32 { + *output = byte(nVal) + nVal >>= 8 + *indxBytePtr(unsafe.Pointer(output), 1) = byte(nVal) + nVal >>= 8 + *indxBytePtr(unsafe.Pointer(output), 2) = byte(nVal) + nVal >>= 8 + *indxBytePtr(unsafe.Pointer(output), 3) = byte(nVal) + return 4 +} + // #define RTMPPacket_IsReady(a) // rtmp.h +142 func C_RTMPPacket_IsReady(p *C.RTMPPacket) int { @@ -2226,8 +2239,10 @@ func C_RTMP_SendPacket(r *C.RTMP, packet *C.RTMPPacket, queue int) int { if nSize > 8 { // TODO: port this - hptr = incBytePtr(hptr, int(C.EncodeInt32LE((*C.char)(hptr), - C.int(packet.m_nInfoField2)))) + hptr = incBytePtr(hptr, int(C_EncodeInt32LE((*byte)(hptr), + int32(packet.m_nInfoField2)))) + //hptr = incBytePtr(hptr, int(C.EncodeInt32LE((*C.char)(hptr), + //C.int(packet.m_nInfoField2)))) } if t >= 0xffffff {