diff --git a/revid/senders.go b/revid/senders.go index 38f7856a..e313993b 100644 --- a/revid/senders.go +++ b/revid/senders.go @@ -30,6 +30,7 @@ package revid import ( "io" + "net" "os" "os/exec" @@ -289,3 +290,35 @@ func (s *rtmpSender) restart() error { func (s *rtmpSender) close() error { 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 }