Browse Source

fix: stream is nil course panic

pull/6/head 0.0.4
halwu(吴浩麟) 8 years ago
parent
commit
3979be9d24
  1. 2
      protocol/hls/source.go
  2. 12
      protocol/rtmp/stream.go

2
protocol/hls/source.go

@ -100,8 +100,10 @@ func (source *Source) Write(p av.Packet) error {
if len(source.packetQueue) >= maxQueueNum-24 { if len(source.packetQueue) >= maxQueueNum-24 {
source.DropPacket(source.packetQueue, source.info) source.DropPacket(source.packetQueue, source.info)
} else { } else {
if !source.closed {
source.packetQueue <- p source.packetQueue <- p
} }
}
return nil return nil
} }

12
protocol/rtmp/stream.go

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

Loading…
Cancel
Save