-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
127 lines (100 loc) · 3.5 KB
/
index.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
<html>
<head>
<meta charset="utf-8">
<title>CMAF Load Test Tool</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="http://cdn.dashjs.org/latest/dash.all.min.js"></script>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-lg-6 mx-auto mb-4">
<div class="section-title text-center ">
<h3 class="top-c-sep">
CMAF Load Test Tool
</h3>
<p>Please fill below blanks</p>
<div class="form-row">
<div class="form-group col-md-6">
<label for="playerCount" class="col-form-label">Concurrent player</label>
<input value="10" type="number" name="playerCount" class="form-control" id="playerCount">
</div>
<div class="form-group col-md-6">
<label for="duration" class="col-form-label">Load test duration</label>
<input value="10" type="number" class="form-control" name="duration" id="duration">
</div>
</div>
<div class="mb-3 row form-group">
<label for="dashURL" class="col-sm-3 col-form-label">CMAF URL:</label>
<div class="col-sm-9"><input value="https://livesim.dashif.org/livesim/chunkdur_1/ato_7/testpic4_8s/Manifest300.mpd" type="text" name="dashURL" id="dashURL" class="form-control"></div>
</div>
<button type="submit" class="btn btn-primary" id="startButton" onclick="startLoadTest()">Start Load Test!</button>
<h4 id="loadTestStatus"></h4>
</div>
</div>
</div>
</div>
<style type="text/css">
body{
background:#f5f5f5;
margin-top:20px;}
#loadTestStatus{
margin-top: 10px;
}
</style>
<script>
let seconds = 0;
var incrementInterval;
var duration;
var url;
var loadStatusText = document.getElementById("loadTestStatus");
var startButton = document.getElementById("startButton");
function incrementSeconds() {
seconds += 1;
console.log("seconds: " + seconds + " duration: " + duration);
if(seconds >= duration){
clearInterval(incrementInterval);
var videoList = document.getElementsByTagName("video");
for(video of videoList){
video.pause();
video.src="";
video.currentTime = 0;
}
startButton.disabled = false;
loadStatusText.innerHTML = "Load test is done!";
console.log("CMAF load test is done!");
}
}
function createVideoElement(i){
var video = document.createElement('video');
duration = document.getElementById("duration").value;
url = document.getElementById("dashURL").value;
var element = dashjs.MediaPlayer().create();
element.updateSettings({
'streaming': { 'lowLatencyEnabled': true },
'debug': {
'logLevel': dashjs.Debug.LOG_LEVEL_NONE }
});
element.initialize(video, url, true);
element.setMute(true);
element.play();
video.setAttribute("preload", "none");
video.style.cssText = 'display:none;';
document.body.appendChild(video);
}
function startLoadTest(){
startButton.disabled = true;
loadStatusText.innerHTML = "Load test is started!";
seconds = 0;
var playerCount = document.getElementById("playerCount").value;
var duration = document.getElementById("duration").value;
console.log("playerCount: " + playerCount + " duration: " + duration);
for(let i = 0; i < playerCount; i++ ){
createVideoElement(i);
}
incrementInterval = setInterval(incrementSeconds, 1000);
}
</script>
</body>
</html>