Browse Source

fix: stream is nil course panic

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

4
protocol/hls/source.go

@ -100,7 +100,9 @@ func (source *Source) Write(p av.Packet) error { @@ -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
}

20
protocol/rtmp/stream.go

@ -29,18 +29,16 @@ func (rs *RtmpStream) HandleReader(r av.ReadCloser) { @@ -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)
}

Loading…
Cancel
Save