Skip to content

Commit

Permalink
excepting errors on writing response, in NewFLVWriter. #132 issue
Browse files Browse the repository at this point in the history
  • Loading branch information
sSimuSs committed Dec 15, 2020
1 parent b6f9735 commit f91633f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 3 additions & 1 deletion protocol/httpflv/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ func (server *Server) Serve(l net.Listener) error {
mux.HandleFunc("/streams", func(w http.ResponseWriter, r *http.Request) {
server.getStream(w, r)
})
http.Serve(l, mux)
if err := http.Serve(l, mux); err != nil {
return err
}
return nil
}

Expand Down
11 changes: 9 additions & 2 deletions protocol/httpflv/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,22 @@ func NewFLVWriter(app, title, url string, ctx http.ResponseWriter) *FLVWriter {
packetQueue: make(chan *av.Packet, maxQueueNum),
}

ret.ctx.Write([]byte{0x46, 0x4c, 0x56, 0x01, 0x05, 0x00, 0x00, 0x00, 0x09})
if _, err := ret.ctx.Write([]byte{0x46, 0x4c, 0x56, 0x01, 0x05, 0x00, 0x00, 0x00, 0x09}); err != nil {
log.Errorf("Error on response writer")
ret.closed = true
}
pio.PutI32BE(ret.buf[:4], 0)
ret.ctx.Write(ret.buf[:4])
if _, err := ret.ctx.Write(ret.buf[:4]); err != nil {
log.Errorf("Error on response writer")
ret.closed = true
}
go func() {
err := ret.SendPacket()
if err != nil {
log.Error("SendPacket error: ", err)
ret.closed = true
}

}()
return ret
}
Expand Down

0 comments on commit f91633f

Please sign in to comment.