Add connect command read code, import amf package
This commit is contained in:
parent
ac5834a12e
commit
7782f14eb5
1 changed files with 15 additions and 1 deletions
|
@ -3,6 +3,7 @@ package rtmp
|
|||
import (
|
||||
"net"
|
||||
"encoding/binary"
|
||||
"stream_server/rtmp/amf"
|
||||
)
|
||||
|
||||
type ChunkWrapper struct {
|
||||
|
@ -17,7 +18,7 @@ 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 = &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{
|
||||
|
@ -55,3 +56,16 @@ func (chnk_wrp_ptr *ChunkWrapper) ReadPeerChunkSize() (error) {
|
|||
chnk_wrp_ptr.params.peer_chunk_size = binary.BigEndian.Uint32(set_chunk_size_msg.data)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (chnk_wrp_ptr *ChunkWrapper) ReadConnectCommand() (error) {
|
||||
connect_cmd_msg, err := chnk_wrp_ptr.ReadChunk()
|
||||
if err != nil || connect_cmd_msg.msg_type != 20 {
|
||||
return err
|
||||
}
|
||||
amf_obj, err := amf.DecodeAMF(&(connect_cmd_msg.data))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
chnk_wrp_ptr.params.stream_key = amf_obj[2].(amf.AMFObj)["tcUrl"].(string)
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue