diff --git a/rtmp/chunk_wrap.go b/rtmp/chunk_wrap.go index f801ca7..6516bd4 100644 --- a/rtmp/chunk_wrap.go +++ b/rtmp/chunk_wrap.go @@ -4,7 +4,6 @@ import ( "net" "encoding/binary" "stream_server/rtmp/amf" - "fmt" ) type ChunkWrapper struct { @@ -99,3 +98,28 @@ func (chnk_wrp_ptr *ChunkWrapper) WriteWindowAckSize() (error) { } return nil } + +func (chnk_wrp_ptr *ChunkWrapper) WritePeerBandwidth() (error) { + msg_ptr := new(Message) + msg_ptr.msg_type = 6 + msg_ptr.data = make([]byte, 5) + msg_ptr.msg_len = 5 + binary.BigEndian.PutUint32(msg_ptr.data, 5000000) + msg_ptr.data[4] = 2 + if err := chnk_wrp_ptr.WriteChunk(2, 0, msg_ptr); err != nil { + return err + } + return nil +} + +func (chnk_wrp_ptr *ChunkWrapper) WriteChunkSize() (error) { + msg_ptr := new(Message) + msg_ptr.msg_type = 1 + msg_ptr.data = make([]byte, 4) + msg_ptr.msg_len = 4 + binary.BigEndian.PutUint32(msg_ptr.data, chnk_wrp_ptr.params.chunk_size) + if err := chnk_wrp_ptr.WriteChunk(2, 0, msg_ptr); err != nil { + return err + } + return nil +} diff --git a/rtmp/connect.go b/rtmp/connect.go index 452f178..f4da7f9 100644 --- a/rtmp/connect.go +++ b/rtmp/connect.go @@ -14,6 +14,12 @@ func NegotiateConnect(chnk_wrp_ptr *ChunkWrapper) (bool) { if err := chnk_wrp_ptr.WriteWindowAckSize(); err != nil { return false } + if err := chnk_wrp_ptr.WritePeerBandwidth(); err != nil { + return false + } + if err := chnk_wrp_ptr.WriteChunkSize(); err != nil { + return false + } fmt.Println(chnk_wrp_ptr.params) return false }