Commits

Liam Staskawicz committed c79e436

rtcpInterval: return interval directly as a time.Duration

  • Participants
  • Parent commits 876c1ef

Comments (0)

Files changed (1)

File rtp/interval.go

 // long running service to handle periodic transmission events
 func (s *Session) transmissionIntervalService() {
 
-	interval := s.rtcpInterval()
-	ticker := time.NewTicker(time.Duration(interval))
+	ticker := time.NewTicker(s.rtcpInterval())
 
 	for {
 		select {
 	}
 }
 
-// calculate the interval, in nanoseconds, at which we should be sending RTCP packets
-func (s *Session) rtcpInterval() int64 {
-	// as implemented in Appendix A.7
+// calculate the interval, at which we should be sending RTCP packets
+func (s *Session) rtcpInterval() time.Duration {
+	// time is calculated in seconds, as implemented in Appendix A.7
 
 	// XXX: locking around state access
 	rtcpBw := s.rtcpBw
 	// random number uniformly distributed between 0.5*t and 1.5*t.
 	interval *= rand.Float64() + 0.5
 	interval /= rtcpIntervalCompensation
-	return int64(interval * 1e9) // convert to nanoseconds
+
+	// Duration accepts the interval in nanoseconds
+	return time.Duration(interval * 1e9)
 }