Going to start using go structs instead of C

This commit is contained in:
saxon 2018-07-28 14:27:30 +09:30
parent 5a6c6837ea
commit 6a6f704840
1 changed files with 41 additions and 3 deletions

View File

@ -754,7 +754,7 @@ func handShake(r *C.RTMP, FP9HandShake int32) int {
} }
// TODO: port this // TODO: port this
if C.ReadN(r, (*C.char)(unsafe.Pointer(&typ)), 1) != 1 { if readN(r, (*C.char)(unsafe.Pointer(&typ)), 1) != 1 {
return 0 return 0
} }
@ -796,6 +796,44 @@ func handShake(r *C.RTMP, FP9HandShake int32) int {
return 1 return 1
} }
// TODO: complete this
/*
func readN(r *C.RTMP, buffer *byte, n int) int {
nOriginalSize := n
var avail int
var ptr *byte
r.m_sb.sb_timedout = 0
ptr = buffer
for n > 0 {
nBytes := 0
var nRead int
if r.Link.protocol & RTMP_FEATURE_HTTP {
refill := 0
for r.m_resplen == 0 {
var ret int
if r.m_sb.sb_size < 13 || refill {
if r.m_unackd == 0 {
C.HTTP_Post(r, RTMPT_IDLE, "", 1)
}
if C.RTMPSockBuf_Fill(&r.m_sb) < 1){
if r.m_sb.sb_timedout == 0 {
return 0
}
}
}
}
}
}
}
*/
func sendConnectPacket(r *C.RTMP, cp *C.RTMPPacket) int { func sendConnectPacket(r *C.RTMP, cp *C.RTMPPacket) int {
var packet C.RTMPPacket var packet C.RTMPPacket
var pbuf [4096]byte var pbuf [4096]byte
@ -1104,7 +1142,7 @@ func sendPacket(r *C.RTMP, packet *C.RTMPPacket, queue int) int {
int(unsafe.Sizeof(packet)*uintptr(n))) int(unsafe.Sizeof(packet)*uintptr(n)))
if uintptr(packets) == uintptr(0) { if uintptr(packets) == uintptr(0) {
C.free(unsafe.Pointer(r.m_vecChannelsOut)) //C.free(unsafe.Pointer(r.m_vecChannelsOut))
r.m_vecChannelsOut = nil r.m_vecChannelsOut = nil
r.m_channelsAllocatedOut = 0 r.m_channelsAllocatedOut = 0
return 0 return 0
@ -1305,7 +1343,7 @@ func sendPacket(r *C.RTMP, packet *C.RTMPPacket, queue int) int {
if tbuf != nil { if tbuf != nil {
wrote := int(writeN(r, tbuf, int(uintptr(decBytePtr(toff, wrote := int(writeN(r, tbuf, int(uintptr(decBytePtr(toff,
int(uintptr(unsafe.Pointer(tbuf)))))))) int(uintptr(unsafe.Pointer(tbuf))))))))
C.free(tbuf) //C.free(tbuf)
tbuf = nil tbuf = nil
if wrote == 0 { if wrote == 0 {