ported EncodeInt32LE and now using - tested and working

This commit is contained in:
saxon 2018-08-11 13:59:55 +09:30
parent e680fc76fa
commit 9cde6f49f7
1 changed files with 19 additions and 4 deletions

View File

@ -1948,14 +1948,27 @@ func C_RTMP_ReadPacket(r *C.RTMP, packet *C.RTMPPacket) int32 {
// static int DecodeInt32LE(const char* data); // static int DecodeInt32LE(const char* data);
// rtmp.c +3527 // rtmp.c +3527
func C_DecodeInt32LE(data *byte) int { func C_DecodeInt32LE(data *byte) int32 {
var c *uint8 = (*uint8)(data) 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), 2) << 16) |
(*indxBytePtr(unsafe.Pointer(c), 1) << 8) | (*indxBytePtr(unsafe.Pointer(c), 1) << 8) |
*c) *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) // #define RTMPPacket_IsReady(a)
// rtmp.h +142 // rtmp.h +142
func C_RTMPPacket_IsReady(p *C.RTMPPacket) int { 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 { if nSize > 8 {
// TODO: port this // TODO: port this
hptr = incBytePtr(hptr, int(C.EncodeInt32LE((*C.char)(hptr), hptr = incBytePtr(hptr, int(C_EncodeInt32LE((*byte)(hptr),
C.int(packet.m_nInfoField2)))) int32(packet.m_nInfoField2))))
//hptr = incBytePtr(hptr, int(C.EncodeInt32LE((*C.char)(hptr),
//C.int(packet.m_nInfoField2))))
} }
if t >= 0xffffff { if t >= 0xffffff {