mirror of https://bitbucket.org/ausocean/av.git
revid: ignoring rtmp.ErrInvalidFlvTag error and checking that rtmp conn is not closed before we try to close it
This commit is contained in:
parent
9c59c5b9d3
commit
8606320731
|
@ -298,6 +298,9 @@ func (s *rtmpSender) load(c *ring.Chunk) error {
|
|||
|
||||
func (s *rtmpSender) send() error {
|
||||
_, err := s.chunk.WriteTo(s.conn)
|
||||
if err == rtmp.ErrInvalidFlvTag {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -307,7 +310,7 @@ func (s *rtmpSender) release() {
|
|||
}
|
||||
|
||||
func (s *rtmpSender) restart() error {
|
||||
s.conn.Close()
|
||||
s.close()
|
||||
var err error
|
||||
for n := 0; n < s.retries; n++ {
|
||||
s.conn, err = rtmp.Dial(s.url, s.timeout, s.log)
|
||||
|
@ -323,8 +326,11 @@ func (s *rtmpSender) restart() error {
|
|||
}
|
||||
|
||||
func (s *rtmpSender) close() error {
|
||||
if s.conn != nil {
|
||||
return s.conn.Close()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// udpSender implements loadSender for a native udp destination.
|
||||
type udpSender struct {
|
||||
|
|
|
@ -155,7 +155,7 @@ func (c *Conn) Write(data []byte) (int, error) {
|
|||
return 0, errNotConnected
|
||||
}
|
||||
if len(data) < flvTagheaderSize {
|
||||
return 0, errInvalidFlvTag
|
||||
return 0, ErrInvalidFlvTag
|
||||
}
|
||||
if data[0] == packetTypeInfo || (data[0] == 'F' && data[1] == 'L' && data[2] == 'V') {
|
||||
return 0, errUnimplemented
|
||||
|
|
|
@ -158,7 +158,7 @@ var (
|
|||
errNotWritable = errors.New("rtmp: connection not writable")
|
||||
errInvalidHeader = errors.New("rtmp: invalid header")
|
||||
errInvalidBody = errors.New("rtmp: invalid body")
|
||||
errInvalidFlvTag = errors.New("rtmp: invalid FLV tag")
|
||||
ErrInvalidFlvTag = errors.New("rtmp: invalid FLV tag")
|
||||
errUnimplemented = errors.New("rtmp: unimplemented feature")
|
||||
)
|
||||
|
||||
|
|
|
@ -216,7 +216,7 @@ type rtmpSender struct {
|
|||
|
||||
func (rs *rtmpSender) Write(p []byte) (int, error) {
|
||||
n, err := rs.conn.Write(p)
|
||||
if err != errInvalidFlvTag && err != nil {
|
||||
if err != ErrInvalidFlvTag && err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return n, nil
|
||||
|
|
Loading…
Reference in New Issue