From a0fa9106d61421ac4c8798afc8dea5c981cb1dfc Mon Sep 17 00:00:00 2001 From: saxon Date: Fri, 20 Jul 2018 14:10:08 +0930 Subject: [PATCH] Creating wrapper for unsafe.Pointer conversion --- rtmp/rtmp.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/rtmp/rtmp.go b/rtmp/rtmp.go index 6c0c9894..2f891493 100644 --- a/rtmp/rtmp.go +++ b/rtmp/rtmp.go @@ -428,10 +428,10 @@ func rtmpSetupUrl(r *C.RTMP, u string) int32 { r.Link.playpath = r.Link.playpath0 if r.Link.tcUrl.av_len == 0 { - r.Link.tcUrl.av_val = url + r.Link.tcUrl.av_val = (*C.char)(unsafe.Pointer(url)) if r.Link.app.av_len != 0 { if int(uintptr(unsafe.Pointer(r.Link.app.av_val))) < - int(uintptr(incBytePtr(url, len))) { + int(uintptr(incBytePtr(unsafe.Pointer(url), len))) { r.Link.tcUrl.av_len = r.Link.app.av_len + int(uintptr(decBytePtr(r.Link.app.av_val, int(uintptr(unsafe.Pointer(url)))))) @@ -478,7 +478,8 @@ func rtmpSetupUrl(r *C.RTMP, u string) int32 { func socksSetup(r *RTMP, sockshost *AVal) { if sockshost.av_len != 0 { - socksport := strchr((*byte)(sockshost.av_val), ':') + socksport := strchr((*byte)(unsafe.Pointer(sockshost.av_val)), ':') + hostname := strdup((*byte)(sockshost.av_val)) } } @@ -1057,6 +1058,16 @@ func avQueue(vals **C.RTMP_METHOD, num *int, av *C.AVal, txn int) { int(unsafe.Sizeof(rtmpMethodPtr))))).name.av_val = (*C.char)(tmp) } +// wrapper for converting byte pointer to unsafe.Pointer +func uBP(b *byte) unsafe.Pointer { + return unsafe.Pointer(b) +} + +// wrapper for converting slice to unsafe.pointer +func uBSP(b []byte) unsafe.Pointer { + return unsafe.Pointer(&b[0]) +} + func goStrToCStr(str string) *byte { l := len(str) slice := make([]byte, l+1)