From 510f431b9054f2771bcb2170820ede0e92e78842 Mon Sep 17 00:00:00 2001 From: saxon Date: Tue, 17 Jul 2018 18:23:31 +0930 Subject: [PATCH] Building and running, but not working - looks like video input into youtube is not enough, going to use nethogs --- rtmp/rtmp.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/rtmp/rtmp.go b/rtmp/rtmp.go index b820dd3f..ca790514 100644 --- a/rtmp/rtmp.go +++ b/rtmp/rtmp.go @@ -268,12 +268,13 @@ func sendPacket(r *C.RTMP, packet *C.RTMPPacket, queue int) int { var hbuf = unsafe.Pointer(&goHbuf[0]) var c byte var t int32 + var packets unsafe.Pointer if packet.m_nChannel >= r.m_channelsAllocatedOut { + log.Println("Resize") n := int(packet.m_nChannel+10) - var tmp *C.RTMPPacket - packets := C.realloc(unsafe.Pointer(r.m_vecChannelsOut), - C.size_t(unsafe.Sizeof(tmp) * uintptr(n))) + packets = C.realloc(unsafe.Pointer(r.m_vecChannelsOut), + C.size_t(unsafe.Sizeof(packet) * uintptr(n))) if uintptr(packets) == uintptr(0) { C.free(unsafe.Pointer(r.m_vecChannelsOut)) @@ -283,7 +284,7 @@ func sendPacket(r *C.RTMP, packet *C.RTMPPacket, queue int) int { } r.m_vecChannelsOut = (**C.RTMPPacket)(packets) C.memset(incPtr(unsafe.Pointer(r.m_vecChannelsOut), int(r.m_channelsAllocatedOut), - int(unsafe.Sizeof(tmp))), 0, C.size_t(unsafe.Sizeof(tmp) * + int(unsafe.Sizeof(packet))), 0, C.size_t(unsafe.Sizeof(packet) * uintptr(n-int(r.m_channelsAllocatedOut)))) r.m_channelsAllocatedOut = C.int(n) } @@ -291,7 +292,6 @@ func sendPacket(r *C.RTMP, packet *C.RTMPPacket, queue int) int { int(packet.m_nChannel), int(unsafe.Sizeof(packet)))) - if prevPacket != nil && packet.m_headerType != RTMP_PACKET_SIZE_LARGE { // compress a bit by using the prev packet's attributes if prevPacket.m_nBodySize == packet.m_nBodySize && @@ -523,15 +523,14 @@ func sendPacket(r *C.RTMP, packet *C.RTMPPacket, queue int) int { *(**C.RTMPPacket)(incPtr(unsafe.Pointer(r.m_vecChannelsOut), int(packet.m_nChannel), int(unsafe.Sizeof(packet)))) = - (*C.RTMPPacket)(C.malloc(C.size_t(unsafe.Sizeof(*packet)))) + (*C.RTMPPacket)(C.malloc(C.size_t(unsafe.Sizeof(*packet)))) } //memmove(incPtr(unsafe.Pointer(r.m_vecChannelsOut),int(packet.m_nChannel), //int(unsafe.Sizeof(packet))),unsafe.Pointer(packet), unsafe.Sizeof(packet)) - dest := ptrToSlice(incPtr(unsafe.Pointer(r.m_vecChannelsOut),int(packet.m_nChannel), - int(unsafe.Sizeof(packet))),int(unsafe.Sizeof(*packet))) - src := ptrToSlice(unsafe.Pointer(packet),int(unsafe.Sizeof(*packet))) - copy(dest,src) + C.memcpy(unsafe.Pointer(*(**C.RTMPPacket)(incPtr(unsafe.Pointer(r.m_vecChannelsOut), + int(packet.m_nChannel), int(unsafe.Sizeof(packet))))), unsafe.Pointer(packet), + C.size_t(uintptr(unsafe.Sizeof(*packet)))) return 1 }