-
Notifications
You must be signed in to change notification settings - Fork 3
/
webRTCBench.html
560 lines (471 loc) · 17.6 KB
/
webRTCBench.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
<!DOCTYPE html>
<html lang="en">
<head>
<title> WebRTCBench 2.0</title>
<link rel="stylesheet" href="css/style.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<body>
<script language="javascript">
</script>
<h2 style = "text-align:center;"> WebRTCBench 2.0: A WebRTC Benchmark [<a href="WebRTCBenchGuide.html">go to the guide</a>]</h2>
<div id = "heading"><h2> Open or Join a WebRTC Connection </h2> </div>
<div id = "welcome" > </div>
<div id = "how-to-use">
<p> To connect to another client, select a session type from the dropdown and click open channel. Then, send your peer the number of the channel you created and tell them to join that channel with the same session type.
</div>
<div style="width:640;">
<div id="nametime" class="container" >
<h4> User Information </h4>
Nick name:
<input type = "text" id = "username" style="float: right" placeholder = "Enter Name Here" >
<br>
Time Stamp:
<input type="text" id="timestamp" value="timestamp" style="float: right">
<br>
<label>Session Type</label>
<select id = "session-type">
<option value="AV"> Video+Audio </option>
<option value="V"> Video </option>
<option value="A"> Audio </option>
<option value="D"> Data </option>
<option value="VD"> Video+Data </option>
<option value="AVD"> Video+Audio+Data </option>
<option value="BVS"> Unicast Send (V) </option>
<option value="BVR"> Unicast Receive (V) </option>
<!-- <option value="TS"> Time Offest Calc </option> -->
</select>
<br>
<input type="text" id="channelId" value="channel">
<br>
<button id="openChannel" style="float:left">Open Channel</button>
<button id="confirmConnection" style="float:right;clear:none"> Connect through Channel </button>
<button id="joinChannel" style="float:right;clear:none">Join Channel</button>
</div>
<div id="uainfo" class="container" >
<h4> User Agent Info </h4>
<label>Device Type</label>
<select id = "device">
<option> Mobile </option>
<option> Desktop </option>
</select>
<br>
<label>Processor</label>
<input type = "text" id = "processor" >
<br>
<label>OS</label>
<input type = "text" id = "operating-system">
<br>
<label>Browser</label>
<input type = "text" id = "browser" >
<br>
<label>Network Type</label>
<select id = "network-type" >
<option> LAN </option>
<option> WIFI </option>
<option> LTE </option>
<option> 4G </option>
</select>
</div>
<div id="settings" class="container">
<h4>Settings</h4>
<label>Verbose</label>
<input type="button" id="verboseButton" value="Yes" class="on" />
<br>
<label>Send Events</label>
<input type="button" id="sendButton" value="Yes" class="on" />
<br>
<label>Video Stats</label>
<input type="button" id="vStatsButton" value="Yes" class="on" />
<br>
<label>Data Stats</label>
<input type="button" id="dStatsButton" value="Yes" class="on" />
<br>
<br>
<button id="storeInfo" >Remember</button>
</div>
</div>
<div>
<div id = "media-constraints" class="dynamicContainer" style="clear:both">
<h4> Media Constraints/Controls </h4>
<input type="button" id="qvgaButton" value="QVGA" class="constraintsOff" />
<input type="button" id="vgaButton" value="VGA" class="constraintsOn" />
<input type="button" id="hdButton" value="HD" class="constraintsOff" />
<input type="button" id="fakeVideoButton" value="Fake" class="constraintsOff" />
<!-- <video id="wv" controls loop autoplay="true">
<source src="test.mp4" type="video/mp4" />
</video> -->
<br>
<br>
<input type="button" id="vp8Button" value="VP8" class="constraintsOn" />
<input type="button" id="vp9Button" value="VP9" class="constraintsOff" />
<input type="button" id="h264Button" value="H264" class="constraintsOff" />
</div>
<div id = "remote-" class="dynamicContainer">
<h4> Data Channel Constraints </h4>
<input type="button" id="dcOrderedButton" value="Reliable" class="constraintsOn" />
</div>
</div>
<div>
<div id = "local-streams" class="dynamicContainer" style="clear:both">
<h4> Local A/V Streams </h4>
</div>
<div id = "remote-streams" class="dynamicContainer">
<h4> Remote A/V Streams </h4>
</div>
<div id="chat" class="dynamicContainer">
<h4> Chat Area </h4>
<textarea id="chat-output" readonly style="width: 80%;min-height:100px;resize: none;"></textarea>
<br>
<input type="text" id="chat-input" placeholder="chat message" disabled style="width:80%;">
<input type="file" id="fileSelector" >
<button id="pingbtn" style="float:right">Ping</button>
<button id="sendbtn" style="float:right">Send</button>
</div>
</div>
<div style="clear: both">
<h2> Console Log </h2>
<textarea id = "console_log" readonly style="width: 100%; min-height:200px;resize: none"> </textarea>
<button id="console-clear" onclick = "clearConsole()"> Clear Console </button>
<button id="download-results" onclick = "download()"> Download Results </button>
<button id="download-analysis-data" onclick = "downloadVideoQualityData()"> Download Video Analysis Data </button>
</div>
<div>
Encoder BitRate
<canvas id="chartEncBitRate" width="400" height="200"></canvas>
</div>
<div>
Encoder Frame rate
<canvas id="chartEncFPS" width="400" height="200"></canvas>
</div>
<div>
Encodedd Video Resolution (pixels)
<canvas id="chartEncRes" width="400" height="200"></canvas>
</div>
<!-- FF->Chrome dec bitrate, framerate wont set properly -->
<div>
Decoder BitRate
<canvas id="chartDecBitRate" width="400" height="200"></canvas>
</div>
<div>
Decoder Frame rate
<canvas id="chartDecFPS" width="400" height="200"></canvas>
</div>
<div>
Decoded Video Resolution (pixels)
<canvas id="chartDecRes" width="400" height="200"></canvas>
</div>
<div>
<button id="quality-btn" onclick = "getQuality()">Image Quality (PSNR & SSIM)</button>
Frame:<input type = "text" id = "qnum" value = "1000000">
<canvas id="chartQuality" width="400" height="200"></canvas>
<canvas id="chartQuality2" width="400" height="200"></canvas>
<canvas id="chartQuality3" width="400" height="200"></canvas>
</div>
<div>
<button id="jitter-btn" onclick = "getJitter()">Jitter (miliseconds)</button>
Frame:<input type = "text" id = "jnum" value = "1000000">
Threshold:<input type = "text" id = "jthreshold" value = "1000">
<canvas id="chartJitter" width="400" height="200"></canvas>
</div>
<div>
<button id="latency-btn" onclick = "getLatency()">Latency (miliseconds)</button>
Frame:<input type = "text" id = "lnum" value = "1000000">
Threshold:<input type = "text" id = "lthreshold" value = "1000">
<canvas id="chartLatency" width="400" height="200"></canvas>
</div>
<!-- Note : This canvas is to store video data, do not touch! -->
<canvas id="data-canvas" width="640" height="480" hidden></canvas>
<script src="js/events.js"> </script>
<script src="js/Chart.js"> </script>
<script>
var peerConnection = null;
var channelId ;
var caller, callee;
var getAudio = false,
getVideo = false,
getData = false ; // for time synchronization
var receiveVideo = false,
receiveAudio = false;
var isCaller = false;
var sendEvents = false;
var videoStats = false ;
var dataStats = false;
var localStreams = [];
var localName;
var answer_offer_cration_time = 0 ;
var dataChannelOpened = false ;
var remoteStreamArrived = false ;
function get(id){
return document.getElementById(id);
}
function log (message){
var logArea = this.get("console_log");
logArea.value += "\n" + message ;
logArea.scrollTop = logArea.scrollHeight;
}
function download(){
var tempBlob = new Blob([dumpBlob], { type: 'octet/stream'});
if( detectedBrowser == "Chrome"){
tempUrl = window.webkitURL.createObjectURL(tempBlob);
window.location.assign(tempUrl);
} else{
tempUrl = window.URL.createObjectURL(tempBlob);
window.location.assign(tempUrl);
}
}
function clearConsole(){
var console = get("console_log");
if (console.firstChild)
console.value = "";
}
if (!Date.now) {
Date.now = function() { return new Date().getTime(); };
}
function populateAVD(){
var sessionType = get("session-type").value;
if (sessionType == "A" || sessionType == "AV" || sessionType == "AVD" ){
getAudio = true;
receiveAudio = true;
}
if (sessionType == "V" || sessionType == "AV" || sessionType == "VD"|| sessionType == "AVD" ){
getVideo = true;
receiveVideo = true;
}
if (sessionType == "D" || sessionType == "VD"|| sessionType == "AVD" || sessionType == "TS") getData = true;
if( sessionType == "BVS" ) getVideo = true ;
if( sessionType == "BVR" ) receiveVideo = true ;
}
</script>
<script src = "socket.io/socket.io.js"> </script>
<script src="js/adapter.js"> </script>
<script src="js/main.js"> </script>
<script src="js/jquery-2.1.4.min.js"></script>
<script>
initInputFields();
get('verboseButton').onclick = function (){
var item = get('verboseButton');
if(item.className == "on") {
item.className="off";
item.value = "No";
eventLogger.isVerbose = false ;
} else {
item.className="on";
item.value = "Yes";
eventLogger.isVerbose = true ;
}
};
get('sendButton').onclick = function (){
var item = get('sendButton');
if(item.className == "on") {
item.className="off";
item.value = "No";
sendEvents = false ;
} else {
item.className="on";
item.value = "Yes";
sendEvents = true ;
}
};
get('vStatsButton').onclick = function (){
var item = get('vStatsButton');
if(item.className == "on") {
item.className="off";
item.value = "No";
videoStats = false ;
} else {
item.className="on";
item.value = "Yes";
videoStats = true ;
}
};
get('dStatsButton').onclick = function (){
var item = get('dStatsButton');
if(item.className == "on") {
item.className="off";
item.value = "No";
dataStats = false ;
} else {
item.className="on";
item.value = "Yes";
dataStats = true ;
}
};
get('h264Button').onclick = function (){
var item = get('h264Button');
if(item.className == "constraintsOff") {
item.className="constraintsOn";
h264 = true ;
vp9 = false ;
get('vp8Button').className = "constraintsOff" ;
get('vp9Button').className = "constraintsOff" ;
}
};
get('vp8Button').onclick = function (){
var item = get('vp8Button');
if(item.className == "constraintsOff") {
item.className="constraintsOn";
h264 = false ;
vp9 = false ;
get('h264Button').className = "constraintsOff" ;
get('vp9Button').className = "constraintsOff" ;
}
};
get('vp9Button').onclick = function (){
var item = get('vp9Button');
if(item.className == "constraintsOff") {
item.className="constraintsOn";
h264 = false ;
vp9 = true ;
get('vp8Button').className = "constraintsOff" ;
get('h264Button').className = "constraintsOff" ;
}
};
get("vgaButton").onclick = function() {
var item = get('vgaButton');
if(item.className == "constraintsOff") {
item.className="constraintsOn";
VGA = true ;
HD = false ;
QVGA = false ;
get('qvgaButton').className = "constraintsOff" ;
get('hdButton').className = "constraintsOff" ;
}
};
get("qvgaButton").onclick = function() {
var item = get('qvgaButton');
if(item.className == "constraintsOff") {
item.className="constraintsOn";
HD = false ;
VGA = false ;
QVGA = true ;
get('vgaButton').className = "constraintsOff" ;
get('hdButton').className = "constraintsOff" ;
}
};
get("hdButton").onclick = function() {
var item = get('hdButton');
if(item.className == "constraintsOff") {
item.className="constraintsOn";
HD = true ;
VGA = false ;
QVGA = false ;
get('qvgaButton').className = "constraintsOff" ;
get('vgaButton').className = "constraintsOff" ;
}
};
get("fakeVideoButton").onclick = function() {
var item = get('fakeVideoButton');
if(item.className == "constraintsOn") {
item.className="constraintsOff";
mozFakeVideo = false ;
} else {
item.className="constraintsOn";
mozFakeVideo = true ;
}
};
get("dcOrderedButton").onclick = function() {
var item = get('dcOrderedButton');
if(item.className == "constraintsOn") {
item.className="constraintsOff";
dcOrdered = false ;
} else {
item.className="constraintsOn";
dcOrdered = true ;
}
};
get('channelId').value = (Math.round(Math.random()*5000));
get('timestamp').value = Date.now();
// DEALING WITH BUTTON UI
// On Opening Channel
get('openChannel').onclick = function () {
dataChannelOpened = false ;
remoteStreamArrived = false ;
caller = true;
callee = false;
get("how-to-use").style.display = "none";
var time1 = time();
populateAVD();
isCaller = true;
initConnection(isCaller);
get('joinChannel').disabled = true;
get('openChannel').disabled = true;
get('channelId').disabled = true;
get('heading').innerHTML = "<h2> "+ get("channelId").value + " is active </h2>"
//log("Initialized RTC Multi Connection in " + (time()-time1).toString() + "ms");
//eventLog(events.TIMING.Init_RTC_Multi_Connection, (time()-time1).toString());
setTimeout(function () {
senderInitVideoQualityMeasure();
}, 10000);
};
// On Storing information
get('storeInfo').onclick = function(){
localStorage.setItem('processor', get('processor').value);
localStorage.setItem('operating-system', get('operating-system').value);
localStorage.setItem('browser', get('browser').value);
localStorage.setItem('device' , get('device').selectedIndex);
localStorage.setItem('verbose', get('verboseButton').className == "on" );
localStorage.setItem('sendEvents' , get('sendButton').className == "on" );
localStorage.setItem('videoStats' , get('vStatsButton').className == "on" );
localStorage.setItem('dataStats' , get('dStatsButton').className == "on" );
log("Info stored at application cache");
}
// On Joining Channel
get('joinChannel').onclick = function () {
dataChannelOpened = false ;
remoteStreamArrived = false ;
callee = true;
caller = false;
get("how-to-use").style.display = "none";
populateAVD();
get('joinChannel').disabled = true;
get('openChannel').disabled = true;
var confirm = get('confirmConnection');
confirm.disabled = false;
confirm.style.display = "block";
initConnection(false)
};
// On Connecting through Channel
get('confirmConnection').onclick = function(){
if( !caller )
{
log("Sending Callee arrived at " + time().toString()) ;
signallingSocket.emit("message",JSON.stringify({
channel:get('channelId').value,
type: "callee_arrived"
})) ;
}
get('heading').innerHTML = "<h2> Connected through channel "+ get("channelId").value + "</h2>";
// log("Initialized RTC Multi Connection in " + (time3-time2).toString() + "ms");
//eventLog(events.TIMING.Init_RTC_Multi_Connection, (time3-time2).toString());
setTimeout(function () {
receiverInitVideoQualityMeasure();
}, 5000);
};
//DEALING WITH TEXT CHAT UI
function appendDIV(data) {
var chatOutput = get('chat-output');
chatOutput.value = data + "\n" + chatOutput.value ;
chatInput.focus();
}
function logError(error) {
console.log(error);
}
var chatInput = get('chat-input');
chatInput.onkeypress = function (e) {
if (e.keyCode !== 13 || !this.value) return;
var t1 = time();
if( this.value == "ping"){
dataChannel.send( this.value);
} else {
dataChannel.send(localName + ": " + this.value);
}
log("Sent Text at " + t1 );
appendDIV("Me" + ": " + this.value);
this.value = '';
this.focus();
};
</script>
<script src="js/stat.js"> </script>
</body>
</html>