mirror of https://bitbucket.org/ausocean/av.git
parser: expose H264 documentation
This commit is contained in:
parent
ca5eefa4c3
commit
0b0f12431b
|
@ -37,9 +37,9 @@ const (
|
|||
outputBufferSize = 10000
|
||||
)
|
||||
|
||||
// h264Parser provides properties and methods to allow for the parsing of a
|
||||
// H264 provides properties and methods to allow for the parsing of a
|
||||
// h264 stream - i.e. to allow extraction of the individual access units
|
||||
type h264Parser struct {
|
||||
type H264 struct {
|
||||
inputBuffer []byte
|
||||
isParsing bool
|
||||
parserOutputChanRef chan []byte
|
||||
|
@ -48,9 +48,9 @@ type h264Parser struct {
|
|||
delay uint
|
||||
}
|
||||
|
||||
// NewH264Parser returns an instance of the h264Parser struct
|
||||
func NewH264Parser() (p *h264Parser) {
|
||||
p = new(h264Parser)
|
||||
// NewH264Parser returns an instance of the H264 struct
|
||||
func NewH264Parser() (p *H264) {
|
||||
p = new(H264)
|
||||
p.isParsing = true
|
||||
p.inputChan = make(chan byte, inputChanSize)
|
||||
p.delay = 0
|
||||
|
@ -60,12 +60,12 @@ func NewH264Parser() (p *h264Parser) {
|
|||
// Stop simply sets the isParsing flag to false to indicate to the parser that
|
||||
// we don't want to interpret incoming data anymore - this will also make the
|
||||
// parser jump out of the parse func
|
||||
func (p *h264Parser) Stop() {
|
||||
func (p *H264) Stop() {
|
||||
p.isParsing = false
|
||||
}
|
||||
|
||||
// Start starts the parse func as a goroutine so that incoming data is interpreted
|
||||
func (p *h264Parser) Start() {
|
||||
func (p *H264) Start() {
|
||||
p.isParsing = true
|
||||
go p.parse()
|
||||
}
|
||||
|
@ -73,31 +73,31 @@ func (p *h264Parser) Start() {
|
|||
// SetDelay sets a delay inbetween each buffer output. Useful if we're parsing
|
||||
// a file but want to replicate the speed of incoming video frames from a
|
||||
// camera
|
||||
func (p *h264Parser) SetDelay(delay uint) {
|
||||
func (p *H264) SetDelay(delay uint) {
|
||||
p.delay = delay
|
||||
}
|
||||
|
||||
// InputChan returns a handle to the input channel of the parser
|
||||
func (p *h264Parser) InputChan() chan byte {
|
||||
func (p *H264) InputChan() chan byte {
|
||||
return p.inputChan
|
||||
}
|
||||
|
||||
// OutputChan returns a handle to the output chan of the parser
|
||||
func (p *h264Parser) OutputChan() <-chan []byte {
|
||||
func (p *H264) OutputChan() <-chan []byte {
|
||||
return p.userOutputChanRef
|
||||
}
|
||||
|
||||
// SetOutputChan sets the parser output chan to the passed output chan. This is
|
||||
// useful if we want the parser output to go directly to a generator of some sort
|
||||
// for packetization.
|
||||
func (p *h264Parser) SetOutputChan(o chan []byte) {
|
||||
func (p *H264) SetOutputChan(o chan []byte) {
|
||||
p.parserOutputChanRef = o
|
||||
p.userOutputChanRef = o
|
||||
}
|
||||
|
||||
// parse interprets an incoming h264 stream and extracts individual frames
|
||||
// aka access units
|
||||
func (p *h264Parser) parse() {
|
||||
func (p *H264) parse() {
|
||||
outputBuffer := make([]byte, 0, outputBufferSize)
|
||||
searchingForEnd := false
|
||||
for p.isParsing {
|
||||
|
|
Loading…
Reference in New Issue