-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEstimate.php
executable file
·437 lines (392 loc) · 20 KB
/
Estimate.php
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
<!DOCTYPE html>
<!-- This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8" />
<meta name="description" content="DASH Conformance">
<meta name="keywords" content="DASH,DASH Conformance,DASH Validator">
<meta name="author" content="Nomor Research GmbH">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.0/themes/smoothness/jquery-ui.css" />
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.0/jquery-ui.min.js"></script>
<link rel="STYLESHEET" type="text/css" href="tree/dhtmlxTree/codebase/dhtmlxtree.css">
<script type="text/javascript" src="tree/dhtmlxTree/codebase/dhtmlxcommon.js"></script>
<script type="text/javascript" src="tree/dhtmlxTree/codebase/dhtmlxtree.js"></script>
<script type="text/javascript" src="tree/dhtmlxTree/codebase/ext/dhtmlxtree_json.js"></script>
<style>
html,body
{
background-color: #fff;
background-size: 100% 1.2em;
}
/* The container */
.container
{
position: relative;
padding-left: 35px;
margin-bottom: 12px;
cursor: pointer;
font-size: 20px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
font-family: Avantgarde, TeX Gyre Adventor, URW Gothic L, sans-serif;
}
/* Hide the browser's default radio button */
.container input
{
position: absolute;
opacity: 0;
cursor: pointer;
}
/* Create a custom radio button */
.checkmark
{
position: absolute;
top: 0;
left: 0;
height: 25px;
width: 25px;
background-color: #eee;
border-radius: 50%;
}
/* On mouse-over, add a grey background color */
.container:hover input ~ .checkmark
{
background-color: #ccc;
}
/* When the radio button is checked, add a blue background */
.container input:checked ~ .checkmark
{
background-color: #2196F3;
}
/* Create the indicator (the dot/circle - hidden when not checked) */
.checkmark:after
{
content: "";
position: absolute;
display: none;
}
/* Show the indicator (dot/circle) when checked */
.container input:checked ~ .checkmark:after
{
display: block;
}
/* Style the indicator (dot/circle) */
.container .checkmark:after
{
top: 9px;
left: 9px;
width: 8px;
height: 8px;
border-radius: 50%;
background: white;
}
/*for the button*/
.button
{
display: inline-block;
padding: 10px 20px;
font-size: 18px;
cursor: pointer;
text-align: center;
text-decoration: none;
outline: none;
color: #fff;
background-color: #4CAF50;
border: none;
border-radius: 15px;
box-shadow: 0 9px #999;
}
.button:hover
{
background-color: #3e8e41;
}
.button:active
{
background-color: #3e8e41;
box-shadow: 0 5px #666;
transform: translateY(4px);
}
/*.button:disabled {
background-color: #3e7e41;
box-shadow: 0 5px #666;
}*/
/*for the forms*/
.input
{
position:absolute;
left: 230px;
}
input[type=text]:enabled
{
border-radius: 8px;
}
input[type=text]:disabled
{
border-radius: 8px;
}
.content
{
height: 550px;
width:550px;
position: absolute;
left: 35%;
top:25%;
}
.title
{
font-family: Avantgarde, TeX Gyre Adventor, URW Gothic L, sans-serif;
font-size:24px;
font-weight:bold;
font-style:normal;
}
.center
{
position: relative;
top:33%;
left: 13%;
}
</style>
</head>
<body>
<div class="content">
<div class="center">
<label class="title">Choose a parameter to estimate:</label>
<br><br>
<label class="container">
<input type="radio" id="MinBufferTime" value="MinBufferTime" name="radio" required>MinBufferTime
<span class="checkmark"></span>
</label>
<input type="text" class="input" id="field1" name="field1">(sec)
<br><br>
<label class="container">Bandwidth
<input type="radio" name="radio" checked="true" id ="Bandwidth" value ="Bandwidth">
<span class="checkmark"></span>
</label>
<input class="input" type="text" id="field2" name="field2">(bit/s)
<br><br>
<button class="button" id="BTN" >Estimate</button>
</div>
</div>
<?php
$locate = $_REQUEST['location'];
?>
<script>
$(document).ready(function ()
{
function checkradiobox()
{
var radio = $("input[name='radio']:checked").val();
$('#field1, #field2').attr('disabled',true);
if(radio == "MinBufferTime")
{
$('#field1').attr('disabled',false);
$("#field1").focus(function() {$( this ).css( "display", "inline" );});
}
else if(radio == "Bandwidth")
{
$('#field2').attr('disabled',false);
$("#field2").focus(function() {$( this ).css( "display", "inline" );});
}
}
$("#MinBufferTime, #Bandwidth").change(function () {checkradiobox();});
checkradiobox();
function loadXMLDoc(dname)
{
if (window.XMLHttpRequest)
{
xhttp=new XMLHttpRequest();
}
else
{
xhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp.open("GET",dname,false);
xhttp.send("");
return xhttp.responseXML;
}
var location = "<?php echo $locate ?>";
var Sample_data = loadXMLDoc(location);
if (Sample_data !== null)
{
var BW, MBT;
BW = parseFloat(Sample_data.getElementsByTagName("MPDInfo").item(0).getAttribute("bandwidth"));
MBT = parseFloat(Sample_data.getElementsByTagName("MPDInfo").item(0).getAttribute("minBufferTime"));
}
document.getElementById("field1").placeholder = MBT;
document.getElementById("field2").placeholder = BW;
function ProcessSampleData(Sample_data, MBT, BW)
{
document.getElementById("field1").placeholder = MBT;
document.getElementById("field2").placeholder = BW;
if (Sample_data !== null)
{
var bandwidth, minBufferTime, timescale, initSize, announcedSAP, dataSizeToRemove, duration; // to be read from the xml file
bandwidth = BW;
minBufferTime = MBT;
initSize = parseFloat(Sample_data.getElementsByTagName("Representation").item(0).getAttribute("initSize"));
timescale = parseFloat(Sample_data.getElementsByTagName("Representation").item(0).getAttribute("timescale"));
var trackNonConforming = false;
var currentBandwidth = bandwidth;
var increment_factor = 2;
var decrement_factor = 0.75;
var upper_bound = 0;
var lower_bound = 0;
var done = false;
var mod_val = 0;
var bufferFullness, lastOffset, timeNowInTicks, totalDataRemoved, totalBitsAdded; //get moofCount from counting the number of instances with annauncedSAP attribute
var radio = $("input[name='radio']:checked").val();
do
{
bufferFullness = currentBandwidth * minBufferTime; //bits (not Bytes)
lastOffset = initSize;
timeNowInTicks = minBufferTime * timescale;
totalDataRemoved = 0;
totalBitsAdded = 0;
trackNonConforming = false;
for(var moof_index = 0; moof_index < Sample_data.getElementsByTagName("moof").length; moof_index ++)
{
var moof = Sample_data.getElementsByTagName("moof").item(moof_index);
announcedSAP = moof.getAttribute("a");
if (announcedSAP && bufferFullness > currentBandwidth * minBufferTime) //There is no buffer overflow for DASH buffer model, only case is on a SAP, as DASH spec. defines the requiremnt that the playback could be from any SAP and at the SAP, the buffer fullness is bandwidth*minBufferTime
{
totalDataRemoved += ((bufferFullness - currentBandwidth * minBufferTime) / 8.0); //The clipped data, for debug information
bufferFullness = currentBandwidth * minBufferTime;
}
for(var traf_index = 0; traf_index < moof.getElementsByTagName("traf").length; traf_index ++)
{
var traf = moof.getElementsByTagName("traf").item(traf_index);
for(var trun_index = 0; trun_index < traf.getElementsByTagName("trun").length; trun_index ++)
{
var trun = traf.getElementsByTagName("trun").item(trun_index);
for(var sample_index = 0; sample_index < trun.getElementsByTagName("s").length; sample_index ++)
{
var sample = trun.getElementsByTagName("s").item(sample_index);
dataSizeToRemove = parseFloat(sample.getAttribute("z"));
duration = parseFloat(sample.getAttribute("d"));
totalDataRemoved += dataSizeToRemove;
if ((dataSizeToRemove * 8) > bufferFullness) //Bufferfullness is in bits
{
if (!trackNonConforming)
{
//if (currentBandwidth == bandwidth)
//console.log("Buffer underrun conformance error: first (and only one reported here) for sample ", sample_index + 1," of run ", trun_index + 1, " of track fragment ", traf_index + 1, " of fragment ", moof_index + 1, ", bandwidth: ", currentBandwidth);
trackNonConforming = true;
break;
}
}
bufferFullness -= (dataSizeToRemove * 8);
bufferFullness += (currentBandwidth * ( duration / timescale));
totalBitsAdded += (currentBandwidth * (duration / timescale));
timeNowInTicks += duration;
}
if (trackNonConforming) break;
}
if (trackNonConforming) break;
}
if (trackNonConforming) break;
}
if(radio == "Bandwidth")
{
if (trackNonConforming) // not passing with the current value
{
if(upper_bound == 0) // if it has yet to pass for the first time then increment
currentBandwidth *= increment_factor;
else // it has already passed once and the upper bound was assigned so it goes here for first time when we find the lower bound
{
if(lower_bound == 0) // first time it doesn't pass after it has passed at least once so we can assign lower bound now
{
lower_bound = currentBandwidth;
mod_val = upper_bound - lower_bound;
}
mod_val /= 2;
currentBandwidth += mod_val; // to be eleborated more
}
}
else // passing with the current value
{
if((lower_bound != 0) && (mod_val <= 50))
done = true;
if (currentBandwidth == bandwidth)
done = true;
else
{
if(upper_bound == 0) // assign only the first time the condition is fulfilled
upper_bound = currentBandwidth;
if(mod_val == 0)
currentBandwidth *= decrement_factor;
else if(done != true)
{
mod_val /= 2;
currentBandwidth -= mod_val;
}
}
}
}
else if(radio == "MinBufferTime")
{
if (trackNonConforming) // not passing with the current value
{
if(upper_bound == 0) // if it has yet to pass for the first time then increment
minBufferTime *= increment_factor;
else // it has already passed once and the upper bound was assigned so it goes here for first time when we find the lower bound
{
if(lower_bound == 0) // first time it doesn't pass after it has passed at least once so we can assign lower bound now
{
lower_bound = minBufferTime;
mod_val = upper_bound - lower_bound;
}
mod_val /= 2;
minBufferTime += mod_val; // to be eleborated more
}
}
else // passing with the current value
{
if((lower_bound != 0) && (mod_val <= 0.1))
done = true;
if (minBufferTime == MBT)
done = true;
else
{
if(upper_bound == 0) // assign only the first time the condition is fulfilled
upper_bound = minBufferTime;
if(mod_val == 0)
minBufferTime *= decrement_factor;
else if(done != true)
{
mod_val /= 2;
minBufferTime -= mod_val;
}
}
}
}
}
while (!done);
if(currentBandwidth != bandwidth)
document.getElementById("field2").placeholder = Math.ceil(currentBandwidth);
else if(minBufferTime != MBT)
document.getElementById("field1").placeholder = minBufferTime.toFixed(4);
else
alert("No Buffer underrun conformance error detected!")
}
}
document.getElementById("BTN").onclick = function() {ProcessSampleData(Sample_data, MBT, BW)};
});
</script>
</body>
</html>