From 97cae6ff203913c4cbf0e2051e71dab8a541e810 Mon Sep 17 00:00:00 2001 From: saxon Date: Wed, 18 Jul 2018 11:41:44 +0930 Subject: [PATCH] Ported AV_queue - tested and working --- rtmp/rtmp.go | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/rtmp/rtmp.go b/rtmp/rtmp.go index 81b2bc3a..c2b0adb2 100644 --- a/rtmp/rtmp.go +++ b/rtmp/rtmp.go @@ -581,22 +581,23 @@ func writeN(r *C.RTMP, buffer unsafe.Pointer, n int) int { } -/* // TODO: port RTMP_METHOD -func avQueue(vals **C.RTMP_METHOD, num *int, av *AVal, txn int ) { - var tmp unsafe.Pointer - +func avQueue(vals **C.RTMP_METHOD, num *int, av *C.AVal, txn int ) { + var rtmpMethodPtr *C.RTMP_METHOD if (*num & 0x0f) == 0 { // TODO: work out what to do with the realloc - *vals = C.realloc(*vals, (*num+16) * C.int(int(unsafe.sizeof(RTMP_METHOD)))) + *vals = (*C.RTMP_METHOD)(C.realloc(unsafe.Pointer(*vals), C.size_t((*num+16) * int(unsafe.Sizeof(*(*vals)))))) } - - tmp := C.malloc(av.av_len + 1 ) - memmove(tmp, unsafe.Pointer(av.av_val), int(av.av_len)) - indxPtr(tmp,av.av_len) = byte(nullChar) + tmp := unsafe.Pointer(C.malloc(C.size_t(av.av_len + 1))) + C.memcpy(tmp, unsafe.Pointer(av.av_val), C.size_t(av.av_len)) + *indxBytePtr(tmp,int(av.av_len)) = *(*byte)(unsafe.Pointer(C.CString(""))) + (*(*C.RTMP_METHOD)(incPtr(unsafe.Pointer(*vals),*num, + int(unsafe.Sizeof(rtmpMethodPtr))))).num = C.int(txn) + (*(*C.RTMP_METHOD)(incPtr(unsafe.Pointer(*vals),*num, + int(unsafe.Sizeof(rtmpMethodPtr))))).name.av_len = av.av_len + (*(*C.RTMP_METHOD)(incPtr(unsafe.Pointer(*vals),*num, + int(unsafe.Sizeof(rtmpMethodPtr))))).name.av_val = (*C.char)(tmp) } -*/ - // indxBytePtr returns a byte at the indx inc give a ptr