mirror of
https://github.com/gwuhaolin/livego.git
synced 2021-06-01 09:10:22 +03:00
46 lines
687 B
Go
Executable File
46 lines
687 B
Go
Executable File
package flv
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/gwuhaolin/livego/av"
|
|
)
|
|
|
|
var (
|
|
ErrAvcEndSEQ = errors.New("avc end sequence")
|
|
)
|
|
|
|
type Demuxer struct {
|
|
}
|
|
|
|
func NewDemuxer() *Demuxer {
|
|
return &Demuxer{}
|
|
}
|
|
|
|
func (d *Demuxer) DemuxH(p *av.Packet) error {
|
|
var tag Tag
|
|
_, err := tag.ParseMeidaTagHeader(p.Data, p.IsVideo)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
p.Header = &tag
|
|
|
|
return nil
|
|
}
|
|
|
|
func (d *Demuxer) Demux(p *av.Packet) error {
|
|
var tag Tag
|
|
n, err := tag.ParseMeidaTagHeader(p.Data, p.IsVideo)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if tag.CodecID() == av.VIDEO_H264 &&
|
|
p.Data[0] == 0x17 && p.Data[1] == 0x02 {
|
|
return ErrAvcEndSEQ
|
|
}
|
|
p.Header = &tag
|
|
p.Data = p.Data[n:]
|
|
|
|
return nil
|
|
}
|