Skip to content

Commit

Permalink
Merge pull request gwuhaolin#143 from sSimuSs/master
Browse files Browse the repository at this point in the history
Excepting errors on writing response in NewFLVWriter
  • Loading branch information
gwuhaolin authored Dec 16, 2020
2 parents bfa299a + f91633f commit a254105
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 a254105

Please sign in to comment.