diff --git a/estimator/estimator_test.go b/estimator/estimator_test.go index 0e1dea1..7376612 100644 --- a/estimator/estimator_test.go +++ b/estimator/estimator_test.go @@ -15,7 +15,7 @@ func TestEstimator(t *testing.T) { e.Accumulate(128) e.estimate(now + rtptime.JiffiesPerSec) rate, packetRate := - e.estimate(now + (rtptime.JiffiesPerSec * 1001) / 1000) + e.estimate(now + (rtptime.JiffiesPerSec*1001)/1000) if rate != 42+128 { t.Errorf("Expected %v, got %v", 42+128, rate) diff --git a/group/client_test.go b/group/client_test.go index b5fd343..9352fc6 100644 --- a/group/client_test.go +++ b/group/client_test.go @@ -69,7 +69,7 @@ func TestJSON(t *testing.T) { } func BenchmarkPlain(b *testing.B) { - for i :=0; i < b.N; i++ { + for i := 0; i < b.N; i++ { match, err := pw2.Match("bad") if err != nil || match { b.Errorf("pw2 matched") @@ -78,7 +78,7 @@ func BenchmarkPlain(b *testing.B) { } func BenchmarkPBKDF2(b *testing.B) { - for i :=0; i < b.N; i++ { + for i := 0; i < b.N; i++ { match, err := pw3.Match("bad") if err != nil || match { b.Errorf("pw3 matched") diff --git a/packetcache/packetcache_test.go b/packetcache/packetcache_test.go index 9fc4c50..dcd8ef7 100644 --- a/packetcache/packetcache_test.go +++ b/packetcache/packetcache_test.go @@ -350,7 +350,7 @@ func TestBitmapPacket(t *testing.T) { } p := rtcp.NackPair{first, rtcp.PacketBitmap(bitmap)} - p.Range(func (s uint16) bool { + p.Range(func(s uint16) bool { if s < 42 || s >= 42+64 { if (value & (1 << (s - 42))) != 0 { t.Errorf("Bit %v unexpectedly set", s-42) diff --git a/rtpconn/rtpconn.go b/rtpconn/rtpconn.go index cda0368..f48e428 100644 --- a/rtpconn/rtpconn.go +++ b/rtpconn/rtpconn.go @@ -574,7 +574,7 @@ func gotNACK(conn *rtpDownConnection, track *rtpDownTrack, p *rtcp.TransportLaye var packet rtp.Packet buf := make([]byte, packetcache.BufSize) for _, nack := range p.Nacks { - nack.Range(func (seqno uint16) bool { + nack.Range(func(seqno uint16) bool { l := track.remote.GetRTP(seqno, buf) if l == 0 { unhandled = append(unhandled, seqno) diff --git a/rtpconn/webclient.go b/rtpconn/webclient.go index 1959b71..66dd260 100644 --- a/rtpconn/webclient.go +++ b/rtpconn/webclient.go @@ -29,11 +29,11 @@ func errorToWSCloseMessage(id string, err error) (*clientMessage, []byte) { code = websocket.CloseProtocolError s := e.Error() m = &clientMessage{ - Type: "usermessage", - Kind: "error", - Dest: id, - Privileged: true, - Value: &s, + Type: "usermessage", + Kind: "error", + Dest: id, + Privileged: true, + Value: &s, } text = e.Error() case group.UserError, group.KickError: @@ -708,7 +708,7 @@ func StartClient(conn *websocket.Conn) (err error) { } type pushConnAction struct { - group *group.Group + group *group.Group id string conn conn.Up tracks []conn.UpTrack @@ -720,7 +720,7 @@ type addLabelAction struct { } type pushConnsAction struct { - group *group.Group + group *group.Group client group.Client } @@ -943,7 +943,6 @@ func leaveGroup(c *webClient) { c.group = nil } - func failDownConnection(c *webClient, id string, message string) error { if id != "" { err := c.write(clientMessage{ @@ -1178,14 +1177,14 @@ func handleClientMessage(c *webClient, m clientMessage) error { } } mm := clientMessage{ - Type: m.Type, - Id: m.Id, - Dest: m.Dest, - Username: m.Username, - Privileged: c.permissions.Op, - Time: tm, - Kind: m.Kind, - Value: m.Value, + Type: m.Type, + Id: m.Id, + Dest: m.Dest, + Username: m.Username, + Privileged: c.permissions.Op, + Time: tm, + Kind: m.Kind, + Value: m.Value, } if m.Dest == "" { clients := g.GetClients(nil) @@ -1428,11 +1427,11 @@ func errorMessage(id string, err error) *clientMessage { case group.UserError: message := e.Error() return &clientMessage{ - Type: "usermessage", - Kind: "error", - Dest: id, - Privileged: true, - Value: &message, + Type: "usermessage", + Kind: "error", + Dest: id, + Privileged: true, + Value: &message, } case group.KickError: message := e.Message @@ -1440,13 +1439,13 @@ func errorMessage(id string, err error) *clientMessage { message = "you have been kicked out" } return &clientMessage{ - Type: "usermessage", - Kind: "error", - Id: e.Id, - Username: e.Username, - Dest: id, - Privileged: true, - Value: &message, + Type: "usermessage", + Kind: "error", + Id: e.Id, + Username: e.Username, + Dest: id, + Privileged: true, + Value: &message, } default: return nil diff --git a/rtptime/rtptime.go b/rtptime/rtptime.go index 0892d46..0ae9c28 100644 --- a/rtptime/rtptime.go +++ b/rtptime/rtptime.go @@ -39,7 +39,7 @@ func NTPToTime(ntp uint64) time.Time { sec := uint32(ntp >> 32) frac := uint32(ntp & 0xFFFFFFFF) return ntpEpoch.Add( - time.Duration(sec) * time.Second + + time.Duration(sec)*time.Second + ((time.Duration(frac) * time.Second) >> 32), ) } @@ -48,5 +48,5 @@ func TimeToNTP(tm time.Time) uint64 { d := tm.Sub(ntpEpoch) sec := uint32(d / time.Second) frac := uint32(d % time.Second) - return (uint64(sec) << 32) + (uint64(frac) << 32) / uint64(time.Second) + return (uint64(sec) << 32) + (uint64(frac)<<32)/uint64(time.Second) } diff --git a/rtptime/rtptime_test.go b/rtptime/rtptime_test.go index 40cd552..e179acf 100644 --- a/rtptime/rtptime_test.go +++ b/rtptime/rtptime_test.go @@ -21,15 +21,15 @@ func differs(a, b, delta uint64) bool { if a < b { a, b = b, a } - return a - b >= delta + return a-b >= delta } func TestTime(t *testing.T) { a := Now(48000) time.Sleep(4 * time.Millisecond) b := Now(48000) - a - if differs(b, 4 * 48, 16) { - t.Errorf("Expected %v, got %v", 4 * 48, b) + if differs(b, 4*48, 16) { + t.Errorf("Expected %v, got %v", 4*48, b) } c := Microseconds() @@ -68,7 +68,7 @@ func TestNTP(t *testing.T) { } if diff2 > (1 << 8) { t.Errorf("Expected %v, got %v (diff=%v)", - ntp, ntp2, float64(diff2) / float64(1<<32)) + ntp, ntp2, float64(diff2)/float64(1<<32)) } }