revid: wrote loadsender implementation for udp sending for the rtp - need to test

This commit is contained in:
saxon 2018-11-18 12:32:11 +10:30
parent 5cc35a77a5
commit d291744f63
1 changed files with 33 additions and 0 deletions

View File

@ -30,6 +30,7 @@ package revid
import ( import (
"io" "io"
"net"
"os" "os"
"os/exec" "os/exec"
@ -289,3 +290,35 @@ func (s *rtmpSender) restart() error {
func (s *rtmpSender) close() error { func (s *rtmpSender) close() error {
return s.sess.Close() return s.sess.Close()
} }
// rtpSender implements loadSender for a native udp destination.
type udpSender struct {
conn net.Conn
log func(lvl int8, msg string, args ...interface{})
chunk *ring.Chunk
}
func newUdpSender(addr string, log func(lvl int8, msg string,
args ...interface{})) (*udpSender, error) {
conn, err := net.Dial("udp", addr)
if err != nil {
return nil, err
}
return &udpSender{
conn: conn,
log: log,
}, nil
}
func (s *udpSender) load(c *ring.Chunk) error {
s.chunk = c
return nil
}
func (s *udpSender) send() error {
_, err := s.chunk.WriteTo(s.conn)
return err
}
func (s *udpSender) close() error { return nil }