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 package revid
import ( import (
"bytes"
"fmt"
"io" "io"
"os" "os"
"os/exec" "os/exec"
@ -107,8 +105,6 @@ type httpSender struct {
log func(lvl, msg string) log func(lvl, msg string)
buf []byte
chunk *ring.Chunk chunk *ring.Chunk
} }
@ -123,25 +119,16 @@ func newHttpSender(_ string, _ time.Duration, log func(lvl, msg string)) *httpSe
func (s *httpSender) load(c *ring.Chunk) error { func (s *httpSender) load(c *ring.Chunk) error {
s.chunk = c 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 return nil
} }
func (s *httpSender) send() error { func (s *httpSender) send() error {
pins := netsender.MakePins("V0", "") pins := netsender.MakePins("V0", "")
pins[0].Value = len(s.buf) pins[0].Value = s.chunk.Len()
pins[0].Data = s.buf pins[0].Data = s.chunk.Bytes()
pins[0].MimeType = "video/mp2t" pins[0].MimeType = "video/mp2t"
_, _, err := s.client.Send(netsender.RequestPoll, pins) _, _, err := s.client.Send(netsender.RequestPoll, pins)
if err != nil { return err
return err
}
return nil
} }
func (s *httpSender) release() { func (s *httpSender) release() {