mirror of https://bitbucket.org/ausocean/av.git
Ported SendCheckBW - tested and working
This commit is contained in:
parent
6e7dbcda60
commit
11bc432b54
35
rtmp/rtmp.go
35
rtmp/rtmp.go
|
@ -1945,8 +1945,6 @@ func C_HandleClientBW(r *C.RTMP, packet *C.RTMPPacket) {
|
|||
|
||||
// int HandleInvoke(RTMP* r, const char* body, unsigned int nBodySize);
|
||||
// rtmp.c +2912
|
||||
// TODO port SendPublish (rtmp.c +1908)
|
||||
// TODO port SendCheckBW (rtmp.c +2105)
|
||||
// TODO port AMF_Reset (amf.c +1282)
|
||||
func C_HandleInvoke(r *C.RTMP, body *byte, nBodySize uint32) int32 {
|
||||
var obj C.AMFObject
|
||||
|
@ -2094,7 +2092,7 @@ func C_HandleInvoke(r *C.RTMP, body *byte, nBodySize uint32) int32 {
|
|||
log.Println("7")
|
||||
if r.m_nBWCheckCounter == 0 {
|
||||
log.Println("7.1")
|
||||
C.SendCheckBW(r)
|
||||
C_SendCheckBW(r)
|
||||
}
|
||||
}
|
||||
/*NOTE This code doesn't run in our use case
|
||||
|
@ -2378,6 +2376,37 @@ func C_SendPublish(r *C.RTMP) int32 {
|
|||
return int32(C_RTMP_SendPacket(r, &packet, 1))
|
||||
}
|
||||
|
||||
// int SendCheckBW(RTMP* r);
|
||||
// rtmp.c +2105
|
||||
func C_SendCheckBW(r *C.RTMP) int32 {
|
||||
var packet C.RTMPPacket
|
||||
var pbuf [256]byte
|
||||
var pend *byte = (*byte)(unsafe.Pointer(uintptr(unsafe.Pointer(&pbuf[0])) +
|
||||
unsafe.Sizeof(pbuf)))
|
||||
var enc *byte
|
||||
|
||||
packet.m_nChannel = 0x03 /* control channel (invoke) */
|
||||
packet.m_headerType = RTMP_PACKET_SIZE_LARGE
|
||||
packet.m_packetType = RTMP_PACKET_TYPE_INVOKE
|
||||
packet.m_nTimeStamp = 0
|
||||
packet.m_nInfoField2 = 0
|
||||
packet.m_hasAbsTimestamp = 0
|
||||
packet.m_body = (*C.char)(incBytePtr(unsafe.Pointer(&pbuf[0]),
|
||||
int(RTMP_MAX_HEADER_SIZE)))
|
||||
|
||||
enc = (*byte)(unsafe.Pointer(packet.m_body))
|
||||
enc = C_AMF_EncodeString(enc, pend, &av__checkbw)
|
||||
r.m_numInvokes++
|
||||
enc = C_AMF_EncodeNumber(enc, pend, float64(r.m_numInvokes))
|
||||
*enc = AMF_NULL
|
||||
enc = (*byte)(incBytePtr(unsafe.Pointer(enc), 1))
|
||||
|
||||
packet.m_nBodySize = C.uint32_t(uintptr(unsafe.Pointer(enc)) - uintptr(
|
||||
unsafe.Pointer(packet.m_body)))
|
||||
|
||||
return int32(C_RTMP_SendPacket(r, &packet, 0))
|
||||
}
|
||||
|
||||
// #define AVMATCH(a1,a2)
|
||||
// amf.h +63
|
||||
func C_AVMATCH(a1, a2 *C.AVal) int32 {
|
||||
|
|
Loading…
Reference in New Issue