mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
handle closed peerConnection.
This commit is contained in:
parent
40d820a3e0
commit
45ee1eef3e
@ -1,6 +1,7 @@
|
|||||||
package webrtc
|
package webrtc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"strings"
|
"strings"
|
||||||
@ -66,6 +67,10 @@ func (manager *WebRTCManagerCtx) Start() {
|
|||||||
|
|
||||||
audioListener := func(sample types.Sample) {
|
audioListener := func(sample types.Sample) {
|
||||||
if err := manager.audioTrack.WriteSample(media.Sample(sample)); err != nil && err != io.ErrClosedPipe {
|
if err := manager.audioTrack.WriteSample(media.Sample(sample)); err != nil && err != io.ErrClosedPipe {
|
||||||
|
if errors.Is(err, io.ErrClosedPipe) {
|
||||||
|
// The peerConnection has been closed.
|
||||||
|
return
|
||||||
|
}
|
||||||
manager.logger.Warn().Err(err).Msg("audio pipeline failed to write")
|
manager.logger.Warn().Err(err).Msg("audio pipeline failed to write")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -167,6 +172,10 @@ func (manager *WebRTCManagerCtx) CreatePeer(session types.Session, videoID strin
|
|||||||
|
|
||||||
videoListener := func(sample types.Sample) {
|
videoListener := func(sample types.Sample) {
|
||||||
if err := videoTrack.WriteSample(media.Sample(sample)); err != nil && err != io.ErrClosedPipe {
|
if err := videoTrack.WriteSample(media.Sample(sample)); err != nil && err != io.ErrClosedPipe {
|
||||||
|
if errors.Is(err, io.ErrClosedPipe) {
|
||||||
|
// The peerConnection has been closed.
|
||||||
|
return
|
||||||
|
}
|
||||||
manager.logger.Warn().Err(err).Msg("video pipeline failed to write")
|
manager.logger.Warn().Err(err).Msg("video pipeline failed to write")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user