From b846dbf2d7f7f1b689b143eec05cb2c9fb822e51 Mon Sep 17 00:00:00 2001 From: saxon Date: Sun, 26 Aug 2018 00:27:38 +0930 Subject: [PATCH] rtmp: continued to port C_SendFCUnpublish - paused - need to work out best way to get rid of unsafe pointers --- rtmp/rtmp.go | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/rtmp/rtmp.go b/rtmp/rtmp.go index 62cfae1d..f4c280ca 100644 --- a/rtmp/rtmp.go +++ b/rtmp/rtmp.go @@ -1086,7 +1086,31 @@ func C_SendFCUnpublish(r *C_RTMP) int32 { /* var packet C_RTMPPacket var pbuf [1024]byte - var pend []byte = + var pend []byte = pbuf[1024:] + var enc []byte + + packet.m_nChannel = 0x03 + packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM + packet.m_packetType = RTMP_PACKET_TYPE_INVOKE + packet.m_nTimeStamp = 0 + packet.m_nInfoField2 = 0 + packet.m_hasAbsTimestamp = 0 + packet.m_body = pbuf + RTMP_MAX_HEADER_SIZE + + // NOTE use of unsafe pointer will be remove here when packet.m_nBody becomes []byte + enc = []byte(unsafe.Pointer(packet.m_nBody)) + enc = C_AMF_EncodeString((*byte)(unsafe.Pointer(&enc[0])), + (*byte)(unsafe.Pointer(&pend[0])), &av_FCUnpublish) + r.m_numInvokes++ + enc = C_AMF_EncodeNumber(enc, pend, r->m_numInvokes); + *enc++ = AMF_NULL; + enc = AMF_EncodeString(enc, pend, &r->Link.playpath); + if (!enc) + return FALSE; + + packet.m_nBodySize = enc - packet.m_body; + + return RTMP_SendPacket(r, &packet, FALSE); */ return 0 }