Merged in ring/bytes (pull request #35)

revid: use direct access to ring.Chunk bytes
This commit is contained in:
kortschak 2018-06-18 22:52:55 +00:00 committed by Alan Noble
commit 5840e483b8
1 changed files with 3 additions and 16 deletions

View File

@ -29,8 +29,6 @@ LICENSE
package revid
import (
"bytes"
"fmt"
"io"
"os"
"os/exec"
@ -107,8 +105,6 @@ type httpSender struct {
log func(lvl, msg string)
buf []byte
chunk *ring.Chunk
}
@ -123,26 +119,17 @@ func newHttpSender(_ string, _ time.Duration, log func(lvl, msg string)) *httpSe
func (s *httpSender) load(c *ring.Chunk) error {
s.chunk = c
buf := bytes.NewBuffer(s.buf[:0])
_, err := s.chunk.WriteTo(buf)
s.buf = buf.Bytes()
if err != nil {
return fmt.Errorf("httpSender: %v", err)
}
return nil
}
func (s *httpSender) send() error {
pins := netsender.MakePins("V0", "")
pins[0].Value = len(s.buf)
pins[0].Data = s.buf
pins[0].Value = s.chunk.Len()
pins[0].Data = s.chunk.Bytes()
pins[0].MimeType = "video/mp2t"
_, _, err := s.client.Send(netsender.RequestPoll, pins)
if err != nil {
return err
}
return nil
}
func (s *httpSender) release() {
s.chunk.Close()