From d291744f6395e96154d26f763a42472b54689d44 Mon Sep 17 00:00:00 2001 From: saxon Date: Sun, 18 Nov 2018 12:32:11 +1030 Subject: [PATCH] revid: wrote loadsender implementation for udp sending for the rtp - need to test --- revid/senders.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) 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 }