Ported sendbytesrecieved

This commit is contained in:
saxon 2018-07-28 16:36:01 +09:30
parent 7d9d4639b9
commit 43c3f7032c
1 changed files with 24 additions and 1 deletions

View File

@ -845,8 +845,8 @@ func readN(r *C.RTMP, buffer *byte, n int) int {
r.m_nBytesIn += C.int(nRead)
if r.m_bSendCounter != 0 && r.m_nBytesIn > (r.m_nBytesInSent+
r.m_nClientBW/10) {
// TODO: port this
if C.SendBytesReceived(r) == 0 {
//if sendBytesReceived(r) == 0 {
return 0
}
}
@ -890,6 +890,29 @@ func rtmpSockBufFill(sb *C.RTMPSockBuf) int {
return nBytes
}
func sendBytesReceived(r *C.RTMP) int {
var packet C.RTMPPacket
var pbuf [256]byte
pend := (*byte)(incBytePtr(unsafe.Pointer(&pbuf[0]), 256))
packet.m_nChannel = 0x02 /* control channel (invoke) */
packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM
packet.m_packetType = RTMP_PACKET_TYPE_BYTES_READ_REPORT
packet.m_nTimeStamp = 0
packet.m_nInfoField2 = 0
packet.m_hasAbsTimestamp = 0
packet.m_body = (*C.char)(incBytePtr(unsafe.Pointer(&pbuf[0]),
RTMP_MAX_HEADER_SIZE))
packet.m_nBodySize = 4
C.AMF_EncodeInt32(packet.m_body, (*C.char)(unsafe.Pointer(pend)), r.m_nBytesIn)
r.m_nBytesInSent = r.m_nBytesIn
return int(C.RTMP_SendPacket(r, &packet, 0))
}
func sendConnectPacket(r *C.RTMP, cp *C.RTMPPacket) int {
var packet C.RTMPPacket
var pbuf [4096]byte