From 4978db2f2bc7bcfeced4f243dd9c8513801e5d90 Mon Sep 17 00:00:00 2001 From: Saxon Date: Tue, 9 Apr 2019 15:44:18 +0930 Subject: [PATCH] revid: fixed silly rtp bug --- protocol/rtp/rtp.go | 4 ++-- revid/senders.go | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/protocol/rtp/rtp.go b/protocol/rtp/rtp.go index 8b18d4ca..33a3e7f8 100644 --- a/protocol/rtp/rtp.go +++ b/protocol/rtp/rtp.go @@ -74,10 +74,10 @@ func (p *Pkt) Bytes(buf []byte) []byte { if p.X { headerExtensionLen = int(4 + 4*len(p.Extension.Header)) } - requiredPktLen := defaultHeadSize + uint8(4*p.CC) + uint8(headerExtensionLen) + uint8(len(p.Payload)) + uint8(len(p.Padding)) + requiredPktLen := defaultHeadSize + int(4*p.CC) + headerExtensionLen + len(p.Payload) + len(p.Padding) // Create new space if no buffer is given, or it doesn't have sufficient capacity. - if buf == nil || requiredPktLen > uint8(cap(buf)) { + if buf == nil || requiredPktLen > cap(buf) { buf = make([]byte, requiredPktLen, defPktSize) } buf = buf[:requiredPktLen] diff --git a/revid/senders.go b/revid/senders.go index b8e73a21..a678b5b1 100644 --- a/revid/senders.go +++ b/revid/senders.go @@ -282,5 +282,11 @@ func newRtpSender(addr string, log func(lvl int8, msg string, args ...interface{ // Write implements io.Writer. func (s *rtpSender) Write(d []byte) (int, error) { - return s.encoder.Write(s.data) + s.data = make([]byte, len(d)) + copy(s.data, d) + _, err := s.encoder.Write(s.data) + if err != nil { + s.log(logger.Warning, pkg+"rtpSender: write error", err.Error()) + } + return len(d), nil }