mirror of https://bitbucket.org/ausocean/av.git
rtmp.Session now rtmp.Conn and rtmp.NewSession() and Open() replaced with Dial().
This commit is contained in:
parent
974d9a484b
commit
fd903b4add
|
@ -251,7 +251,7 @@ func (s *ffmpegSender) close() error {
|
||||||
|
|
||||||
// rtmpSender implements loadSender for a native RTMP destination.
|
// rtmpSender implements loadSender for a native RTMP destination.
|
||||||
type rtmpSender struct {
|
type rtmpSender struct {
|
||||||
sess *rtmp.Session
|
conn *rtmp.Conn
|
||||||
|
|
||||||
url string
|
url string
|
||||||
timeout uint
|
timeout uint
|
||||||
|
@ -264,16 +264,15 @@ type rtmpSender struct {
|
||||||
var _ restarter = (*rtmpSender)(nil)
|
var _ restarter = (*rtmpSender)(nil)
|
||||||
|
|
||||||
func newRtmpSender(url string, timeout uint, retries int, log func(lvl int8, msg string, args ...interface{})) (*rtmpSender, error) {
|
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
|
var err error
|
||||||
for n := 0; n < retries; n++ {
|
for n := 0; n < retries; n++ {
|
||||||
sess = rtmp.NewSession(url, timeout, log)
|
conn, err = rtmp.Dial(url, timeout, log)
|
||||||
err = sess.Open()
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
log(logger.Error, err.Error())
|
log(logger.Error, err.Error())
|
||||||
sess.Close()
|
conn.Close()
|
||||||
if n < retries-1 {
|
if n < retries-1 {
|
||||||
log(logger.Info, pkg+"retry rtmp connection")
|
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{
|
s := &rtmpSender{
|
||||||
sess: sess,
|
conn: conn,
|
||||||
url: url,
|
url: url,
|
||||||
timeout: timeout,
|
timeout: timeout,
|
||||||
retries: retries,
|
retries: retries,
|
||||||
|
@ -298,7 +297,7 @@ func (s *rtmpSender) load(c *ring.Chunk) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *rtmpSender) send() error {
|
func (s *rtmpSender) send() error {
|
||||||
_, err := s.chunk.WriteTo(s.sess)
|
_, err := s.chunk.WriteTo(s.conn)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,18 +307,17 @@ func (s *rtmpSender) release() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *rtmpSender) restart() error {
|
func (s *rtmpSender) restart() error {
|
||||||
err := s.sess.Close()
|
err := s.conn.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for n := 0; n < s.retries; n++ {
|
for n := 0; n < s.retries; n++ {
|
||||||
s.sess = rtmp.NewSession(s.url, s.timeout, s.log)
|
s.conn, err = rtmp.Dial(s.url, s.timeout, s.log)
|
||||||
err = s.sess.Open()
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
s.log(logger.Error, err.Error())
|
s.log(logger.Error, err.Error())
|
||||||
s.sess.Close()
|
s.conn.Close()
|
||||||
if n < s.retries-1 {
|
if n < s.retries-1 {
|
||||||
s.log(logger.Info, pkg+"retry rtmp connection")
|
s.log(logger.Info, pkg+"retry rtmp connection")
|
||||||
}
|
}
|
||||||
|
@ -328,7 +326,7 @@ func (s *rtmpSender) restart() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *rtmpSender) close() error {
|
func (s *rtmpSender) close() error {
|
||||||
return s.sess.Close()
|
return s.conn.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
// udpSender implements loadSender for a native udp destination.
|
// udpSender implements loadSender for a native udp destination.
|
||||||
|
|
Loading…
Reference in New Issue