mirror of https://github.com/gwuhaolin/livego.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
683 B
44 lines
683 B
package flv |
|
|
|
import ( |
|
"fmt" |
|
"github.com/gwuhaolin/livego/av" |
|
) |
|
|
|
var ( |
|
ErrAvcEndSEQ = fmt.Errorf("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 |
|
}
|
|
|