diff --git a/rtmp/chunk_wrap.go b/rtmp/chunk_wrap.go index 1abdad1..bc11428 100644 --- a/rtmp/chunk_wrap.go +++ b/rtmp/chunk_wrap.go @@ -18,7 +18,9 @@ func NewChunkWrapper(conn net.Conn) (chnk_wrp_ptr *ChunkWrapper) { chnk_wrp_ptr = new(ChunkWrapper) chnk_wrp_ptr.conn = conn - chnk_wrp_ptr.params = &ProtocolParams{1024, 512, 0, 0, ""} + chnk_wrp_ptr.params = new(ProtocolParams) + chnk_wrp_ptr.params.chunk_size = 128 + chnk_wrp_ptr.params.peer_chunk_size = 128 chnk_wrp_ptr.open_chnkstrms = make(map[uint32]*ChunkStream) chnk_wrp_ptr.open_msgs = make(map[uint32]*Message) buffers := ChunkBuffers{ @@ -138,3 +140,23 @@ func (chnk_wrp_ptr *ChunkWrapper) WriteConnectResponse() (error) { } return nil } + +func (chnk_wrp_ptr *ChunkWrapper) ReadCreateStream() (error) { + create_stream_msg, err := chnk_wrp_ptr.ReadChunk() + if err != nil || create_stream_msg.msg_type != 20 { + return err + } + amf_obj, err := amf.DecodeAMF(&(create_stream_msg.data)) + if err != nil { + return err + } + err = amf_obj.ProcessCreateStream(&(chnk_wrp_ptr.params.trans_id)) + if err != nil { + return err + } + return nil +} + +func (chnk_wrp_ptr *ChunkWrapper) WriteCreateStreamResponse() (error) { + return nil +} diff --git a/rtmp/connect.go b/rtmp/connect.go index 0e89b3c..9d8fd14 100644 --- a/rtmp/connect.go +++ b/rtmp/connect.go @@ -31,7 +31,13 @@ func CreateStream(chnk_wrp_ptr *ChunkWrapper) (bool) { if _, err := chnk_wrp_ptr.ReadChunk(); err != nil { return false } - full_msg_ptr, _ := chnk_wrp_ptr.ReadChunk() - fmt.Println(full_msg_ptr) + if err := chnk_wrp_ptr.ReadCreateStream(); err != nil { + return false + } + fmt.Println("test read") + if err := chnk_wrp_ptr.WriteCreateStreamResponse(); err != nil { + return false + } + fmt.Println("test") return true }