Browse Source

将配置文件中的PublicIP改为数组

v4
langhuihui 4 years ago
parent
commit
057aa4e4ef
  1. 6
      main.go

6
main.go

@ -20,7 +20,7 @@ import (
var config struct { var config struct {
ICEServers []string ICEServers []string
PublicIP string PublicIP []string
} }
// }{[]string{ // }{[]string{
@ -173,7 +173,7 @@ func (rtc *WebRTC) Publish(streamPath string) bool {
DefaultPayloadTypeH264, DefaultPayloadTypeH264,
new(avformat.H264))) new(avformat.H264)))
//m.RegisterCodec(NewRTPPCMUCodec(DefaultPayloadTypePCMU, 8000)) //m.RegisterCodec(NewRTPPCMUCodec(DefaultPayloadTypePCMU, 8000))
rtc.s.SetNAT1To1IPs([]string{config.PublicIP}, ICECandidateTypeHost) rtc.s.SetNAT1To1IPs(config.PublicIP, ICECandidateTypeHost)
rtc.api = NewAPI(WithMediaEngine(rtc.m), WithSettingEngine(rtc.s)) rtc.api = NewAPI(WithMediaEngine(rtc.m), WithSettingEngine(rtc.s))
peerConnection, err := rtc.api.NewPeerConnection(Configuration{ peerConnection, err := rtc.api.NewPeerConnection(Configuration{
ICEServers: []ICEServer{ ICEServers: []ICEServer{
@ -300,7 +300,7 @@ func run() {
DefaultPayloadTypeH264, DefaultPayloadTypeH264,
&rtc.payloader)) &rtc.payloader))
rtc.m.RegisterCodec(NewRTPPCMACodec(DefaultPayloadTypePCMA, 8000)) rtc.m.RegisterCodec(NewRTPPCMACodec(DefaultPayloadTypePCMA, 8000))
rtc.s.SetNAT1To1IPs([]string{config.PublicIP}, ICECandidateTypeHost) rtc.s.SetNAT1To1IPs(config.PublicIP, ICECandidateTypeHost)
rtc.api = NewAPI(WithMediaEngine(rtc.m), WithSettingEngine(rtc.s)) rtc.api = NewAPI(WithMediaEngine(rtc.m), WithSettingEngine(rtc.s))
peerConnection, err := rtc.api.NewPeerConnection(Configuration{ peerConnection, err := rtc.api.NewPeerConnection(Configuration{
// ICEServers: []ICEServer{ // ICEServers: []ICEServer{

Loading…
Cancel
Save