webrtc: remove offer timeout as this is handled by lib.

This commit is contained in:
Miroslav Šedivý 2021-06-29 22:41:30 +02:00
parent d3fb84e582
commit c2277c4917

View File

@ -1,14 +1,6 @@
package webrtc package webrtc
import ( import "github.com/pion/webrtc/v3"
"time"
"github.com/pion/webrtc/v3"
"github.com/rs/zerolog/log"
)
// how long is can take between sending offer and connecting
const offerTimeout = 10 * time.Second
type WebRTCPeerCtx struct { type WebRTCPeerCtx struct {
api *webrtc.API api *webrtc.API
@ -19,22 +11,6 @@ type WebRTCPeerCtx struct {
} }
func (peer *WebRTCPeerCtx) CreateOffer(ICERestart bool) (*webrtc.SessionDescription, error) { func (peer *WebRTCPeerCtx) CreateOffer(ICERestart bool) (*webrtc.SessionDescription, error) {
// offer timeout
go func() {
time.Sleep(offerTimeout)
// already disconnected
if peer.connection.ConnectionState() == webrtc.PeerConnectionStateClosed {
return
}
// not connected
if peer.connection.ConnectionState() != webrtc.PeerConnectionStateConnected {
log.Warn().Msg("connection timeouted, closing")
peer.connection.Close()
}
}()
offer, err := peer.connection.CreateOffer(&webrtc.OfferOptions{ offer, err := peer.connection.CreateOffer(&webrtc.OfferOptions{
ICERestart: ICERestart, ICERestart: ICERestart,
}) })