Exemple #1
0
func main() {
	target_addr := flag.String("target", default_target, "The partner to exchange latency measurement packets with")
	local_addr := protocols.ParseServerFlags("0.0.0.0", 6060)

	server, err := NewServer(local_addr)
	golib.Checkerr(err)
	client, err := NewClientFor(*target_addr)
	golib.Checkerr(err)

	measureLatency := golib.NewLoopTask("sending latency packets", func(stop golib.StopChan) {
		err := client.SendMeasureLatency()
		if err != nil {
			log.Println("Error sending Latency packet:", err)
		}
		select {
		case <-time.After(1 * time.Second):
		case <-stop:
		}
	})

	log.Println("Listening to Latency on " + local_addr + ", sending to: " + *target_addr)
	log.Println("Press Ctrl-C to close")
	golib.NewTaskGroup(
		server, measureLatency,
		&golib.NoopTask{golib.ExternalInterrupt(), "external interrupt"},
	).WaitAndExit()
}
Exemple #2
0
func printStatistics() {
	agg := make(stats.AggregatedStats, 0, 10)
	for _, stats := range statistics {
		agg.Aggregate(stats)
	}
	if running_average {
		agg.Start()
	}
	tasks.AddNamed("stats",
		golib.NewLoopTask("printing statistics", func(stop golib.StopChan) {
			agg.Flush(3)
			fmt.Printf("==============\n%s", agg.String())
			select {
			case <-time.After(time.Second):
			case <-stop:
			}
		}))
}
Exemple #3
0
func (session *streamSession) Tasks() []golib.Task {
	errors1 := session.rtpProxy.WriteErrors()
	errors2 := session.rtcpProxy.WriteErrors()
	return []golib.Task{
		session.rtpProxy,
		session.rtcpProxy,
		session.backend,
		golib.NewLoopTask("printing proxy errors", func(stop golib.StopChan) {
			select {
			case err := <-errors1:
				session.proxy.LogError(fmt.Errorf("RTP %v write error: %v", session.rtpProxy, err))
			case err := <-errors2:
				session.proxy.LogError(fmt.Errorf("RTCP %v write error: %v", session.rtcpProxy, err))
			case <-stop:
			}
		}),
	}
}