From c7ea01e3bd02d81ccff47bd54f9ac99841bd2809 Mon Sep 17 00:00:00 2001 From: Muaz Ahmad Date: Thu, 10 Aug 2023 20:58:01 +0500 Subject: [PATCH] Force read peer chunk size message from client --- rtmp/chunk_wrap.go | 10 ++++++++++ rtmp/connect.go | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/rtmp/chunk_wrap.go b/rtmp/chunk_wrap.go index 3d1e688..550c8ac 100644 --- a/rtmp/chunk_wrap.go +++ b/rtmp/chunk_wrap.go @@ -2,6 +2,7 @@ package rtmp import ( "net" + "encoding/binary" ) type ChunkWrapper struct { @@ -45,3 +46,12 @@ func (chnk_wrp_ptr *ChunkWrapper) ReadChunk() (*Message, error) { } return full_msg_ptr, nil } + +func (chnk_wrp_ptr *ChunkWrapper) ReadPeerChunkSize() (error) { + set_chunk_size_msg, err := chnk_wrp_ptr.ReadChunk() + if err != nil || set_chunk_size_msg.msg_type != 1 || set_chunk_size_msg.msg_len != 4 { + return err + } + chnk_wrp_ptr.params.peer_chunk_size = binary.BigEndian.Uint32(set_chunk_size_msg.data) + return nil +} diff --git a/rtmp/connect.go b/rtmp/connect.go index b39d09b..5f91aee 100644 --- a/rtmp/connect.go +++ b/rtmp/connect.go @@ -5,6 +5,11 @@ import ( ) func NegotiateConnect(chnk_wrp_ptr *ChunkWrapper) (bool) { + fmt.Println(chnk_wrp_ptr.params.peer_chunk_size) + if err := chnk_wrp_ptr.ReadPeerChunkSize(); err != nil { + return false + } + fmt.Println(chnk_wrp_ptr.params.peer_chunk_size) for { full_msg_ptr, err := chnk_wrp_ptr.ReadChunk() if err != nil {