mirror of https://bitbucket.org/ausocean/av.git
protocol/rtcp: addressing of PR feedback
This commit is contained in:
parent
f54dd13959
commit
51478ee064
|
@ -45,6 +45,7 @@ const (
|
|||
defaultClientName = "client"
|
||||
delayUnit = 1.0 / 65536.0
|
||||
pkg = "rtcp: "
|
||||
rtcpVer = 2
|
||||
)
|
||||
|
||||
type log func(lvl int8, msg string, args ...interface{})
|
||||
|
@ -53,6 +54,7 @@ type log func(lvl int8, msg string, args ...interface{})
|
|||
// and sending out ReceiverReports.
|
||||
type client struct {
|
||||
ErrChan chan error
|
||||
|
||||
cAddr *net.UDPAddr
|
||||
sAddr *net.UDPAddr
|
||||
name string
|
||||
|
@ -125,7 +127,7 @@ func (c *client) Stop() {
|
|||
c.wg.Wait()
|
||||
}
|
||||
|
||||
// listen reads from the UDP connection and parses SenderReports.
|
||||
// recv reads from the UDP connection and parses SenderReports.
|
||||
func (c *client) recv() {
|
||||
defer c.wg.Done()
|
||||
c.log(logger.Debug, pkg+"client is receiving")
|
||||
|
@ -159,7 +161,7 @@ func (c *client) send() {
|
|||
|
||||
report := ReceiverReport{
|
||||
Header: Header{
|
||||
Version: 2,
|
||||
Version: rtcpVer,
|
||||
Padding: false,
|
||||
ReportCount: 1,
|
||||
Type: typeReceiverReport,
|
||||
|
@ -181,7 +183,7 @@ func (c *client) send() {
|
|||
|
||||
description := SourceDescription{
|
||||
Header: Header{
|
||||
Version: 2,
|
||||
Version: rtcpVer,
|
||||
Padding: false,
|
||||
ReportCount: 1,
|
||||
Type: typeSourceDescription,
|
||||
|
|
|
@ -202,12 +202,12 @@ func TestReceiveAndSend(t *testing.T) {
|
|||
now := time.Now().Second()
|
||||
var time [8]byte
|
||||
binary.BigEndian.PutUint64(time[:], uint64(now))
|
||||
msw := binary.BigEndian.Uint32(time[:])
|
||||
msw := binary.BigEndian.Uint32(time[:4])
|
||||
lsw := binary.BigEndian.Uint32(time[4:])
|
||||
|
||||
report := SenderReport{
|
||||
Header: Header{
|
||||
Version: 2,
|
||||
Version: rtcpVer,
|
||||
Padding: false,
|
||||
ReportCount: 0,
|
||||
Type: typeSenderReport,
|
||||
|
|
|
@ -39,7 +39,7 @@ func Timestamp(buf []byte) (msw, lsw uint32, err error) {
|
|||
if len(buf) < 4 {
|
||||
return 0, 0, errors.New("bad RTCP packet, not of sufficient length")
|
||||
}
|
||||
if (buf[0] & 0xc0 >> 6) != 2 {
|
||||
if (buf[0]&0xc0)>>6 != 2 {
|
||||
return 0, 0, errors.New("incompatible RTCP version")
|
||||
}
|
||||
|
||||
|
|
|
@ -72,18 +72,13 @@ func (r *ReceiverReport) Bytes(buf []byte) []byte {
|
|||
idx := 8
|
||||
for _, b := range r.Blocks {
|
||||
binary.BigEndian.PutUint32(buf[idx:], b.SSRC)
|
||||
idx += 4
|
||||
binary.BigEndian.PutUint32(buf[idx:], b.PacketsLost)
|
||||
buf[idx] = b.FractionLost
|
||||
idx += 4
|
||||
binary.BigEndian.PutUint32(buf[idx:], b.HighestSequence)
|
||||
idx += 4
|
||||
binary.BigEndian.PutUint32(buf[idx:], b.Jitter)
|
||||
idx += 4
|
||||
binary.BigEndian.PutUint32(buf[idx:], b.LSR)
|
||||
idx += 4
|
||||
binary.BigEndian.PutUint32(buf[idx:], b.DLSR)
|
||||
idx += 4
|
||||
binary.BigEndian.PutUint32(buf[idx+4:], b.PacketsLost)
|
||||
buf[idx+4] = b.FractionLost
|
||||
binary.BigEndian.PutUint32(buf[idx+8:], b.HighestSequence)
|
||||
binary.BigEndian.PutUint32(buf[idx+12:], b.Jitter)
|
||||
binary.BigEndian.PutUint32(buf[idx+16:], b.LSR)
|
||||
binary.BigEndian.PutUint32(buf[idx+20:], b.DLSR)
|
||||
idx += 24
|
||||
}
|
||||
|
||||
for _, e := range r.Extensions {
|
||||
|
@ -132,9 +127,8 @@ func (d *SourceDescription) Bytes(buf []byte) []byte {
|
|||
idx += 4
|
||||
for _, i := range c.Items {
|
||||
buf[idx] = i.Type
|
||||
idx++
|
||||
buf[idx] = byte(len(i.Text))
|
||||
idx++
|
||||
buf[idx+1] = byte(len(i.Text))
|
||||
idx += 2
|
||||
copy(buf[idx:], i.Text)
|
||||
idx += len(i.Text)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue