mirror of
https://github.com/jech/galene.git
synced 2024-11-22 08:35:57 +01:00
Run gofmt.
This commit is contained in:
parent
325f288189
commit
4fde2c40e6
7 changed files with 38 additions and 39 deletions
|
@ -15,7 +15,7 @@ func TestEstimator(t *testing.T) {
|
||||||
e.Accumulate(128)
|
e.Accumulate(128)
|
||||||
e.estimate(now + rtptime.JiffiesPerSec)
|
e.estimate(now + rtptime.JiffiesPerSec)
|
||||||
rate, packetRate :=
|
rate, packetRate :=
|
||||||
e.estimate(now + (rtptime.JiffiesPerSec * 1001) / 1000)
|
e.estimate(now + (rtptime.JiffiesPerSec*1001)/1000)
|
||||||
|
|
||||||
if rate != 42+128 {
|
if rate != 42+128 {
|
||||||
t.Errorf("Expected %v, got %v", 42+128, rate)
|
t.Errorf("Expected %v, got %v", 42+128, rate)
|
||||||
|
|
|
@ -69,7 +69,7 @@ func TestJSON(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkPlain(b *testing.B) {
|
func BenchmarkPlain(b *testing.B) {
|
||||||
for i :=0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
match, err := pw2.Match("bad")
|
match, err := pw2.Match("bad")
|
||||||
if err != nil || match {
|
if err != nil || match {
|
||||||
b.Errorf("pw2 matched")
|
b.Errorf("pw2 matched")
|
||||||
|
@ -78,7 +78,7 @@ func BenchmarkPlain(b *testing.B) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkPBKDF2(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")
|
match, err := pw3.Match("bad")
|
||||||
if err != nil || match {
|
if err != nil || match {
|
||||||
b.Errorf("pw3 matched")
|
b.Errorf("pw3 matched")
|
||||||
|
|
|
@ -350,7 +350,7 @@ func TestBitmapPacket(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
p := rtcp.NackPair{first, rtcp.PacketBitmap(bitmap)}
|
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 s < 42 || s >= 42+64 {
|
||||||
if (value & (1 << (s - 42))) != 0 {
|
if (value & (1 << (s - 42))) != 0 {
|
||||||
t.Errorf("Bit %v unexpectedly set", s-42)
|
t.Errorf("Bit %v unexpectedly set", s-42)
|
||||||
|
|
|
@ -574,7 +574,7 @@ func gotNACK(conn *rtpDownConnection, track *rtpDownTrack, p *rtcp.TransportLaye
|
||||||
var packet rtp.Packet
|
var packet rtp.Packet
|
||||||
buf := make([]byte, packetcache.BufSize)
|
buf := make([]byte, packetcache.BufSize)
|
||||||
for _, nack := range p.Nacks {
|
for _, nack := range p.Nacks {
|
||||||
nack.Range(func (seqno uint16) bool {
|
nack.Range(func(seqno uint16) bool {
|
||||||
l := track.remote.GetRTP(seqno, buf)
|
l := track.remote.GetRTP(seqno, buf)
|
||||||
if l == 0 {
|
if l == 0 {
|
||||||
unhandled = append(unhandled, seqno)
|
unhandled = append(unhandled, seqno)
|
||||||
|
|
|
@ -29,11 +29,11 @@ func errorToWSCloseMessage(id string, err error) (*clientMessage, []byte) {
|
||||||
code = websocket.CloseProtocolError
|
code = websocket.CloseProtocolError
|
||||||
s := e.Error()
|
s := e.Error()
|
||||||
m = &clientMessage{
|
m = &clientMessage{
|
||||||
Type: "usermessage",
|
Type: "usermessage",
|
||||||
Kind: "error",
|
Kind: "error",
|
||||||
Dest: id,
|
Dest: id,
|
||||||
Privileged: true,
|
Privileged: true,
|
||||||
Value: &s,
|
Value: &s,
|
||||||
}
|
}
|
||||||
text = e.Error()
|
text = e.Error()
|
||||||
case group.UserError, group.KickError:
|
case group.UserError, group.KickError:
|
||||||
|
@ -708,7 +708,7 @@ func StartClient(conn *websocket.Conn) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type pushConnAction struct {
|
type pushConnAction struct {
|
||||||
group *group.Group
|
group *group.Group
|
||||||
id string
|
id string
|
||||||
conn conn.Up
|
conn conn.Up
|
||||||
tracks []conn.UpTrack
|
tracks []conn.UpTrack
|
||||||
|
@ -720,7 +720,7 @@ type addLabelAction struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type pushConnsAction struct {
|
type pushConnsAction struct {
|
||||||
group *group.Group
|
group *group.Group
|
||||||
client group.Client
|
client group.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -943,7 +943,6 @@ func leaveGroup(c *webClient) {
|
||||||
c.group = nil
|
c.group = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func failDownConnection(c *webClient, id string, message string) error {
|
func failDownConnection(c *webClient, id string, message string) error {
|
||||||
if id != "" {
|
if id != "" {
|
||||||
err := c.write(clientMessage{
|
err := c.write(clientMessage{
|
||||||
|
@ -1178,14 +1177,14 @@ func handleClientMessage(c *webClient, m clientMessage) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mm := clientMessage{
|
mm := clientMessage{
|
||||||
Type: m.Type,
|
Type: m.Type,
|
||||||
Id: m.Id,
|
Id: m.Id,
|
||||||
Dest: m.Dest,
|
Dest: m.Dest,
|
||||||
Username: m.Username,
|
Username: m.Username,
|
||||||
Privileged: c.permissions.Op,
|
Privileged: c.permissions.Op,
|
||||||
Time: tm,
|
Time: tm,
|
||||||
Kind: m.Kind,
|
Kind: m.Kind,
|
||||||
Value: m.Value,
|
Value: m.Value,
|
||||||
}
|
}
|
||||||
if m.Dest == "" {
|
if m.Dest == "" {
|
||||||
clients := g.GetClients(nil)
|
clients := g.GetClients(nil)
|
||||||
|
@ -1428,11 +1427,11 @@ func errorMessage(id string, err error) *clientMessage {
|
||||||
case group.UserError:
|
case group.UserError:
|
||||||
message := e.Error()
|
message := e.Error()
|
||||||
return &clientMessage{
|
return &clientMessage{
|
||||||
Type: "usermessage",
|
Type: "usermessage",
|
||||||
Kind: "error",
|
Kind: "error",
|
||||||
Dest: id,
|
Dest: id,
|
||||||
Privileged: true,
|
Privileged: true,
|
||||||
Value: &message,
|
Value: &message,
|
||||||
}
|
}
|
||||||
case group.KickError:
|
case group.KickError:
|
||||||
message := e.Message
|
message := e.Message
|
||||||
|
@ -1440,13 +1439,13 @@ func errorMessage(id string, err error) *clientMessage {
|
||||||
message = "you have been kicked out"
|
message = "you have been kicked out"
|
||||||
}
|
}
|
||||||
return &clientMessage{
|
return &clientMessage{
|
||||||
Type: "usermessage",
|
Type: "usermessage",
|
||||||
Kind: "error",
|
Kind: "error",
|
||||||
Id: e.Id,
|
Id: e.Id,
|
||||||
Username: e.Username,
|
Username: e.Username,
|
||||||
Dest: id,
|
Dest: id,
|
||||||
Privileged: true,
|
Privileged: true,
|
||||||
Value: &message,
|
Value: &message,
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -39,7 +39,7 @@ func NTPToTime(ntp uint64) time.Time {
|
||||||
sec := uint32(ntp >> 32)
|
sec := uint32(ntp >> 32)
|
||||||
frac := uint32(ntp & 0xFFFFFFFF)
|
frac := uint32(ntp & 0xFFFFFFFF)
|
||||||
return ntpEpoch.Add(
|
return ntpEpoch.Add(
|
||||||
time.Duration(sec) * time.Second +
|
time.Duration(sec)*time.Second +
|
||||||
((time.Duration(frac) * time.Second) >> 32),
|
((time.Duration(frac) * time.Second) >> 32),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -48,5 +48,5 @@ func TimeToNTP(tm time.Time) uint64 {
|
||||||
d := tm.Sub(ntpEpoch)
|
d := tm.Sub(ntpEpoch)
|
||||||
sec := uint32(d / time.Second)
|
sec := uint32(d / time.Second)
|
||||||
frac := 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)
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,15 +21,15 @@ func differs(a, b, delta uint64) bool {
|
||||||
if a < b {
|
if a < b {
|
||||||
a, b = b, a
|
a, b = b, a
|
||||||
}
|
}
|
||||||
return a - b >= delta
|
return a-b >= delta
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTime(t *testing.T) {
|
func TestTime(t *testing.T) {
|
||||||
a := Now(48000)
|
a := Now(48000)
|
||||||
time.Sleep(4 * time.Millisecond)
|
time.Sleep(4 * time.Millisecond)
|
||||||
b := Now(48000) - a
|
b := Now(48000) - a
|
||||||
if differs(b, 4 * 48, 16) {
|
if differs(b, 4*48, 16) {
|
||||||
t.Errorf("Expected %v, got %v", 4 * 48, b)
|
t.Errorf("Expected %v, got %v", 4*48, b)
|
||||||
}
|
}
|
||||||
|
|
||||||
c := Microseconds()
|
c := Microseconds()
|
||||||
|
@ -68,7 +68,7 @@ func TestNTP(t *testing.T) {
|
||||||
}
|
}
|
||||||
if diff2 > (1 << 8) {
|
if diff2 > (1 << 8) {
|
||||||
t.Errorf("Expected %v, got %v (diff=%v)",
|
t.Errorf("Expected %v, got %v (diff=%v)",
|
||||||
ntp, ntp2, float64(diff2) / float64(1<<32))
|
ntp, ntp2, float64(diff2)/float64(1<<32))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue