forked from anantn/webrtc-landing
-
Notifications
You must be signed in to change notification settings - Fork 22
/
stun_test.html
44 lines (33 loc) · 1.05 KB
/
stun_test.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title> RTCPeerConnection STUN Gathering Test</title>
</head>
<body>
<h1> RTCPeerConnection STUN Gathering Test</h1>
<div id="log"></div>
<script type="application/javascript">
function log(msg) {
let div = document.getElementById("log");
div.innerHTML = div.innerHTML + "<p>" + msg + "</p>";
}
let pc1;
function failed(code) {
log("Failure callback: " + JSON.stringify(code));
}
var configuration = { "iceServers": [{ "urls": ["stun:stun.l.google.com:19302" ]}]};
pc1 = new RTCPeerConnection(configuration);
pc1.onicecandidate = function(c) {
log("ICE candidate: " + JSON.stringify(c.candidate));
};
navigator.mozGetUserMedia({video:true, fake:true},
function(stream) {
pc1.addStream(stream);
pc1.createOffer(function(offer) {
log("Created offer: " + offer.sdp.replace(/[\n]/g, '<br>'));
pc1.setLocalDescription(offer, function() {}, failed);
},
failed
)
},
failed);
</script>