Example #1
0
func (v *RtmpPlayAgent) Write(m core.Message) (err error) {
	var ok bool
	var om *protocol.OryxRtmpMessage
	if om, ok = m.(*protocol.OryxRtmpMessage); !ok {
		return
	}

	// load the jitter algorithm.
	// TODO: FIXME: implements it.
	ag := Full

	// correct message timestamp.
	om.SetTimestamp(v.jitter.Correct(om.Timestamp(), ag))

	// cache message.
	if err = v.conn.CacheMessage(om.Payload()); err != nil {
		return
	}

	return
}
Example #2
0
func (v *DupAgent) Write(m core.Message) (err error) {
	var ok bool
	var om *protocol.OryxRtmpMessage
	if om, ok = m.(*protocol.OryxRtmpMessage); !ok {
		return
	}

	// update the timestamp for agent.
	v.lastTimestamp = om.Timestamp()

	// cache the sequence header.
	if om.Metadata {
		v.msh = om.Copy()
		core.Trace.Println("cache metadta sh.")
	} else if om.VideoSequenceHeader {
		v.vsh = om.Copy()
		core.Trace.Println("cache video sh.")
	} else if om.AudioSequenceHeader {
		v.ash = om.Copy()
		core.Trace.Println("cache audio sh.")
	}

	// copy to all agents.
	for _, a := range v.sources {
		if err = a.Write(om.Copy()); err != nil {
			return
		}
	}

	// for single core, manually sched to send more.
	if core.Conf.Workers == 1 {
		runtime.Gosched()
	}

	return
}