32 lines
620 B
Go
32 lines
620 B
Go
package rtmp
|
|
|
|
import (
|
|
"stream_server/rtmp/flv"
|
|
)
|
|
|
|
func HandleDataLoop(chnk_wrp_ptr *ChunkWrapper) {
|
|
file_writer, err := flv.NewFLVWriter(chnk_wrp_ptr.params.stream_key)
|
|
defer file_writer.Close()
|
|
if err != nil {
|
|
return
|
|
}
|
|
if err = chnk_wrp_ptr.ReadMetadata(file_writer); err != nil {
|
|
return
|
|
}
|
|
for {
|
|
msg_ptr, err := chnk_wrp_ptr.ReadChunk()
|
|
if err != nil {
|
|
return
|
|
} else if msg_ptr == nil {
|
|
continue
|
|
}
|
|
switch msg_ptr.msg_type {
|
|
case 20:
|
|
return
|
|
case 8, 9:
|
|
if err = file_writer.WriteMediaTag(&(msg_ptr.data), msg_ptr.timestamp, msg_ptr.msg_type); err != nil {
|
|
return
|
|
}
|
|
}
|
|
}
|
|
}
|