diff --git a/revid/senders.go b/revid/senders.go index d1689396..a73523d5 100644 --- a/revid/senders.go +++ b/revid/senders.go @@ -251,7 +251,7 @@ func (s *ffmpegSender) close() error { // rtmpSender implements loadSender for a native RTMP destination. type rtmpSender struct { - sess *rtmp.Session + conn *rtmp.Conn url string timeout uint @@ -264,16 +264,15 @@ type rtmpSender struct { var _ restarter = (*rtmpSender)(nil) func newRtmpSender(url string, timeout uint, retries int, log func(lvl int8, msg string, args ...interface{})) (*rtmpSender, error) { - var sess *rtmp.Session + var conn *rtmp.Conn var err error for n := 0; n < retries; n++ { - sess = rtmp.NewSession(url, timeout, log) - err = sess.Open() + conn, err = rtmp.Dial(url, timeout, log) if err == nil { break } log(logger.Error, err.Error()) - sess.Close() + conn.Close() if n < retries-1 { log(logger.Info, pkg+"retry rtmp connection") } @@ -283,7 +282,7 @@ func newRtmpSender(url string, timeout uint, retries int, log func(lvl int8, msg } s := &rtmpSender{ - sess: sess, + conn: conn, url: url, timeout: timeout, retries: retries, @@ -298,7 +297,7 @@ func (s *rtmpSender) load(c *ring.Chunk) error { } func (s *rtmpSender) send() error { - _, err := s.chunk.WriteTo(s.sess) + _, err := s.chunk.WriteTo(s.conn) return err } @@ -308,18 +307,17 @@ func (s *rtmpSender) release() { } func (s *rtmpSender) restart() error { - err := s.sess.Close() + err := s.conn.Close() if err != nil { return err } for n := 0; n < s.retries; n++ { - s.sess = rtmp.NewSession(s.url, s.timeout, s.log) - err = s.sess.Open() + s.conn, err = rtmp.Dial(s.url, s.timeout, s.log) if err == nil { break } s.log(logger.Error, err.Error()) - s.sess.Close() + s.conn.Close() if n < s.retries-1 { s.log(logger.Info, pkg+"retry rtmp connection") } @@ -328,7 +326,7 @@ func (s *rtmpSender) restart() error { } func (s *rtmpSender) close() error { - return s.sess.Close() + return s.conn.Close() } // udpSender implements loadSender for a native udp destination.