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 f6a8749 commit 3979be9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
4 changes: 3 additions & 1 deletion protocol/hls/source.go
Expand Up @@ -100,7 +100,9 @@ func (source *Source) Write(p av.Packet) error {
if len(source.packetQueue) >= maxQueueNum-24 {
source.DropPacket(source.packetQueue, source.info)
} else {
source.packetQueue <- p
if !source.closed {
source.packetQueue <- p
}
}
return nil
}
Expand Down
20 changes: 9 additions & 11 deletions protocol/rtmp/stream.go
Expand Up @@ -29,18 +29,16 @@ func (rs *RtmpStream) HandleReader(r av.ReadCloser) {
info := r.Info()
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)
}
if stream, ok = i.(*Stream); ok {
stream.TransStop()
id := stream.ID()
if id != EmptyID && id != info.UID {
ns := NewStream()
stream.Copy(ns)
stream = ns
rs.streams.Set(info.Key, ns)
}
} else {
}else {
stream = NewStream()
rs.streams.Set(info.Key, stream)
}
Expand Down

0 comments on commit 3979be9

Please sign in to comment.