Skip to content

Commit

Permalink
fix: stream is nil course panic
Browse files Browse the repository at this point in the history
  • Loading branch information
halwu(吴浩麟) committed May 30, 2017
1 parent 09976a1 commit f6a8749
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions protocol/rtmp/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,25 @@ func NewRtmpStream() *RtmpStream {

func (rs *RtmpStream) HandleReader(r av.ReadCloser) {
info := r.Info()
var s *Stream
ok := rs.streams.Has(info.Key)
if !ok {
s = NewStream()
rs.streams.Set(info.Key, s)
} else {
s.TransStop()
id := s.ID()
if id != EmptyID && id != info.UID {
ns := NewStream()
s.Copy(ns)
s = ns
rs.streams.Set(info.Key, ns)
var stream *Stream
i, ok := rs.streams.Get(info.Key)
if ok {
if s, ok := i.(*Stream); ok {
s.TransStop()
id := s.ID()
if id != EmptyID && id != info.UID {
ns := NewStream()
s.Copy(ns)
s = ns
rs.streams.Set(info.Key, ns)
}
}
} else {
stream = NewStream()
rs.streams.Set(info.Key, stream)
}
s.AddReader(r)

stream.AddReader(r)
}

func (rs *RtmpStream) HandleWriter(w av.WriteCloser) {
Expand Down

0 comments on commit f6a8749

Please sign in to comment.