Browse Source

加一些判断

v4
langhuihui 4 years ago
parent
commit
8fe5b192db
  1. 14
      main.go

14
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 = peerConnection.AddTransceiverFromKind(RTPCodecTypeVideo); err != nil {
if err != nil { if err != nil {
Println(err) Println(err)
@ -315,13 +319,16 @@ func run() {
rtc.s.SetEphemeralUDPPortRange(config.PortMin, config.PortMax) rtc.s.SetEphemeralUDPPortRange(config.PortMin, config.PortMax)
} }
rtc.api = NewAPI(WithMediaEngine(rtc.m), WithSettingEngine(rtc.s)) 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{ // ICEServers: []ICEServer{
// { // {
// URLs: config.ICEServers, // URLs: config.ICEServers,
// }, // },
// }, // },
}) }); err != nil {
return
}
rtc.OnICECandidate(func(ice *ICECandidate) { rtc.OnICECandidate(func(ice *ICECandidate) {
if ice != nil { if ice != nil {
Println(ice.ToJSON().Candidate) Println(ice.ToJSON().Candidate)
@ -332,9 +339,6 @@ func run() {
// } else { // } else {
// Println(err) // Println(err)
// } // }
if err != nil {
return
}
rtc.RemoteAddr = r.RemoteAddr rtc.RemoteAddr = r.RemoteAddr
if err = rtc.SetRemoteDescription(offer); err != nil { if err = rtc.SetRemoteDescription(offer); err != nil {
return return

Loading…
Cancel
Save