From 01f3caa8eced353ac29ef9003d9e3e02daf80eb4 Mon Sep 17 00:00:00 2001 From: saxon Date: Tue, 28 Aug 2018 19:18:13 +0930 Subject: [PATCH] rtmp: created NOT_PORTED.txt to hold names of funcs not ported and also deleted sections of code not run in our case --- rtmp/NOT_PORTED.txt | 16 ++++++ rtmp/rtmp.go | 137 ++------------------------------------------ 2 files changed, 20 insertions(+), 133 deletions(-) create mode 100644 rtmp/NOT_PORTED.txt diff --git a/rtmp/NOT_PORTED.txt b/rtmp/NOT_PORTED.txt new file mode 100644 index 00000000..b1c983e3 --- /dev/null +++ b/rtmp/NOT_PORTED.txt @@ -0,0 +1,16 @@ +HandleAudio +HandleVideo +HandleMetadata +DecodeTEA +SendSecureTokenResponse +RTMP_FindFirstMatchingProperty +RTMP_SendServerBW +RTMP_SendCtrl +SendUsherToken +SendFCSubscribe +SendPlaylist +SendPlay +SendPlaylist +SendPong +SendCheckBWResult +RTMP_SendPause diff --git a/rtmp/rtmp.go b/rtmp/rtmp.go index 1d5aa03e..a1b1a221 100644 --- a/rtmp/rtmp.go +++ b/rtmp/rtmp.go @@ -600,54 +600,15 @@ func C_RTMP_ClientPacket(r *C_RTMP, packet *C_RTMPPacket) int32 { case RTMP_PACKET_TYPE_AUDIO: panic("Unsupported packet type RTMP_PACKET_TYPE_AUDIO") - /* - // TODO port this - //C.HandleAudio(r, packet) NOTE this does nothing - bHasMediaPacket = 1 - if r.m_mediaChannel == 0 { - r.m_mediaChannel = packet.m_nChannel - } - - if r.m_pausing == 0 { - r.m_mediaStamp = packet.m_nTimeStamp - } - */ case RTMP_PACKET_TYPE_VIDEO: panic("Unsupported packet type RTMP_PACKET_TYPE_VIDEO") - /* - // TODO port this - // C.HandleVideo(r, packet) NOTE this does nothing - bHasMediaPacket = 1 - if r.m_mediaChannel == 0 { - r.m_mediaChannel = packet.m_nChannel - } - if r.m_pausing == 0 { - r.m_mediaStamp = packet.m_nTimeStamp - } - */ + case RTMP_PACKET_TYPE_FLEX_MESSAGE: panic("Unsupported packet type RTMP_PACKET_TYPE_FLEX_MESSAGE") - /* - { - // TODO use new logger here - // RTMP_Log(RTMP_LOGDEBUG,"%s, flex message, size %u bytes, not fully supported", __FUNCTION__, packet.m_nBodySize); - if C.HandleInvoke(r, (*byte)(incBytePtr(unsafe.Pointer(packet.m_body), 1)), - C.uint(packet.m_nBodySize-1)) == 1 { - bHasMediaPacket = 2 - } - } - */ case RTMP_PACKET_TYPE_INFO: panic("Unsupported packet type RTMP_PACKET_TYPE_INFO") - /* - // TODO use new logger here - //RTMP_Log(RTMP_LOGDEBUG, "%s, received: notify %u bytes", __FUNCTION__,packet.m_nBodySize); - if C.HandleMetadata(r, packet.m_body, C.uint(packet.m_nBodySize)) != 0 { - bHasMediaPacket = 1 - } - */ case RTMP_PACKET_TYPE_INVOKE: log.Println("RTMP_PACKET_TYPE_INVOKE:") @@ -662,42 +623,7 @@ func C_RTMP_ClientPacket(r *C_RTMP, packet *C_RTMPPacket) int32 { case RTMP_PACKET_TYPE_FLASH_VIDEO: panic("Unsupported packet type RTMP_PACKET_TYPE_FLASH_VIDEO") - /* - { - var pos uint32 = 0 - var nTimeStamp uint32 = uint32(packet.m_nTimeStamp) - for pos+11 < uint32(packet.m_nBodySize) { - var dataSize uint32 = C_AMF_DecodeInt24((*byte)(incBytePtr(unsafe.Pointer( - packet.m_body), int(pos+1)))) - - if pos+11+dataSize+4 > uint32(packet.m_nBodySize) { - // TODO use new logger here - // RTMP_Log(RTMP_LOGWARNING, "Stream corrupt?!"); - break - } - - switch { - case *indxBytePtr(unsafe.Pointer(packet.m_body), int(pos)) == 0x12: - C.HandleMetadata(r, (*byte)(incBytePtr(unsafe.Pointer(packet.m_body), - int(pos+11))), C.uint(dataSize)) - case *indxBytePtr(unsafe.Pointer(packet.m_body), int(pos)) == 8 || - *indxBytePtr(unsafe.Pointer(packet.m_body), int(pos)) == 9: - nTimeStamp = C_AMF_DecodeInt24((*byte)(incBytePtr(unsafe.Pointer( - packet.m_body), int(pos+4)))) - nTimeStamp |= uint32(*indxBytePtr(unsafe.Pointer(packet.m_body), - int(pos+7)) << 24) - } - pos += (11 + dataSize + 4) - } - if r.m_pausing == 0 { - r.m_mediaStamp = uint32(nTimeStamp) - } - - bHasMediaPacket = 1 - - } - */ default: // TODO use new logger here // RTMP_Log(RTMP_LOGDEBUG, "%s, unknown packet type received: 0x%02x", __FUNCTION__,packet.m_packetType); @@ -1317,52 +1243,18 @@ func C_HandleInvoke(r *C_RTMP, body *byte, nBodySize uint32) int32 { case C_AVMATCH(&methodInvoked, &av_connect) != 0: if r.Link.token.av_len != 0 { panic("No support for link token") - /* - log.Println("2.1") - var p C_AMFObjectProperty - if C.RTMP_FindFirstMatchingProperty(&obj, &av_secureToken, &p) != 0 { - log.Println("2.2") - C.DecodeTEA(&r.Link.token, &p.p_vu.p_aval) - C.SendSecureTokenResponse(r, &p.p_vu.p_aval) - } - */ + } if (r.Link.protocol & RTMP_FEATURE_WRITE) != 0 { C_SendReleaseStream(r) C_SendFCPublish(r) } else { panic("Link protocol has no RTMP_FEATURE_WRITE") - /* - log.Println("2.4") - C.RTMP_SendServerBW(r) - C.RTMP_SendCtrl(r, 3, 0, 300) - */ } C_RTMP_SendCreateStream(r) if (r.Link.protocol & RTMP_FEATURE_WRITE) == 0 { panic("Link protocol has no RTMP_FEATURE_WRITE") - /* - log.Println("2.5") - // Authenticate on Justin.tv legacy servers before sending FCSubscribe - if r.Link.usherToken.av_len != 0 { - log.Println("2.6") - C.SendUsherToken(r, &r.Link.usherToken) - } - // Send the FCSubscribe if live stream or if subscribepath is set - switch { - case r.Link.subscribepath.av_len != 0: - { - log.Println("3") - C.SendFCSubscribe(r, &r.Link.subscribepath) - } - case (r.Link.lFlags & RTMP_LF_LIVE) != 0: - { - log.Println("4") - C.SendFCSubscribe(r, &r.Link.playpath) - } - } - */ } case C_AVMATCH(&methodInvoked, &av_createStream) != 0: @@ -1372,15 +1264,6 @@ func C_HandleInvoke(r *C_RTMP, body *byte, nBodySize uint32) int32 { C_SendPublish(r) } else { panic("Link protocol has no RTMP_FEATURE_WRITE") - /* - log.Println("5.2") - if (r.Link.lFlags & RTMP_LF_PLST) != 0 { - log.Println("5.3") - C.SendPlaylist(r) - } - C.SendPlay(r) - C.RTMP_SendCtrl(r, 3, C.uint(r.m_stream_id), C.uint(r.m_nBufferMS)) - */ } case C_AVMATCH(&methodInvoked, &av_play) != 0 || @@ -1399,15 +1282,10 @@ func C_HandleInvoke(r *C_RTMP, body *byte, nBodySize uint32) int32 { case C_AVMATCH(&method, &av_ping) != 0: panic("Unsupported method av_ping") - /* - C.SendPong(r, float64(txn)) - */ + case C_AVMATCH(&method, &av__onbwcheck) != 0: panic("Unsupported method av_onbwcheck") - /* - log.Println("10") - C.SendCheckBWResult(r, float64(txn)) - */ + case C_AVMATCH(&method, &av__onbwdone) != 0: panic("Unsupported method av_onbwdone") @@ -1457,13 +1335,6 @@ func C_HandleInvoke(r *C_RTMP, body *byte, nBodySize uint32) int32 { case C_AVMATCH(&code, &av_NetStream_Pause_Notify) != 0: panic("Unsupported method av_NetStream_Pause_Notify") - /* - log.Println("19") - if r.m_pausing == 1 || r.m_pausing == 2 { - C.RTMP_SendPause(r, 0, int32(r.m_pauseStamp)) - r.m_pausing = 3 - } - */ } case C_AVMATCH(&method, &av_playlist_ready) != 0: