mirror of https://bitbucket.org/ausocean/av.git
protocol/rtcp/client.go: not using defer for simple setters/getters
This commit is contained in:
parent
881ddc3d38
commit
d34eabcd34
|
@ -244,8 +244,9 @@ func (c *client) UpdateSequence(s uint32) {
|
||||||
// highestSequence will return the highest sequence number received through RTP.
|
// highestSequence will return the highest sequence number received through RTP.
|
||||||
func (c *client) highestSequence() uint32 {
|
func (c *client) highestSequence() uint32 {
|
||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
defer c.mu.Unlock()
|
s := c.sequence
|
||||||
return c.sequence
|
c.mu.Unlock()
|
||||||
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
// jitter returns the interarrival jitter as described by RTCP specifications:
|
// jitter returns the interarrival jitter as described by RTCP specifications:
|
||||||
|
@ -257,30 +258,31 @@ func (c *client) jitter() uint32 {
|
||||||
// setSenderTs allows us to safely set the current sender report timestamp.
|
// setSenderTs allows us to safely set the current sender report timestamp.
|
||||||
func (c *client) setSenderTs(msw, lsw uint32) {
|
func (c *client) setSenderTs(msw, lsw uint32) {
|
||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
defer c.mu.Unlock()
|
|
||||||
binary.BigEndian.PutUint32(c.senderTs[:], msw)
|
binary.BigEndian.PutUint32(c.senderTs[:], msw)
|
||||||
binary.BigEndian.PutUint32(c.senderTs[4:], lsw)
|
binary.BigEndian.PutUint32(c.senderTs[4:], lsw)
|
||||||
|
c.mu.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
// lastSenderTs returns the timestamp of the most recent sender report.
|
// lastSenderTs returns the timestamp of the most recent sender report.
|
||||||
func (c *client) lastSenderTs() uint32 {
|
func (c *client) lastSenderTs() uint32 {
|
||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
defer c.mu.Unlock()
|
t := binary.BigEndian.Uint32(c.senderTs[2:])
|
||||||
return binary.BigEndian.Uint32(c.senderTs[2:])
|
c.mu.Unlock()
|
||||||
|
return t
|
||||||
}
|
}
|
||||||
|
|
||||||
// delay returns the duration between the receive time of the last sender report
|
// delay returns the duration between the receive time of the last sender report
|
||||||
// and now. This is called when forming a receiver report.
|
// and now. This is called when forming a receiver report.
|
||||||
func (c *client) delay() uint32 {
|
func (c *client) delay() uint32 {
|
||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
defer c.mu.Unlock()
|
t := c.receiveTime
|
||||||
now := time.Now()
|
c.mu.Unlock()
|
||||||
return uint32(now.Sub(c.receiveTime).Seconds() / delayUnit)
|
return uint32(time.Now().Sub(t).Seconds() / delayUnit)
|
||||||
}
|
}
|
||||||
|
|
||||||
// received is called when a sender report is received to mark the receive time.
|
// received is called when a sender report is received to mark the receive time.
|
||||||
func (c *client) received() {
|
func (c *client) received() {
|
||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
defer c.mu.Unlock()
|
|
||||||
c.receiveTime = time.Now()
|
c.receiveTime = time.Now()
|
||||||
|
c.mu.Unlock()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue