diff --git a/codec/mjpeg/extract.go b/codec/mjpeg/extract.go index 6fb987bd..39e4ec57 100644 --- a/codec/mjpeg/extract.go +++ b/codec/mjpeg/extract.go @@ -48,7 +48,7 @@ func NewExtractor() *Extractor { return &Extractor{} } // function expects that each read from src will provide a single RTP packet. func (e *Extractor) Extract(dst io.Writer, src io.Reader, delay time.Duration) error { buf := make([]byte, maxRTPSize) - c := NewCtx(dst) + ctx := NewContext(dst) for { n, err := src.Read(buf) @@ -72,7 +72,7 @@ func (e *Extractor) Extract(dst io.Writer, src io.Reader, delay time.Duration) e return fmt.Errorf("could not read RTP marker: %w", err) } - err = c.ParsePayload(p, m) + err = ctx.ParsePayload(p, m) if err != nil { return fmt.Errorf("could not parse JPEG scan: %w", err) } diff --git a/codec/mjpeg/jpeg.go b/codec/mjpeg/jpeg.go index 41f9e529..88a7db78 100644 --- a/codec/mjpeg/jpeg.go +++ b/codec/mjpeg/jpeg.go @@ -134,25 +134,25 @@ var ( } ) -// Ctx describes a RTP/JPEG parsing context that will keep track of the current +// Context describes a RTP/JPEG parsing context that will keep track of the current // JPEG (held by p), and the state of the quantization tables. -type Ctx struct { +type Context struct { qTables [128][128]byte qTablesLen [128]byte p *putBuffer d io.Writer } -// NewCTX will return a new Ctx. -func NewCtx(d io.Writer) *Ctx { - return &Ctx{ +// NewContext will return a new Context. +func NewContext(d io.Writer) *Context { + return &Context{ d: d, p: newPutBuffer(make([]byte, maxJPEG)), } } // ParsePayload will parse an RTP/JPEG payload and append to current image. -func (c *Ctx) ParsePayload(p []byte, m bool) error { +func (c *Context) ParsePayload(p []byte, m bool) error { b := newByteStream(p) _ = b.get8() // Ignore type-specific flag