From 4f1b6ff56f742047403b5068af71f413ee3dca21 Mon Sep 17 00:00:00 2001 From: saxon Date: Sun, 12 Aug 2018 19:47:53 +0930 Subject: [PATCH] Ported handleclientbw, handleserverbw and handle changechunksize --- rtmp/rtmp.go | 44 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/rtmp/rtmp.go b/rtmp/rtmp.go index d9c5cb1a..05eeb410 100644 --- a/rtmp/rtmp.go +++ b/rtmp/rtmp.go @@ -1742,7 +1742,8 @@ func C_RTMP_ClientPacket(r *C.RTMP, packet *C.RTMPPacket) int32 { case RTMP_PACKET_TYPE_CHUNK_SIZE: log.Println("RTMP_PACKET_TYPE_CHUNK_SIZE") // TODO: port this - C.HandleChangeChunkSize(r, packet) + //C.HandleChangeChunkSize(r, packet) + C_HandleChangeChunkSize(r, packet) /* case RTMP_PACKET_TYPE_BYTES_READ_REPORT: log.Println("RTMP_PACKET_TYPE_BYTES_READ_REPORT") @@ -1757,12 +1758,14 @@ func C_RTMP_ClientPacket(r *C.RTMP, packet *C.RTMPPacket) int32 { case RTMP_PACKET_TYPE_SERVER_BW: log.Println("RTMP_PACKET_TYPE_SERVER_BW") // TODO: port this - C.HandleServerBW(r, packet) + //C.HandleServerBW(r, packet) + C_HandlServerBW(r, packet) case RTMP_PACKET_TYPE_CLIENT_BW: log.Println("RTMP_PACKET_TYPE_CLIENT_BW") // TODO: port this - C.HandleClientBW(r, packet) + //C.HandleClientBW(r, packet) + C_HandlClientBW(r, packet) /* case RTMP_PACKET_TYPE_AUDIO: log.Println("RTMP_PACKET_TYPE_AUDIO") @@ -1863,6 +1866,41 @@ func C_RTMP_ClientPacket(r *C.RTMP, packet *C.RTMPPacket) int32 { return bHasMediaPacket } +// void HandleChangeChunkSize(RTMP* r, const RTMPPacket* packet); +// rtmp.c +3345 +func C_HandleChangeChunkSize(r *C.RTMP, packet *C.RTMPPacket) { + if packet.m_nBodySize >= 4 { + // TODO port C.AMF_DeocdeInt32 + r.m_inChunkSize = C.AMF_DecodeInt32(packet.m_body) + // TODO use new logger here + // RTMP_Log(RTMP_LOGDEBUG, "%s, received: chunk size change to %d", __FUNCTION__, r->m_inChunkSize); + } +} + +// void HandleServerBW(RTMP* r, const RTMPPacket* packet); +// rtmp.c +3508 +func C_HandlServerBW(r *C.RTMP, packet *C.RTMPPacket) { + // TODO port AMF_DecodeInt32 + r.m_nServerBW = C.AMF_DecodeInt32(packet.m_body) + // TODO use new logger here + // RTMP_Log(RTMP_LOGDEBUG, "%s: server BW = %d", __FUNCTION__, r->m_nServerBW); +} + +// void HandleClientBW(RTMP* r, const RTMPPacket* packet); +// rtmp.c +3515 +func C_HandleClientBW(r *C.RTMP, packet *C.RTMPPacket) { + r.m_nClientBW = C.AMF_DeocdeInt32(packet.m_body) + + if packet.m_nBodySize > 4 { + r.m_nClientBW2 = packet.m_body[4] + } else { + r.m_nClientBW2 = -1 + } + // TODO use new logger here + // RTMP_Log(RTMP_LOGDEBUG, "%s: client BW = %d %d", __FUNCTION__, r->m_nClientBW, + //r->m_nClientBW2); +} + // void RTMPPacket_Free(RTMPPacket* p); // rtmp.c +203 func C_RTMPPacket_Free(p *C.RTMPPacket) {