package rtmp import ( "net" ) type ChunkWrapper struct { conn net.Conn params *ProtocolParams open_chnkstrms map[uint32]*ChunkStream open_msgs map[uint32]*Message chunk_buffs *ChunkBuffers } 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.open_chnkstrms = make(map[uint32]*ChunkStream) chnk_wrp_ptr.open_msgs = make(map[uint32]*Message) buffers := ChunkBuffers{ make([]byte, 4), make([]byte, 4), make([]byte, 1), make([]byte, 4), make([]byte, 1), make([]byte, 2), } chnk_wrp_ptr.chunk_buffs = &buffers return } func (chnk_wrp_ptr *ChunkWrapper) ReadChunk() (*Message, error) { full_msg_ptr, err := ReadChunk( chnk_wrp_ptr.conn, chnk_wrp_ptr.open_chnkstrms, chnk_wrp_ptr.open_msgs, chnk_wrp_ptr.params.peer_chunk_size, chnk_wrp_ptr.chunk_buffs, &(chnk_wrp_ptr.params.curr_read), ) if err != nil { return nil, err } return full_msg_ptr, nil }