codec/h265/lexer.go & protocol/rtp/client.go: fixed lexer and rtp client.

The lexer had a bug which is now fixed, and the RTP client is no longer looking for SSRC
in rtp.NewClient (which means we miss a packet).
This commit is contained in:
Saxon 2019-05-20 20:49:50 +09:30
parent 3ff726e439
commit 970a445ca4
2 changed files with 8 additions and 16 deletions

View File

@ -151,14 +151,15 @@ func (l *Lexer) handleFragmentation(d []byte) {
start := d[2]&0x80 != 0
end := d[2]&0x40 != 0
old := d
b1 := (d[0] & 0x81) | ((d[2] & 0x3f) << 1)
b2 := d[1]
if start {
d = d[1:]
if l.donl {
d = d[2:]
}
d[0] = (old[0] & 0x81) | ((old[2] & 0x3f) << 1)
d[1] = old[1]
d[0] = b1
d[1] = b2
} else {
d = d[3:]
if l.donl {

View File

@ -28,7 +28,6 @@ LICENSE
package rtp
import (
"fmt"
"net"
"sync"
)
@ -59,17 +58,6 @@ func NewClient(addr string) (*Client, error) {
if err != nil {
return nil, err
}
buf := make([]byte, 4096)
n, err := c.Read(buf)
if err != nil {
return nil, err
}
c.ssrc, err = SSRC(buf[:n])
if err != nil {
return nil, fmt.Errorf("could not parse SSRC from RTP packet, failed with error: %v", err)
}
return c, nil
}
@ -85,9 +73,12 @@ func (c *Client) Read(p []byte) (int, error) {
if err != nil {
return n, err
}
if c.ssrc == 0 {
c.ssrc, _ = SSRC(p[:n])
}
s, _ := Sequence(p[:n])
c.setSequence(s)
return c.r.Read(p)
return n, err
}
// setSequence sets the most recently received sequence number, and updates the