Fixed my avQueue func - now using, tested and working

This commit is contained in:
saxon 2018-07-29 21:13:40 +09:30
parent 10667ba5f0
commit 1b1843d2b6
1 changed files with 9 additions and 8 deletions

View File

@ -1496,7 +1496,8 @@ func rtmpSendPacket(r *C.RTMP, packet *C.RTMPPacket, queue int) int {
//txn = int(C.AMF_DecodeNumber((*C.char)(ptr))) //txn = int(C.AMF_DecodeNumber((*C.char)(ptr)))
txn = int(amfDecodeNumber((*byte)(ptr))) txn = int(amfDecodeNumber((*byte)(ptr)))
// TODO: port this // TODO: port this
avQueue(&r.m_methodCalls, (*int)(unsafe.Pointer(&r.m_numCalls)), &method, txn) avQueue(&r.m_methodCalls, (*int32)(unsafe.Pointer(&r.m_numCalls)),
&method, int32(txn))
//C.AV_queue(&r.m_methodCalls, (*C.int)(unsafe.Pointer(&r.m_numCalls)), &method, //C.AV_queue(&r.m_methodCalls, (*C.int)(unsafe.Pointer(&r.m_numCalls)), &method,
//C.int(txn)) //C.int(txn))
} }
@ -1563,26 +1564,26 @@ func sockBufSend(sb *C.RTMPSockBuf, buf *byte, l int32) int32 {
} }
// TODO: port RTMP_METHOD // TODO: port RTMP_METHOD
func avQueue(vals **C.RTMP_METHOD, num *int, av *C.AVal, txn int) { func avQueue(vals **C.RTMP_METHOD, num *int32, av *C.AVal, txn int32) {
if (*num & 0x0f) == 0 { if (*num & 0x0f) == 0 {
// TODO: work out what to do with the realloc // TODO: work out what to do with the realloc
//*vals = (*C.RTMP_METHOD)(realloc(unsafe.Pointer(*vals), int((*num+16)* //*vals = (*C.RTMP_METHOD)(realloc(unsafe.Pointer(*vals), int((*num+16)*
//int(unsafe.Sizeof(*(*vals)))))) //int(unsafe.Sizeof(*(*vals))))))
*vals = (*C.RTMP_METHOD)(C.realloc(unsafe.Pointer(*vals), C.size_t((*num+16)*int( *vals = (*C.RTMP_METHOD)(C.realloc(unsafe.Pointer(*vals), C.size_t((*num+16)*
unsafe.Sizeof(*(*vals)))))) int32(unsafe.Sizeof(*(*vals))))))
} }
tmp := C.malloc(C.size_t(av.av_len + 1)) tmp := C.malloc(C.size_t(av.av_len + 1))
//tmp := allocate(uintptr(av.av_len + 1)) //tmp := allocate(uintptr(av.av_len + 1))
memmove(tmp, unsafe.Pointer(av.av_val), uintptr(av.av_len)) memmove(tmp, unsafe.Pointer(av.av_val), uintptr(av.av_len))
*indxBytePtr(tmp, int(av.av_len)) = '\000' *indxBytePtr(tmp, int(av.av_len)) = '\000'
(*(*C.RTMP_METHOD)(incPtr(unsafe.Pointer(*vals), *num, (*(*C.RTMP_METHOD)(incPtr(unsafe.Pointer(*vals), int(*num),
int(unsafe.Sizeof(*(*vals)))))).num = C.int(txn) int(unsafe.Sizeof(*(*vals)))))).num = C.int(txn)
(*(*C.RTMP_METHOD)(incPtr(unsafe.Pointer(*vals), *num, (*(*C.RTMP_METHOD)(incPtr(unsafe.Pointer(*vals), int(*num),
int(unsafe.Sizeof(*(*vals)))))).name.av_len = av.av_len int(unsafe.Sizeof(*(*vals)))))).name.av_len = av.av_len
(*(*C.RTMP_METHOD)(incPtr(unsafe.Pointer(*vals), *num, (*(*C.RTMP_METHOD)(incPtr(unsafe.Pointer(*vals), int(*num),
int(unsafe.Sizeof(*(*vals)))))).name.av_val = (*C.char)(tmp) int(unsafe.Sizeof(*(*vals)))))).name.av_val = (*C.char)(tmp)
*num++ (*num)++
} }
func amfEncodeNamedNumber(output *byte, outend *byte, strName *C.AVal, dVal float64) *byte { func amfEncodeNamedNumber(output *byte, outend *byte, strName *C.AVal, dVal float64) *byte {