diff --git a/rtmp/chunk.go b/rtmp/chunk.go index 5aa483a..98fb87a 100644 --- a/rtmp/chunk.go +++ b/rtmp/chunk.go @@ -265,7 +265,18 @@ func ReadChunk(conn net.Conn, open_chnkstrms map[uint32]*ChunkStream, open_msgs } case 3: chnkstream_ptr = open_chnkstrms[csid] - msg_ptr = open_msgs[chnkstream_ptr.last_msg_strm_id] + msg_prev, ok := open_msgs[chnkstream_ptr.last_msg_strm_id] + if !ok { + msg_ptr = new(Message) + msg_ptr.msg_type = chnkstream_ptr.last_msg_type + msg_ptr.msg_len = chnkstream_ptr.last_msg_len + msg_ptr.data = make([]byte, msg_ptr.msg_len) + + chnkstream_ptr.timestamp += chnkstream_ptr.timedelta + msg_ptr.timestamp = chnkstream_ptr.timestamp + } else { + msg_ptr = msg_prev + } } n, err := read_chunk_data(conn, msg_ptr, chnk_size)