codec/h265: fixed lexer to get nal header into start of fragment

Now getting the nal header and type from fu header for the first fragment. We can now
lex and create HEVC MTS to RTP - working fine. Need to use RTCP now to continue stream.
This commit is contained in:
Saxon 2019-05-19 17:21:41 +09:30
parent 92d4c5f79a
commit a2d1b09e92
1 changed files with 8 additions and 1 deletions

View File

@ -76,6 +76,7 @@ func (l *Lexer) Lex(dst io.Writer, src io.Reader, delay time.Duration) error {
switch err {
case nil: // Do nothing.
case io.EOF:
fmt.Println("done")
return nil
default:
return fmt.Errorf("source read error: %v\n", err)
@ -150,6 +151,11 @@ func (l *Lexer) handleFragmentation(d []byte) {
start := d[2]&0x80 != 0
end := d[2]&0x40 != 0
var head []byte
if start {
head = []byte{(d[0] & 0x81) | ((d[2] & 0x3f) << 1), d[1]}
}
d = d[3:]
if l.donl {
d = d[2:]
@ -158,7 +164,8 @@ func (l *Lexer) handleFragmentation(d []byte) {
switch {
case start && !end:
l.frag = true
l.writeWithPrefix(d)
_d := append(head, d...)
l.writeWithPrefix(_d)
case !start && end:
l.frag = false
fallthrough