Ported AV_erase - tested and working

This commit is contained in:
saxon 2018-08-15 03:34:18 +09:30
parent 27006d8fd3
commit 6cfabc671f
1 changed files with 25 additions and 3 deletions

View File

@ -1942,7 +1942,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 AMFProp_GetNumber (amf.c +330)
// TODO port AV_erase (rtmp.c +2393)
// TODO port SendReleaseStream (rtmp.c +1816)
// TODO port SendFCPublish (rtmp.c +1846)
@ -1993,7 +1992,8 @@ func C_HandleInvoke(r *C.RTMP, body *byte, nBodySize uint32) int32 {
log.Println("1.1")
methodInvoked = (*(*C.RTMP_METHOD)(incPtr(unsafe.Pointer(r.m_methodCalls),
int(i), int(unsafe.Sizeof(*r.m_methodCalls))))).name
C.AV_erase(r.m_methodCalls, &r.m_numCalls, C.int(i), 0)
//C.AV_erase(r.m_methodCalls, &r.m_numCalls, C.int(i), 0)
C_AV_erase(r.m_methodCalls, (*int32)(&r.m_numCalls), int32(i), 0)
break
}
}
@ -2185,7 +2185,8 @@ func C_HandleInvoke(r *C.RTMP, body *byte, nBodySize uint32) int32 {
if C_AVMATCH(&(*(*C.RTMP_METHOD)(incPtr(unsafe.Pointer(r.m_methodCalls), int(i),
int(unsafe.Sizeof(*r.m_methodCalls))))).name, &av_publish) != 0 {
log.Println("16.1")
C.AV_erase(r.m_methodCalls, &r.m_numCalls, C.int(i), 1)
//C.AV_erase(r.m_methodCalls, &r.m_numCalls, C.int(i), 1)
C_AV_erase(r.m_methodCalls, (*int32)(&r.m_numCalls), int32(i), 1)
break
}
}
@ -2297,6 +2298,27 @@ func C_AMFProp_GetNumber(prop *C.AMFObjectProperty) float64 {
return float64(prop.p_vu.p_number)
}
// void AV_erase(C.RTMP_METHOD* vals, int* num, int i, int freeit);
// rtmp.c +2393
func C_AV_erase(vals *C.RTMP_METHOD, num *int32, i, freeit int32) {
if freeit != 0 {
C.free(unsafe.Pointer((*(*C.RTMP_METHOD)(incPtr(unsafe.Pointer(vals), int(i),
int(unsafe.Sizeof(*vals))))).name.av_val))
}
(*num)--
for ; i < *num; i++ {
*(*C.RTMP_METHOD)(incPtr(unsafe.Pointer(vals), int(i),
int(unsafe.Sizeof(*vals)))) = *(*C.RTMP_METHOD)(incPtr(
unsafe.Pointer(vals), int(i+1), int(unsafe.Sizeof(*vals))))
}
(*(*C.RTMP_METHOD)(incPtr(unsafe.Pointer(vals), int(i),
int(unsafe.Sizeof(*vals))))).name.av_val = nil
(*(*C.RTMP_METHOD)(incPtr(unsafe.Pointer(vals), int(i),
int(unsafe.Sizeof(*vals))))).name.av_len = 0
(*(*C.RTMP_METHOD)(incPtr(unsafe.Pointer(vals), int(i),
int(unsafe.Sizeof(*vals))))).num = 0
}
// void RTMPPacket_Free(RTMPPacket* p);
// rtmp.c +203
func C_RTMPPacket_Free(p *C.RTMPPacket) {