-
Notifications
You must be signed in to change notification settings - Fork 5
/
low-latency-playback-over-gaps.html
executable file
·145 lines (135 loc) · 5.24 KB
/
low-latency-playback-over-gaps.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Low-Latency: Playback over Gaps</title>
<link rel="stylesheet" href="../lib/style.css" />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="content-wrapper">
<div id="video-wrapper">
<video></video>
<div><div id="qr-code"></div></div>
<div><div id="status-text"></div></div>
</div>
<div>To show/hide debug overlay press up/down or button beneath</div>
<div id="debug-wrapper">
<div>
<div class="button" id="debug-button">Debug Overlay</div>
</div>
<div id="debug"></div>
<div id="log"></div>
</div>
</div>
<div id="info-overlay"></div>
<script src="../lib/mozilla/object-keys-polyfill.js"></script>
<script src="../lib/stefanpenner/es6-promise.min.js"></script>
<script src="../lib/player.js"></script>
<script src="../lib/manifest_parser.js"></script>
<script src="../lib/mpd-parser.js"></script>
<script src="../lib/wave-service.js"></script>
<script src="../lib/davidshimjs/qrcode.js"></script>
<script src="../lib/dpctf-testharness.js"></script>
<script src="../lib/hbbtv.js"></script>
<script>
// Global variables
var TEST_INFO = {
id: "low-latency-playback-over-gaps",
title: "Low-Latency: Playback over Gaps",
description: "",
code: "{{TEMPLATE_NAME}}",
};
var video = document.querySelector("video");
var qrCode = document.getElementById("qr-code");
var statusText = document.getElementById("status-text");
var videoContentModel = "{{VIDEO_MPD_URL}}";
var audioContentModel = "{{AUDIO_MPD_URL}}";
var dpctfTest = new DpctfTest({
testInfo: TEST_INFO,
videoContentModel: videoContentModel,
audioContentModel: audioContentModel,
videoElement: video,
qrCodeElement: qrCode,
statusTextElement: statusText,
infoOverlayElement: document.getElementById("info-overlay"),
executeTest: executeTest,
setupTest: setupTest,
usePlayout: false,
});
function setupTest(player, done, parameters) {
var firstSegment = player.getVideoSegments()[0];
var segmentDuration = firstSegment.getDuration();
var chunks = firstSegment.getChunks();
var chunkDuration = segmentDuration / chunks.length;
if (chunks.length === 0) chunkDuration = segmentDuration;
var minBufferDuration = parameters.minBufferDuration;
var maxBufferDuration = parameters.maxBufferDuration;
var gapDuration = parameters.gapDuration || segmentDuration * 1000;
var gapStart = segmentDuration;
if (gapStart > minBufferDuration) gapStart = minBufferDuration;
if (gapStart < chunkDuration) gapStart = chunkDuration;
dpctfTest.setMinBufferDuration(maxBufferDuration);
dpctfTest.setGap(gapStart, gapDuration);
done();
}
function executeTest(player, done, parameters) {
var logger = dpctfTest.getLogger();
var minBufferDuration = parameters.minBufferDuration / 1000;
player.startBuffering();
dpctfTest.asyncTest(function (test) {
var query = location.search.replace(/\?/, "");
var match = query.match(/redirect_time=([^&]+)/);
var REDIRECT_TIME = match ? match[1] : null;
if (!REDIRECT_TIME) REDIRECT_TIME = 5;
video.addEventListener("ended", function (event) {
assert_true(true);
test.done();
});
}, "video ended event fired");
dpctfTest.asyncTest(function (test) {
function onPlayerWaiting() {
logger.log("play position reached gap");
var playbackMode = parameters.playbackMode;
var gapDuration = parameters.gapDuration;
var waitingDuration = 0;
if (playbackMode === dpctfTest.PLAYBACK_MODE_LIVE) {
waitingDuration = gapDuration;
}
video.addEventListener("playing", onPlayerPlaying);
logger.log(
"playback mode: " +
playbackMode +
", waiting " +
waitingDuration +
"ms"
);
setTimeout(function () {
video.removeEventListener("waiting", onPlayerWaiting);
logger.log("seeking to end of gap");
player.setCurrentTime(video.buffered.start(1));
test.step(function () {
assert_true(true);
});
done();
test.done();
}, waitingDuration);
}
function onPlayerPlaying() {
video.removeEventListener("waiting", onPlayerWaiting);
test.step(function () {
assert_true(false);
});
logger.log("video started playing early");
test.done();
done();
}
player.playOnBufferLoaded(minBufferDuration).then(function () {
video.addEventListener("waiting", onPlayerWaiting);
});
}, "video remains in waiting state until skipping over the gap");
}
</script>
</body>
</html>