parser: expose H264 documentation

This commit is contained in:
Dan Kortschak 2018-06-17 21:29:20 +09:30
parent ca5eefa4c3
commit 0b0f12431b
1 changed files with 12 additions and 12 deletions

View File

@ -37,9 +37,9 @@ const (
outputBufferSize = 10000 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 // h264 stream - i.e. to allow extraction of the individual access units
type h264Parser struct { type H264 struct {
inputBuffer []byte inputBuffer []byte
isParsing bool isParsing bool
parserOutputChanRef chan []byte parserOutputChanRef chan []byte
@ -48,9 +48,9 @@ type h264Parser struct {
delay uint delay uint
} }
// NewH264Parser returns an instance of the h264Parser struct // NewH264Parser returns an instance of the H264 struct
func NewH264Parser() (p *h264Parser) { func NewH264Parser() (p *H264) {
p = new(h264Parser) p = new(H264)
p.isParsing = true p.isParsing = true
p.inputChan = make(chan byte, inputChanSize) p.inputChan = make(chan byte, inputChanSize)
p.delay = 0 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 // 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 // we don't want to interpret incoming data anymore - this will also make the
// parser jump out of the parse func // parser jump out of the parse func
func (p *h264Parser) Stop() { func (p *H264) Stop() {
p.isParsing = false p.isParsing = false
} }
// Start starts the parse func as a goroutine so that incoming data is interpreted // 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 p.isParsing = true
go p.parse() go p.parse()
} }
@ -73,31 +73,31 @@ func (p *h264Parser) Start() {
// SetDelay sets a delay inbetween each buffer output. Useful if we're parsing // 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 // a file but want to replicate the speed of incoming video frames from a
// camera // camera
func (p *h264Parser) SetDelay(delay uint) { func (p *H264) SetDelay(delay uint) {
p.delay = delay p.delay = delay
} }
// InputChan returns a handle to the input channel of the parser // 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 return p.inputChan
} }
// OutputChan returns a handle to the output chan of the parser // 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 return p.userOutputChanRef
} }
// SetOutputChan sets the parser output chan to the passed output chan. This is // 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 // useful if we want the parser output to go directly to a generator of some sort
// for packetization. // for packetization.
func (p *h264Parser) SetOutputChan(o chan []byte) { func (p *H264) SetOutputChan(o chan []byte) {
p.parserOutputChanRef = o p.parserOutputChanRef = o
p.userOutputChanRef = o p.userOutputChanRef = o
} }
// parse interprets an incoming h264 stream and extracts individual frames // parse interprets an incoming h264 stream and extracts individual frames
// aka access units // aka access units
func (p *h264Parser) parse() { func (p *H264) parse() {
outputBuffer := make([]byte, 0, outputBufferSize) outputBuffer := make([]byte, 0, outputBufferSize)
searchingForEnd := false searchingForEnd := false
for p.isParsing { for p.isParsing {