mirror of
https://github.com/m1k1o/neko.git
synced 2025-08-03 08:50:13 +02:00
Fix upstream not working if there is an error
This commit is contained in:
parent
2b3d945281
commit
f7128e8a87
2 changed files with 4 additions and 13 deletions
|
@ -47,7 +47,7 @@ func NewBroadcastPipeline(device string, display string, pipelineSrc string, url
|
|||
// replace display
|
||||
pipelineStr = strings.Replace(pipelineStr, "{display}", display, -1)
|
||||
} else {
|
||||
pipelineStr = fmt.Sprintf("flvmux name=mux ! rtmpsink location='%s live=1' %s audio/x-raw,channels=2 ! audioconvert ! voaacenc ! mux. %s video/x-raw,format=NV12 ! x264enc bitrate=%d bframes=0 key-int-max=60 byte-stream=true tune=zerolatency speed-preset=veryfast ! mux.", url, audio, video, 6000)
|
||||
pipelineStr = fmt.Sprintf("flvmux name=mux ! rtmpsink location='%s live=1' %s audio/x-raw,channels=2 ! audioconvert ! voaacenc ! mux. %s video/x-raw,format=NV12 ! x264enc bitrate=%d bframes=0 key-int-max=60 byte-stream=true tune=zerolatency speed-preset=veryfast ! mux.", url, audio, video, 8000)
|
||||
}
|
||||
|
||||
return pipelineStr, nil
|
||||
|
|
|
@ -48,9 +48,6 @@ type Client struct {
|
|||
}
|
||||
|
||||
func (c *Client) readPump() {
|
||||
defer func() {
|
||||
c.hub.unregister <- c
|
||||
}()
|
||||
c.conn.SetReadLimit(maxMessageSize)
|
||||
c.conn.SetReadDeadline(time.Now().Add(pongWait))
|
||||
c.conn.SetPongHandler(func(string) error {
|
||||
|
@ -64,8 +61,7 @@ func (c *Client) readPump() {
|
|||
if websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway, websocket.CloseAbnormalClosure) {
|
||||
log.Printf("error: %v", err)
|
||||
}
|
||||
c.hub.unregister <- c
|
||||
break
|
||||
return
|
||||
}
|
||||
c.hub.broadcast <- raw
|
||||
}
|
||||
|
@ -77,18 +73,13 @@ func (c *Client) writePump() {
|
|||
ticker.Stop()
|
||||
c.hub.unregister <- c
|
||||
close(c.send)
|
||||
c.conn.Close()
|
||||
}()
|
||||
|
||||
for {
|
||||
select {
|
||||
case raw, ok := <-c.send:
|
||||
case raw := <-c.send:
|
||||
c.conn.SetWriteDeadline(time.Now().Add(writeWait))
|
||||
if !ok {
|
||||
// The hub closed the channel.
|
||||
c.conn.WriteMessage(websocket.CloseMessage, []byte{})
|
||||
c.conn.Close()
|
||||
return
|
||||
}
|
||||
|
||||
if err := c.conn.WriteMessage(websocket.BinaryMessage, raw); err != nil {
|
||||
log.Printf("Error writing message: %v", err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue