From 648b43c50a43b2195918894e7853f204b8b1fe0d Mon Sep 17 00:00:00 2001 From: Saxon Date: Fri, 29 Mar 2019 13:29:31 +1030 Subject: [PATCH] revid: added some commentary --- revid/senders.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/revid/senders.go b/revid/senders.go index 44e2db34..959fba21 100644 --- a/revid/senders.go +++ b/revid/senders.go @@ -113,8 +113,13 @@ func (s *minimalHttpSender) send(d []byte) error { // When a loadSender has finished using the *ring.Chunk // it must be Closed. type loadSender interface { + // load assigns the *ring.Chunk to the loadSender. + // The load call may fail, but must not mutate the + // the chunk. load(d []byte) error + // send performs a destination-specific send + // operation. It must not mutate the chunk. send() error // release releases the *ring.Chunk. @@ -136,6 +141,7 @@ type fileSender struct { data []byte } +// Write implements io.Writer. This will attempt to load and send the data given. func (s *fileSender) Write(d []byte) (int, error) { err := s.load(d) if err != nil { @@ -185,6 +191,7 @@ type mtsSender struct { curPid int } +// Write implements io.Writer. This will attempt to load and send the data given. func (s *mtsSender) Write(d []byte) (int, error) { return write(s, d) } @@ -372,6 +379,7 @@ func newRtmpSender(url string, timeout uint, retries int, log func(lvl int8, msg return s, err } +// Write implements io.Writer. This will attempt to load and send the data given. func (s *rtmpSender) Write(d []byte) (int, error) { return write(s, d) } @@ -425,6 +433,7 @@ type rtpSender struct { data []byte } +// Write implements io.Writer. This will attempt to load and send the data given. func (s *rtpSender) Write(d []byte) (int, error) { return write(s, d) } @@ -456,6 +465,7 @@ func (s *rtpSender) send() error { return err } +// write wraps the load and send method for loadSenders. func write(s loadSender, d []byte) (int, error) { err := s.load(d) if err != nil {