Added chunk size and bandwidth write to peer

This commit is contained in:
Muaz Ahmad 2023-08-13 14:43:07 +05:00
parent 94bd146e77
commit a070e0c952
2 changed files with 31 additions and 1 deletions

View file

@ -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
}

View file

@ -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
}