mirror of https://bitbucket.org/ausocean/av.git
Merged in ring/bytes (pull request #35)
revid: use direct access to ring.Chunk bytes
This commit is contained in:
commit
5840e483b8
|
@ -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,25 +119,16 @@ 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() {
|
||||
|
|
Loading…
Reference in New Issue