Using my sockBufFill - tested and working

This commit is contained in:
saxon 2018-07-28 16:28:24 +09:30
parent 670e79f8f0
commit 7d9d4639b9
1 changed files with 27 additions and 1 deletions

View File

@ -821,7 +821,8 @@ func readN(r *C.RTMP, buffer *byte, n int) int {
avail = int(r.m_sb.sb_size) avail = int(r.m_sb.sb_size)
if avail == 0 { if avail == 0 {
if C.RTMPSockBuf_Fill(&r.m_sb) < 1 { if rtmpSockBufFill(&r.m_sb) < 1 {
// if C.RTMPSockBuf_Fill(&r.m_sb) < 1 {
if r.m_sb.sb_timedout == 0 { if r.m_sb.sb_timedout == 0 {
return 0 return 0
} }
@ -864,6 +865,31 @@ func readN(r *C.RTMP, buffer *byte, n int) int {
return nOriginalSize - n return nOriginalSize - n
} }
func rtmpSockBufFill(sb *C.RTMPSockBuf) int {
var nBytes int
if sb.sb_size == 0 {
sb.sb_start = &sb.sb_buf[0]
}
for {
nBytes = int(unsafe.Sizeof(sb.sb_buf)) - 1 - int(sb.sb_size) -
int(uintptr(unsafe.Pointer(sb.sb_start))-uintptr(unsafe.Pointer(
&sb.sb_buf[0])))
nBytes = int(C.recv(sb.sb_socket, unsafe.Pointer(uintptr(unsafe.Pointer(
sb.sb_start))+uintptr(int(sb.sb_size))), C.size_t(nBytes), 0))
if nBytes != -1 {
sb.sb_size += C.int(nBytes)
} else {
log.Println("rtmpSockBufFill: recv error!")
}
break
}
return nBytes
}
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