parser: expose MJPEG documentation

This commit is contained in:
Dan Kortschak 2018-06-17 21:30:00 +09:30
parent 0b0f12431b
commit 77cb074ede
1 changed files with 10 additions and 10 deletions

View File

@ -29,7 +29,7 @@ package parser
const frameStartCode = 0xD8 const frameStartCode = 0xD8
type mjpegParser struct { type MJPEG struct {
inputBuffer []byte inputBuffer []byte
isParsing bool isParsing bool
parserOutputChanRef chan []byte parserOutputChanRef chan []byte
@ -38,39 +38,39 @@ type mjpegParser struct {
delay uint delay uint
} }
func NewMJPEGParser(inputChanLen int) (p *mjpegParser) { func NewMJPEGParser(inputChanLen int) (p *MJPEG) {
p = new(mjpegParser) p = new(MJPEG)
p.isParsing = true p.isParsing = true
p.inputChan = make(chan byte, inputChanLen) p.inputChan = make(chan byte, inputChanLen)
return return
} }
func (p *mjpegParser) Stop() { func (p *MJPEG) Stop() {
p.isParsing = false p.isParsing = false
} }
func (p *mjpegParser) Start() { func (p *MJPEG) Start() {
go p.parse() go p.parse()
} }
func (p *mjpegParser) SetDelay(delay uint) { func (p *MJPEG) SetDelay(delay uint) {
p.delay = delay p.delay = delay
} }
func (p *mjpegParser) InputChan() chan byte { func (p *MJPEG) InputChan() chan byte {
return p.inputChan return p.inputChan
} }
func (p *mjpegParser) OutputChan() <-chan []byte { func (p *MJPEG) OutputChan() <-chan []byte {
return p.userOutputChanRef return p.userOutputChanRef
} }
func (p *mjpegParser) SetOutputChan(o chan []byte) { func (p *MJPEG) SetOutputChan(o chan []byte) {
p.parserOutputChanRef = o p.parserOutputChanRef = o
p.userOutputChanRef = o p.userOutputChanRef = o
} }
func (p *mjpegParser) parse() { func (p *MJPEG) parse() {
var outputBuffer []byte var outputBuffer []byte
for p.isParsing { for p.isParsing {
aByte := <-p.inputChan aByte := <-p.inputChan