mpromonet / webrtc-streamer

WebRTC streamer for V4L2 capture devices, RTSP sources and Screen Capture
https://webrtcstreamer.agreeabletree-365b9a90.canadacentral.azurecontainerapps.io/?layout=2x2
The Unlicense
2.94k stars 598 forks source link

About using stun server #527

Closed Wa1tN closed 2 years ago

Wa1tN commented 2 years ago

Hi,mpromonet! Sorry to interupt!I have a client A and a webrtc streamer server B(in different LANs). I want to connect them P2P through a stun server with a public IP, but I am not sure what to do. The following is my HTML client code and webrtc streamer startup command.

<html>
<head>
<script src="libs/adapter.min.js" ></script>
<script src="webrtcstreamer.js" ></script>
<script>        
    var webRtcServer      = null;
    window.onload         = function() { 
        webRtcServer      = new WebRtcStreamer("video",webrtc-streamer-serverIP+":8000")
        webRtcServer.connect("rtsp://LAN_IP");
    }
    window.onbeforeunload = function() { webRtcServer.disconnect(); }
</script>
</head>
<body> 
    <video id="video" />
</body>
</html>
./webrtc-streamer -sSTUN-SERVER_IP:3478

Can you teach me how to achieve it? Thank you very much Best Regards, WaitN

mpromonet commented 2 years ago

Hi,

I guess you are in right direction, using public IP of stun server given to -s argument. This value is used by both peer webbrowser and webrtc-server. You can check the ICE configuration calling /api/getIceServers.

Best regards Michel

Wa1tN commented 2 years ago

I'm sorry I replied so late. I'm learning about webrtc these days, I also read your webrtcstreamer.js source code, I found that webrtcstreamer has realized P2P connection automatically through stun. I am a novice in webrtc. I have learned a lot from your project. Thank you very much.