func (r *SrsClient) fmle_publishing(s *source.Sourcer) (err error) { // refer check // TODO: FIXME: implements it. // notify the hls to prepare when publish start. // TODO: FIXME: implements it. hasAudioMeta := false hasVideoMeta := false isPass := false n := 1 for { // read from client. var msg *rtmp.Message if msg, err = r.rtmp.Protocol().RecvMessage(); err != nil { return } // process UnPublish event. if msg.Header.IsAmf0Command() || msg.Header.IsAmf3Command() { var pkt interface{} if pkt, err = r.rtmp.Protocol().DecodeMessage(msg); err != nil { return } if _, ok := pkt.(*rtmp.FMLEStartPacket); ok { glog.Info("FMLE publish finished.") return } continue } if msg.Header.Timestamp == 0 && msg.Header.IsAmf0Data() { glog.Info("set meta data") if err = s.SetMeta(msg); err != nil { return } glog.Info("set meta data done.") // TODO remove : // for test. // go f(s) // go f1(s) continue } if !isPass { if n > 2 { isPass = true } else if msg.Header.IsAudio() && !hasAudioMeta { glog.Info("get audio meta data.") hasAudioMeta = true s.SetAudioMeta(msg) continue } else if msg.Header.IsVideo() && !hasVideoMeta { glog.Info("get audio meta data.") hasVideoMeta = true s.SetVideoMeta(msg) continue } else { // pass, not match. } if hasAudioMeta && hasVideoMeta { isPass = true } n++ } else { // ok. norlmal play. s.Run() } if err = r.process_publish_message(s, msg); err != nil { return } } return }
func (r *SrsClient) process_publish_message(s *source.Sourcer, msg *rtmp.Message) (err error) { // glog.Info("handle msg") s.HandleMsg(msg) // glog.Info("handle msg done") return }
func (r *SrsClient) process_publish_message(s *source.Sourcer, msg *rtmp.Message) (err error) { s.HandleMsg(msg) return }