From 8fe5b192db279a99f7910e5da6936268200c0965 Mon Sep 17 00:00:00 2001 From: langhuihui <178529795@qq.com> Date: Sat, 9 Jan 2021 18:12:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E4=B8=80=E4=BA=9B=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index 3dd0cd4..9af30cc 100644 --- a/main.go +++ b/main.go @@ -189,6 +189,10 @@ func (rtc *WebRTC) Publish(streamPath string) bool { }, }, }) + if err != nil { + Println(err) + return false + } if _, err = peerConnection.AddTransceiverFromKind(RTPCodecTypeVideo); err != nil { if err != nil { Println(err) @@ -315,13 +319,16 @@ func run() { rtc.s.SetEphemeralUDPPortRange(config.PortMin, config.PortMax) } rtc.api = NewAPI(WithMediaEngine(rtc.m), WithSettingEngine(rtc.s)) - rtc.PeerConnection, err = rtc.api.NewPeerConnection(Configuration{ + + if rtc.PeerConnection, err = rtc.api.NewPeerConnection(Configuration{ // ICEServers: []ICEServer{ // { // URLs: config.ICEServers, // }, // }, - }) + }); err != nil { + return + } rtc.OnICECandidate(func(ice *ICECandidate) { if ice != nil { Println(ice.ToJSON().Candidate) @@ -332,9 +339,6 @@ func run() { // } else { // Println(err) // } - if err != nil { - return - } rtc.RemoteAddr = r.RemoteAddr if err = rtc.SetRemoteDescription(offer); err != nil { return