Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot be used without internet on the LAN #81

Open
MI-Class opened this issue Apr 12, 2023 · 1 comment
Open

Cannot be used without internet on the LAN #81

MI-Class opened this issue Apr 12, 2023 · 1 comment

Comments

@MI-Class
Copy link

The version I use is [email protected] and the version of go is 1.18.
On the LAN and not available when there is no internet, then I modified /format/webrtcv3/adapter.go

This method

func (element *Muxer) WriteHeader(streams []av.CodecData, sdp64 string) (string, error)

About line 197

	// gatherCompletePromise := webrtc.GatheringCompletePromise(peerConnection)
	answer, err := peerConnection.CreateAnswer(nil)
	if err != nil {
		return "", err
	}
	if err = peerConnection.SetLocalDescription(answer); err != nil {
		return "", err
	}

	element.pc = peerConnection
	// waitT := time.NewTimer(time.Second * 10)
	// select {
	// case <-waitT.C:
	// 	// return "", errors.New("gatherCompletePromise wait")
	// case <-gatherCompletePromise:
	// 	//Connected
	// }
	time.Sleep(time.Millisecond * 1)
	resp := peerConnection.LocalDescription()
	WriteHeaderSuccess = true

	return base64.StdEncoding.EncodeToString([]byte(resp.SDP)), nil

so modify hereafter in lan without the use of the internet, but I don't know what is the cause of this problem, so... can you check what is the reason, and then repair under, thank you.

@MI-Class
Copy link
Author

Perhaps because of the problem here, there is no configuration ice_servers in my configuration file, and then a default value is given when judging that there is no configuration.

func (element *Muxer) NewPeerConnection(configuration webrtc.Configuration) (*webrtc.PeerConnection, error) {
	if len(element.Options.ICEServers) > 0 {
		log.Println("Set ICEServers", element.Options.ICEServers)
		configuration.ICEServers = append(configuration.ICEServers, webrtc.ICEServer{
			URLs:           element.Options.ICEServers,
			Username:       element.Options.ICEUsername,
			Credential:     element.Options.ICECredential,
			CredentialType: webrtc.ICECredentialTypePassword,
		})
	} else {
		configuration.ICEServers = append(configuration.ICEServers, webrtc.ICEServer{
			URLs: []string{"stun:stun.l.google.com:19302"},
		})
	}
   ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant