deepch / RTSPtoWeb

RTSP Stream to WebBrowser
MIT License
1.32k stars 312 forks source link

Using Local ICE Server #244

Open AlessandroMartinelli opened 2 years ago

AlessandroMartinelli commented 2 years ago

Good day, I've a local deployment of RTSPtoWeb. Since there is no guarantee of having a permanent internet connection, I'd like to avoid using an ICE server which needs an internet connection in order to be reached out. Is it possible for RTSPtoWeb to act as a local ICE server as well?

milan0dp commented 2 years ago

Hey, i just removed the Google ICE Server from the config and the RTCPEERConnection on the Clientside and it seems to work fine.

AlessandroMartinelli commented 2 years ago

Hey, i just removed the Google ICE Server from the config and the RTCPEERConnection on the Clientside and it seems to work fine.

Thank you for the suggestion. Howerver I've tried and it seems quite an unreliable method the one you're talking about: I get a working stream like 1 time out of 4 and the other times I get a 400 (BAD REQUEST) error.

I'm using this as client and it seems that POST request
webrtc.setRemoteDescription(new RTCSessionDescription({ type: 'answer', sdp: atob(data) }) inside main.js is causing the exception I'm receiving, i.e. DOMException: String contains an invalid character

elparasite commented 1 year ago

Maybe I'm wrong but if I check the code of what I understand is the underlying layer, if no ICE is specified, Goole STUN is used.

Cf. https://github.com/deepch/vdk/blob/master/format/webrtcv3/adapter.go

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"},
        })
}