From 47f6dcfe514a8c1934e25bb81d7521e649844566 Mon Sep 17 00:00:00 2001 From: Saxon Date: Mon, 28 Oct 2019 08:41:49 +1030 Subject: [PATCH] codec/h264/extract.go: extracter->extractor everywhere --- codec/h264/extract.go | 30 +++++++++++++++--------------- codec/h264/extract_test.go | 2 +- revid/revid.go | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/codec/h264/extract.go b/codec/h264/extract.go index 7964600a..b431207f 100644 --- a/codec/h264/extract.go +++ b/codec/h264/extract.go @@ -3,7 +3,7 @@ NAME extract.go DESCRIPTION - extract.go provides an extracter to get access units from an RTP stream. + extract.go provides an Extractor to get access units from an RTP stream. AUTHOR Saxon Nelson-Milton @@ -72,23 +72,23 @@ const ( // Bytes for an access unit delimeter. var aud = []byte{0x00, 0x00, 0x01, 0x09, 0xf0} -// Extracter is an extracter for extracting H264 access units from RTP stream. -type Extracter struct { +// Extractor is an Extractor for extracting H264 access units from RTP stream. +type Extractor struct { buf *bytes.Buffer // Holds the current access unit. frag bool // Indicates if we're currently dealing with a fragmentation packet. dst io.Writer // The destination we'll be writing extracted NALUs to. toWrite []byte // Holds the current NAL unit with start code to be written. } -// NewExtracter returns a new Extracter. -func NewExtracter() *Extracter { - return &Extracter{ +// NewExtractor returns a new Extractor. +func NewExtractor() *Extractor { + return &Extractor{ buf: bytes.NewBuffer(make([]byte, 0, maxAUSize))} } // Extract extracts H264 access units from an RTP stream. This function // expects that each read from src will provide a single RTP packet. -func (e *Extracter) Extract(dst io.Writer, src io.Reader, delay time.Duration) error { +func (e *Extractor) Extract(dst io.Writer, src io.Reader, delay time.Duration) error { e.toWrite = []byte{0, 0, 0, 1} e.buf.Write(aud) e.dst = dst @@ -146,8 +146,8 @@ func (e *Extracter) Extract(dst io.Writer, src io.Reader, delay time.Duration) e } // handleSTAPA parses NAL units from an aggregation packet and writes -// them to the Extracter's buffer buf. -func (e *Extracter) handleSTAPA(d []byte) { +// them to the Extractor's buffer buf. +func (e *Extractor) handleSTAPA(d []byte) { // If the length is too small, ignore. if len(d) < minSTAPALen { return @@ -168,8 +168,8 @@ func (e *Extracter) handleSTAPA(d []byte) { } // handleFUA parses NAL units from fragmentation packets and writes -// them to the Extracter's buf. -func (e *Extracter) handleFUA(d []byte) { +// them to the Extractor's buf. +func (e *Extractor) handleFUA(d []byte) { // If length is too small, ignore. if len(d) < minFUALen { return @@ -200,10 +200,10 @@ func (e *Extracter) handleFUA(d []byte) { } } -// writeWithPrefix writes a NAL unit to the Extracter's buf in byte stream format +// writeWithPrefix writes a NAL unit to the Extractor's buf in byte stream format // using the start code, and sends any ready prior access unit stored in the buf // to the destination. -func (e *Extracter) writeWithPrefix(d []byte) { +func (e *Extractor) writeWithPrefix(d []byte) { e.toWrite = append(e.toWrite, d...) curType, _ := NALType(e.toWrite) if e.buf.Len() != 0 && (curType == h264dec.NALTypeSPS || curType == h264dec.NALTypeIDR || curType == h264dec.NALTypeNonIDR) { @@ -215,8 +215,8 @@ func (e *Extracter) writeWithPrefix(d []byte) { e.toWrite = e.toWrite[:4] } -// writeNoPrefix writes data to the Extracter's buf. This is used for non start +// writeNoPrefix writes data to the Extractor's buf. This is used for non start // fragmentations of a NALU. -func (e *Extracter) writeNoPrefix(d []byte) { +func (e *Extractor) writeNoPrefix(d []byte) { e.buf.Write(d) } diff --git a/codec/h264/extract_test.go b/codec/h264/extract_test.go index eb82af1e..b071b1f7 100644 --- a/codec/h264/extract_test.go +++ b/codec/h264/extract_test.go @@ -159,7 +159,7 @@ func TestRTPLex(t *testing.T) { for testNum, test := range tests { r := &rtpReader{packets: test.packets} d := &destination{} - err := NewExtracter().Extract(d, r, 0) + err := NewExtractor().Extract(d, r, 0) if err != nil { t.Fatalf("error lexing: %v\n", err) } diff --git a/revid/revid.go b/revid/revid.go index fc3b3335..0fbf2fe6 100644 --- a/revid/revid.go +++ b/revid/revid.go @@ -322,7 +322,7 @@ func (r *Revid) setupPipeline(mtsEnc func(dst io.WriteCloser, rate float64) (io. r.setupInput = r.startRTSPCamera switch r.config.InputCodec { case codecutil.H264: - r.lexTo = h264.NewExtracter().Extract + r.lexTo = h264.NewExtractor().Extract case codecutil.H265: r.lexTo = h265.NewLexer(false).Lex case codecutil.MJPEG: