├── .gitignore ├── .travis.yml ├── README.md ├── dist ├── dashvalidator.js └── dashvalidator.min.js ├── docs ├── fonts │ ├── OpenSans-Bold-webfont.eot │ ├── OpenSans-Bold-webfont.svg │ ├── OpenSans-Bold-webfont.woff │ ├── OpenSans-BoldItalic-webfont.eot │ ├── OpenSans-BoldItalic-webfont.svg │ ├── OpenSans-BoldItalic-webfont.woff │ ├── OpenSans-Italic-webfont.eot │ ├── OpenSans-Italic-webfont.svg │ ├── OpenSans-Italic-webfont.woff │ ├── OpenSans-Light-webfont.eot │ ├── OpenSans-Light-webfont.svg │ ├── OpenSans-Light-webfont.woff │ ├── OpenSans-LightItalic-webfont.eot │ ├── OpenSans-LightItalic-webfont.svg │ ├── OpenSans-LightItalic-webfont.woff │ ├── OpenSans-Regular-webfont.eot │ ├── OpenSans-Regular-webfont.svg │ ├── OpenSans-Regular-webfont.woff │ ├── OpenSans-Semibold-webfont.eot │ ├── OpenSans-Semibold-webfont.svg │ ├── OpenSans-Semibold-webfont.ttf │ ├── OpenSans-Semibold-webfont.woff │ ├── OpenSans-SemiboldItalic-webfont.eot │ ├── OpenSans-SemiboldItalic-webfont.svg │ ├── OpenSans-SemiboldItalic-webfont.ttf │ └── OpenSans-SemiboldItalic-webfont.woff ├── index.html ├── index.js.html ├── module-dash-validator-DashValidator.html ├── module-dash-validator.html ├── scripts │ ├── linenumber.js │ └── prettify │ │ ├── Apache-License-2.0.txt │ │ ├── lang-css.js │ │ └── prettify.js └── styles │ ├── jsdoc-default.css │ ├── prettify-jsdoc.css │ └── prettify-tomorrow.css ├── example.js ├── global_exports.js ├── index.js ├── jsdoc.conf.json ├── karma.conf.js ├── lib ├── dash_manifest.js ├── dash_parser.js ├── dash_representation.js ├── dash_segmentlist.js ├── dash_validator_runner.js └── util.js ├── package.json └── test ├── dash_validator_unit.js ├── lib ├── dash_manifest_unit.js ├── dash_parser_unit.js ├── dash_representation_unit.js ├── dash_segmentlist_unit.js ├── dash_validator_runner_unit.js └── util_unit.js └── support ├── testassets.js └── testassets ├── dynamic.1.mpd ├── dynamic.2.mpd ├── dynamic.3.mpd ├── usp.live.mpd └── usp.vod.mpd /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | *.swp 3 | .vscode/ 4 | coverage/ 5 | .coveralls.yml 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: required 2 | dist: trusty 3 | language: node_js 4 | node_js: 5 | - '6' 6 | before_script: 7 | - export CHROME_BIN=/usr/bin/google-chrome 8 | - export DISPLAY=:99.0 9 | - sh -e /etc/init.d/xvfb start 10 | - sudo apt-get update 11 | - sudo apt-get install -y libappindicator1 fonts-liberation 12 | - wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb 13 | - sudo dpkg -i google-chrome*.deb 14 | after_success: 15 | - npm run coveralls 16 | deploy: 17 | provider: npm 18 | email: jonas.birme@eyevinn.se 19 | api_key: 20 | secure: CYbY7E+a3eJpwk7b/XtkCNe3zFUSMZZdeS6ssM8y39gfi+FLZHsB9AwqUsU/F3ZrpWea1nmmhgKooa9c3Vn3+s804rvM69FK5ajYRR7IPEEmDC5WXqwyVaEf3E2qO6PoSnzKGAgv9CgYc3R2CUhg+0HzVQjNcCxsmeVYJpt2yzZVXydzKSeH4m9XlozzEisU6pKyNsILmxvumBnbXSAsTC866mcwKqZrKxL3S60/Q9MDO1EFLhwqV1pmCq54wvgRxQIj9SJPKB//FW3PH/EVs5r8BGhMDi5pzsIczrLnHwJvw1I1Bmk53Ba0J69xGcn9i4V2JrfIAb+5s3tFS8nDSXKyPQqDtx/ux1EilOfP3ZjS3Md3cQGPcJ7BIyzD9RVC+2cGJh95H7CFOhp8MivYIr4dvrvfB6n0jp/CAfxYf39F4PxTTJOKLTP+nMfWSFsB8A0DRQdKfskQP7pa6YdjAp+49YKbK9CVEsI1HV3Jjfy+YURqgJnuVGgSfOUwcG6CJshB7I9FCy2JIHfsxquKPHRgBAr5Qg5HFBTeBtwz/IywoaOfdSPMYLSv15coLXa2hSVSQBdgLoiN78NUVAh9gR8pzF4v0TQrxgj1r7kbBwD/rgWwwoo8SO/cOgQ2S0fQuKapzRFh+0nxOIKfRf161rRVepHRmOD6/HQtqy7B0CM= 21 | on: 22 | tags: true 23 | repo: Eyevinn/dash-validator-js 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/Eyevinn/dash-validator-js.svg?branch=master)](https://travis-ci.org/Eyevinn/dash-validator-js) 2 | [![Coverage Status](https://coveralls.io/repos/github/Eyevinn/dash-validator-js/badge.svg)](https://coveralls.io/github/Eyevinn/dash-validator-js) 3 | 4 | A Javascript library to validate content with the MPEG DASH streaming format 5 | 6 | ## Usage (Node JS) 7 | 8 | ``` 9 | npm install --save dash-validator 10 | ``` 11 | 12 | Example implementation: 13 | 14 | ``` 15 | const DashValidator = require("dash-validator"); 16 | 17 | const validator = new DashValidator("http://example.com/test.mpd"); 18 | validator.load().then(() => { 19 | console.log("Loaded manifest"); 20 | console.log(validator.duration()); 21 | validator.verifyAllSegments(verifyFn).then(result => { 22 | console.log(result); 23 | }); 24 | }).catch(console.error); 25 | 26 | function verifyFn(headers) { 27 | return (typeof headers["x-my-custom-header"] !== "undefined"); 28 | } 29 | ``` 30 | 31 | To verify dynamically updating manifests: 32 | 33 | ``` 34 | validator.load().then(() => { 35 | validator.validateDynamicManifest(5).then((result) => { 36 | console.log(result); 37 | }); 38 | validator.on("invalidplayhead", (data) => { 39 | console.log(data); 40 | }); 41 | validator.on("checking", data => { 42 | const mpd = data.mpd; 43 | const headers = data.headers; 44 | console.log("Playhead: " + new Date(mpd.timeAtHead)); 45 | }); 46 | }); 47 | ``` 48 | 49 | ## Usage (Browser) 50 | 51 | ``` 52 | 53 | 64 | ``` 65 | -------------------------------------------------------------------------------- /docs/fonts/OpenSans-Bold-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eyevinn/dash-validator-js/aeb4c4f128313650338b22b4ffcd2a9677123c59/docs/fonts/OpenSans-Bold-webfont.eot -------------------------------------------------------------------------------- /docs/fonts/OpenSans-Bold-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eyevinn/dash-validator-js/aeb4c4f128313650338b22b4ffcd2a9677123c59/docs/fonts/OpenSans-Bold-webfont.woff -------------------------------------------------------------------------------- /docs/fonts/OpenSans-BoldItalic-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eyevinn/dash-validator-js/aeb4c4f128313650338b22b4ffcd2a9677123c59/docs/fonts/OpenSans-BoldItalic-webfont.eot -------------------------------------------------------------------------------- /docs/fonts/OpenSans-BoldItalic-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eyevinn/dash-validator-js/aeb4c4f128313650338b22b4ffcd2a9677123c59/docs/fonts/OpenSans-BoldItalic-webfont.woff -------------------------------------------------------------------------------- /docs/fonts/OpenSans-Italic-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eyevinn/dash-validator-js/aeb4c4f128313650338b22b4ffcd2a9677123c59/docs/fonts/OpenSans-Italic-webfont.eot -------------------------------------------------------------------------------- /docs/fonts/OpenSans-Italic-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eyevinn/dash-validator-js/aeb4c4f128313650338b22b4ffcd2a9677123c59/docs/fonts/OpenSans-Italic-webfont.woff -------------------------------------------------------------------------------- /docs/fonts/OpenSans-Light-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eyevinn/dash-validator-js/aeb4c4f128313650338b22b4ffcd2a9677123c59/docs/fonts/OpenSans-Light-webfont.eot -------------------------------------------------------------------------------- /docs/fonts/OpenSans-Light-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eyevinn/dash-validator-js/aeb4c4f128313650338b22b4ffcd2a9677123c59/docs/fonts/OpenSans-Light-webfont.woff -------------------------------------------------------------------------------- /docs/fonts/OpenSans-LightItalic-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eyevinn/dash-validator-js/aeb4c4f128313650338b22b4ffcd2a9677123c59/docs/fonts/OpenSans-LightItalic-webfont.eot -------------------------------------------------------------------------------- /docs/fonts/OpenSans-LightItalic-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eyevinn/dash-validator-js/aeb4c4f128313650338b22b4ffcd2a9677123c59/docs/fonts/OpenSans-LightItalic-webfont.woff -------------------------------------------------------------------------------- /docs/fonts/OpenSans-Regular-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eyevinn/dash-validator-js/aeb4c4f128313650338b22b4ffcd2a9677123c59/docs/fonts/OpenSans-Regular-webfont.eot -------------------------------------------------------------------------------- /docs/fonts/OpenSans-Regular-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eyevinn/dash-validator-js/aeb4c4f128313650338b22b4ffcd2a9677123c59/docs/fonts/OpenSans-Regular-webfont.woff -------------------------------------------------------------------------------- /docs/fonts/OpenSans-Semibold-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eyevinn/dash-validator-js/aeb4c4f128313650338b22b4ffcd2a9677123c59/docs/fonts/OpenSans-Semibold-webfont.eot -------------------------------------------------------------------------------- /docs/fonts/OpenSans-Semibold-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eyevinn/dash-validator-js/aeb4c4f128313650338b22b4ffcd2a9677123c59/docs/fonts/OpenSans-Semibold-webfont.ttf -------------------------------------------------------------------------------- /docs/fonts/OpenSans-Semibold-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eyevinn/dash-validator-js/aeb4c4f128313650338b22b4ffcd2a9677123c59/docs/fonts/OpenSans-Semibold-webfont.woff -------------------------------------------------------------------------------- /docs/fonts/OpenSans-SemiboldItalic-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eyevinn/dash-validator-js/aeb4c4f128313650338b22b4ffcd2a9677123c59/docs/fonts/OpenSans-SemiboldItalic-webfont.eot -------------------------------------------------------------------------------- /docs/fonts/OpenSans-SemiboldItalic-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eyevinn/dash-validator-js/aeb4c4f128313650338b22b4ffcd2a9677123c59/docs/fonts/OpenSans-SemiboldItalic-webfont.ttf -------------------------------------------------------------------------------- /docs/fonts/OpenSans-SemiboldItalic-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Eyevinn/dash-validator-js/aeb4c4f128313650338b22b4ffcd2a9677123c59/docs/fonts/OpenSans-SemiboldItalic-webfont.woff -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Home - Documentation 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 22 | 23 | 24 | 25 | 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 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /docs/index.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | index.js - Documentation 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 22 | 23 | 24 | 25 | 28 | 29 |
30 | 31 |

index.js

32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
40 |
41 |
// Copyright 2016 Eyevinn Technology. All rights reserved
 42 | // Use of this source code is governed by a MIT License
 43 | // license that can be found in the LICENSE file.
 44 | // Author: Jonas Birme (Eyevinn Technology)
 45 | const DashParser = require("./lib/dash_parser.js");
 46 | const DashValidatorRunner = require("./lib/dash_validator_runner.js");
 47 | const util = require("./lib/util.js");
 48 | 
 49 | /**
 50 |  * MPEG DASH Validator
 51 |  * 
 52 |  * A Javascript library that can be used to validate MPEG DASH streams (VOD and Live).
 53 |  * Source available on {@link https://github.com/Eyevinn/dash-validator-js GitHub}
 54 |  * 
 55 |  * @module dash-validator
 56 |  */
 57 | 
 58 | /**
 59 |  * Creates a new Dash Validator object
 60 |  * @constructor
 61 |  * 
 62 |  * @param {string} src URI to MPEG DASH manifest, e.g. http://example.com/example.mpd
 63 |  * @returns {DashValidator}
 64 |  */
 65 | const DashValidator = function constructor(src) {
 66 |   this._src = src;
 67 |   this._manifest;
 68 |   this._base = "";
 69 |   this._manifestHeaders;
 70 |   this._runner;
 71 | };
 72 | 
 73 | /**
 74 |  * Download and parses MPEG DASH manifest
 75 |  * 
 76 |  * @returns {Promise} a Promise that resolves when the manifest is downloaded and parsed. 
 77 |  */
 78 | DashValidator.prototype.load = function load() {
 79 |   return new Promise((resolve, reject) => {
 80 |     this._base = util.getBaseUrl(this._src) + "/";
 81 |     util.requestXml(this._src).then(resp => {
 82 |       this._manifestHeaders = resp.headers;
 83 | 
 84 |       const parser = new DashParser();
 85 |       parser.parse(resp.xml).then((manifest) => {
 86 |         this._manifest = manifest;
 87 |         this._runner = new DashValidatorRunner(this._manifest, this._manifestHeaders, 10);
 88 |         resolve();
 89 |       }).catch(reject);
 90 |     }).catch(reject);
 91 |   });
 92 | };
 93 | 
 94 | /**
 95 |  * @typedef FailedInfo
 96 |  * @type {Object}
 97 |  * @property {string} uri URI to the segment that failed
 98 |  * @property {Object} headers The actual HTTP response headers 
 99 |  */
100 | 
101 | /**
102 |  * @typedef SuccessInfo
103 |  * @type {Object}
104 |  * @property {string} uri URI to the successful segment
105 |  */
106 | 
107 | /**
108 |  * @typedef SegmentVerifyResult
109 |  * @type {Object}
110 |  * @property {Array.<FailedInfo>} failed An array of all segments that failed
111 |  * @property {Array.<SuccessInfo>} ok An array of all segments that were ok
112 |  */
113 | 
114 | /**
115 |  * @typedef ManifestVerifyResult
116 |  * @type {Object}
117 |  * @property {boolean} ok True if successful
118 |  * @property {Object} headers The response headers for the manifest request.
119 |  */
120 | 
121 | /**
122 |  * Verifies that the timestamp of the last segment for a MPEG DASH live-stream
123 |  * does not differ more than 10 seconds (default) from actual time.
124 |  * 
125 |  * This is only applicable for live-streams and for VOD will always return OK
126 |  * 
127 |  * @typedef TimestampResult
128 |  * @type {Object}
129 |  * @property {string} clock "OK" if ok or "BAD" if diff > allowedDiff
130 |  * @property {string} clockOffset The actual diff between last segment and now
131 |  * 
132 |  * @param {number} allowedDiff The allowed diff (in millisec, default is 10000)
133 |  * @returns {Promise.<TimestampResult>} a Promise that resolves when the timing has been checked.
134 |  */
135 | DashValidator.prototype.verifyTimestamps = function verifyTimestamps(allowedDiff) {
136 |   return new Promise((resolve, reject) => {
137 |     const diffCriteria = allowedDiff || 10000;
138 |     const result = {};
139 |     if (this._manifest.type === "static") {
140 |       result.clock = "OK";
141 |     } else {
142 |       const timeAtHead = this._manifest.timeAtHead;
143 |       const d = new Date().getTime();
144 |       if (Math.abs(timeAtHead - d) > diffCriteria) {
145 |         result.clock = "BAD";
146 |         result.clockOffset = Math.abs(timeAtHead - d);
147 |       } else {
148 |         result.clock = "OK";
149 |         result.clockOffset = Math.abs(timeAtHead - d);
150 |       }
151 |     }
152 |     resolve(result);
153 |   });
154 | }
155 | 
156 | /**
157 |  * Verify that a list of segments can be downloaded and have correct HTTP headers
158 |  * Applicable for both live and VOD.
159 |  * 
160 |  * @param {Function(Object)} verifyFn Function that is called to verify a segment.
161 |  *    If not provided a default will be used
162 |  * @param {Array.<string>} segments An array of segment URIs
163 |  * @param {boolean} doDownload When true use GET instead of HEAD
164 |  * @returns {Promise.<SegmentVerifyResult>} a Promise that resolves when all segments are verified.
165 |  */
166 | DashValidator.prototype.verifySegments = function verifySegments(verifyFn, segments, doDownload) {
167 |   return new Promise((resolve, reject) => {
168 |     let failed = [];
169 |     let ok = [];
170 |   
171 |     let it = util.iteratorFromArray(segments);
172 |     const base = this._base;
173 | 
174 |     function checkSegment(doneCb) {
175 |       const iter = it.next();
176 |       if (iter.done) {
177 |         doneCb();
178 |       } else {
179 |         const segmentUrl = iter.value;
180 |         verifySegment(verifyFn || defaultVerifyFn, base + segmentUrl, doDownload).then((result) => {
181 |           if (result.ok) {
182 |             ok.push({ uri: segmentUrl });
183 |           } else {
184 |             failed.push({ uri: segmentUrl, reason: result.reason, headers: result.headers });
185 |           }
186 |           util.sleep(50);
187 |           checkSegment(doneCb);
188 |         }).catch((error) => {
189 |           console.error(error);
190 |         });
191 |       }
192 |     }
193 | 
194 |     checkSegment(() => {
195 |       resolve({ failed: failed, ok: ok});
196 |     });
197 |   });
198 | };
199 | 
200 | /**
201 |  * Verify that the manifest is ok.
202 |  * 
203 |  * @param {Function(headers, type)} verifyFn Function that is called to verify a manifest.
204 |  *   If not provided a default will be used.
205 |  * @returns {Promise.<ManifestVerifyResult>} a Promise that resolves when the manifest
206 |  *   is verified.
207 |  */
208 | DashValidator.prototype.verifyManifest = function verifyManifest(verifyFn) {
209 |   return new Promise((resolve, reject) => {
210 |     const verify = verifyFn || defaultManifestVerifyFn;
211 |     const result = {};
212 |     result.ok = verify(this._manifestHeaders, this._manifest.type);
213 |     result.headers = this._manifestHeaders;
214 |     resolve(result);
215 |   });
216 | };
217 | 
218 | /**
219 |  * Verify that all segments referred to by this MPEG DASH manifest is OK
220 |  * 
221 |  * @param {Function(Object)} verifyFn Function that is called to verify a segment.
222 |  *    If not provided a default will be used
223 |  * @param {boolean} doDownload When true use GET instead of HEAD
224 |  * @returns {Promise.<SegmentVerifyResult>} a Promise that resolves when all segments are verified.
225 |  */
226 | DashValidator.prototype.verifyAllSegments = function verifyAllSegments(verifyFn, doDownload) {
227 |   const segments = this._manifest.segments;
228 |   return this.verifySegments(verifyFn, segments, doDownload);
229 | };
230 | 
231 | /**
232 |  * Verify a random sample of segments (spotcheck)
233 |  *  
234 |  * @param {Function(Object)} verifyFn Function that is called to verify a segment.
235 |  *    If not provided a default will be used
236 |  * @param {number} noSamples The number of spotchecks to do
237 |  * @param {boolean} doDownload When true use GET instead of HEAD
238 |  * @returns {Promise.<SegmentVerifyResult>} a Promise that resolves when all segments are verified.
239 |  */
240 | DashValidator.prototype.spotcheckSegments = function spotcheckSegments(verifyFn, noSamples, doDownload) {
241 |   const segments = this._manifest.segments;
242 |   let i = 0;
243 |   let spotchecks = [];
244 |   while(i < noSamples) {
245 |     spotchecks.push(util.getRandomItem(segments));
246 |     i++;
247 |   }
248 |   return this.verifySegments(verifyFn, spotchecks, doDownload);
249 | }
250 | 
251 | /**
252 |  * Validate a dynamically updated MPEG DASH manifest usually used for live
253 |  * streaming
254 |  * 
255 |  * @param {number} iterations Number of iterations to test
256 |  * @param {Function} _optIterator For testing purposes
257 |  * @returns {Promise}
258 |  */
259 | DashValidator.prototype.validateDynamicManifest = function validateDynamicManifest(iterations, _optIterator) {
260 |   return new Promise((resolve, reject) => {
261 |     this._runner.start(iterations, () => {
262 |       return new Promise((resolveUpdateMpd) => {
263 |         // Download, parse and update MPD
264 |         util.requestXml(this._src).then(resp => {
265 |           const parser = new DashParser();
266 |           parser.parse(resp.xml).then((manifest) => {
267 |             this._manifest = manifest;
268 |             this._runner.updateMpd(this._manifest, resp.headers);
269 |             resolveUpdateMpd();
270 |           })
271 |         });
272 |       });
273 |     }, _optIterator)
274 |     .then((result) => {
275 |       resolve(result);
276 |     }).catch(reject);
277 |   });
278 | };
279 | 
280 | DashValidator.prototype.on = function on(eventName, fn) {
281 |   if (["invalidplayhead", "invalidheaders", "checking"].indexOf(eventName) != -1) {
282 |     this._runner.on(eventName, fn);
283 |   }
284 | };
285 | 
286 | /**
287 |  * @returns {number} the total duration of the MPEG DASH manifest
288 |  */
289 | DashValidator.prototype.duration = function duration() {
290 |   return this._manifest.totalDuration;
291 | };
292 | 
293 | /**
294 |  * @returns {Array.<string>} an array with all segment URIs referred to by this
295 |  *   MPEG DASH manifest
296 |  */
297 | DashValidator.prototype.segmentUrls = function segmentUrls() {
298 |   return this._manifest.segments;
299 | };
300 | 
301 | /**
302 |  * @returns {boolean} True if dynamic manifest, i.e. live stream
303 |  */
304 | DashValidator.prototype.isLive = function isLive() {
305 |   return (this._manifest.type === "dynamic");
306 | };
307 | 
308 | /** Private functions */
309 | 
310 | /** @private */
311 | function defaultVerifyFn(headers) {
312 |   let headersOk = true;
313 |   if (typeof headers["cache-control"] === "undefined" ||
314 |       headers["access-control-expose-headers"].split(',').indexOf("Date") == -1 ||
315 |       headers["access-control-allow-headers"].split(',').indexOf("origin") == -1)
316 |   {
317 |     headersOk = false;
318 |   }
319 |   return headersOk;
320 | }
321 | 
322 | function defaultManifestVerifyFn(headers, type) {
323 |   if (type == "dynamic") {
324 |     if (!headers["cache-control"]) {
325 |       return false;
326 |     }
327 |     const m = headers["cache-control"].match(/max-age=(\d+)/);
328 |     if (!m) {
329 |       return false;
330 |     }
331 |     if (m[1] > 10) {
332 |       // Max age for dynamic manifest should not cache this long
333 |       return false;
334 |     }
335 |   }
336 |   return true;
337 | }
338 | 
339 | function verifySegment(verifyFn, segmentUrl, doDownload) {
340 |   return new Promise((resolve, reject) => {
341 |     const result = {};
342 | 
343 |     let reqFn;
344 |     if (!doDownload) {
345 |       reqFn = util.requestHeaders;
346 |     } else {
347 |       reqFn = util.requestCacheFill;
348 |     }
349 |     reqFn(segmentUrl).then((headers) => {
350 |       result.ok = verifyFn(headers);
351 |       result.headers = headers;
352 |       resolve(result);
353 |     }).catch((err) => {
354 |       result.ok = false;
355 |       result.reason = err;
356 |       resolve(result);
357 |     });
358 |   });
359 | }
360 | 
361 | /** Create a Dash Validator object */
362 | module.exports = DashValidator;
363 | 
364 |
365 |
366 | 367 | 368 | 369 | 370 |
371 | 372 |
373 | 374 | 377 | 378 | 379 | 380 | 381 | 382 | -------------------------------------------------------------------------------- /docs/module-dash-validator-DashValidator.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | DashValidator - Documentation 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 22 | 23 | 24 | 25 | 28 | 29 |
30 | 31 |

DashValidator

32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
40 | 41 |
42 | 43 |

44 | dash-validator~ 45 | 46 | DashValidator 47 |

48 | 49 | 50 |
51 | 52 |
53 |
54 | 55 | 56 | 57 | 58 | 59 |

new DashValidator(src) → {DashValidator}

60 | 61 | 62 | 63 | 64 | 65 |
66 | Creates a new Dash Validator object 67 |
68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 |
Parameters:
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 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 |
NameTypeDescription
src 106 | 107 | 108 | string 109 | 110 | 111 | 112 | URI to MPEG DASH manifest, e.g. http://example.com/example.mpd
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 |
Source:
158 |
161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 |
169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 |
Returns:
183 | 184 | 185 | 186 | 187 |
188 |
189 | Type 190 |
191 |
192 | 193 | DashValidator 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 |

Methods

220 | 221 | 222 | 223 | 224 | 225 | 226 |

duration() → {number}

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 |
Source:
272 |
275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 |
283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 |
Returns:
297 | 298 | 299 |
300 | the total duration of the MPEG DASH manifest 301 |
302 | 303 | 304 | 305 |
306 |
307 | Type 308 |
309 |
310 | 311 | number 312 | 313 | 314 |
315 |
316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 |

isLive() → {boolean}

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 |
Source:
372 |
375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 |
383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 |
Returns:
397 | 398 | 399 |
400 | True if dynamic manifest, i.e. live stream 401 |
402 | 403 | 404 | 405 |
406 |
407 | Type 408 |
409 |
410 | 411 | boolean 412 | 413 | 414 |
415 |
416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 |

load() → {Promise}

427 | 428 | 429 | 430 | 431 | 432 |
433 | Download and parses MPEG DASH manifest 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 |
Source:
476 |
479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 |
487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 |
Returns:
501 | 502 | 503 |
504 | a Promise that resolves when the manifest is downloaded and parsed. 505 |
506 | 507 | 508 | 509 |
510 |
511 | Type 512 |
513 |
514 | 515 | Promise 516 | 517 | 518 |
519 |
520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 |

segmentUrls() → {Array.<string>}

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 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 |
Source:
576 |
579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 |
587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 |
Returns:
601 | 602 | 603 |
604 | an array with all segment URIs referred to by this 605 | MPEG DASH manifest 606 |
607 | 608 | 609 | 610 |
611 |
612 | Type 613 |
614 |
615 | 616 | Array.<string> 617 | 618 | 619 |
620 |
621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 |

spotcheckSegments(verifyFn, noSamples, doDownload) → {Promise.<SegmentVerifyResult>}

632 | 633 | 634 | 635 | 636 | 637 |
638 | Verify a random sample of segments (spotcheck) 639 |
640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 |
Parameters:
650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 671 | 672 | 673 | 674 | 675 | 676 | 677 | 685 | 686 | 687 | 688 | 689 | 690 | 692 | 693 | 694 | 695 | 696 | 697 | 698 | 699 | 700 | 701 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 724 | 732 | 733 | 734 | 735 | 736 | 737 | 738 | 739 | 740 | 741 | 742 |
NameTypeDescription
verifyFn 678 | 679 | 680 | function 681 | 682 | 683 | 684 | Function that is called to verify a segment. 691 | If not provided a default will be used
noSamples 702 | 703 | 704 | number 705 | 706 | 707 | 708 | The number of spotchecks to do
doDownload 725 | 726 | 727 | boolean 728 | 729 | 730 | 731 | When true use GET instead of HEAD
743 | 744 | 745 | 746 | 747 | 748 | 749 |
750 | 751 | 752 | 753 | 754 | 755 | 756 | 757 | 758 | 759 | 760 | 761 | 762 | 763 | 764 | 765 | 766 | 767 | 768 | 769 | 770 | 771 | 772 | 773 | 774 | 775 | 776 |
Source:
777 |
780 | 781 | 782 | 783 | 784 | 785 | 786 | 787 |
788 | 789 | 790 | 791 | 792 | 793 | 794 | 795 | 796 | 797 | 798 | 799 | 800 | 801 |
Returns:
802 | 803 | 804 |
805 | a Promise that resolves when all segments are verified. 806 |
807 | 808 | 809 | 810 |
811 |
812 | Type 813 |
814 |
815 | 816 | Promise.<SegmentVerifyResult> 817 | 818 | 819 |
820 |
821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 829 | 830 | 831 |

validateDynamicManifest(iterations, _optIterator) → {Promise}

832 | 833 | 834 | 835 | 836 | 837 |
838 | Validate a dynamically updated MPEG DASH manifest usually used for live 839 | streaming 840 |
841 | 842 | 843 | 844 | 845 | 846 | 847 | 848 | 849 | 850 |
Parameters:
851 | 852 | 853 | 854 | 855 | 856 | 857 | 858 | 859 | 860 | 861 | 862 | 863 | 864 | 865 | 866 | 867 | 868 | 869 | 870 | 871 | 872 | 873 | 874 | 875 | 876 | 877 | 878 | 886 | 887 | 888 | 889 | 890 | 891 | 892 | 893 | 894 | 895 | 896 | 897 | 898 | 899 | 900 | 901 | 909 | 910 | 911 | 912 | 913 | 914 | 915 | 916 | 917 | 918 | 919 |
NameTypeDescription
iterations 879 | 880 | 881 | number 882 | 883 | 884 | 885 | Number of iterations to test
_optIterator 902 | 903 | 904 | function 905 | 906 | 907 | 908 | For testing purposes
920 | 921 | 922 | 923 | 924 | 925 | 926 |
927 | 928 | 929 | 930 | 931 | 932 | 933 | 934 | 935 | 936 | 937 | 938 | 939 | 940 | 941 | 942 | 943 | 944 | 945 | 946 | 947 | 948 | 949 | 950 | 951 | 952 | 953 |
Source:
954 |
957 | 958 | 959 | 960 | 961 | 962 | 963 | 964 |
965 | 966 | 967 | 968 | 969 | 970 | 971 | 972 | 973 | 974 | 975 | 976 | 977 | 978 |
Returns:
979 | 980 | 981 | 982 | 983 |
984 |
985 | Type 986 |
987 |
988 | 989 | Promise 990 | 991 | 992 |
993 |
994 | 995 | 996 | 997 | 998 | 999 | 1000 | 1001 | 1002 | 1003 | 1004 |

verifyAllSegments(verifyFn, doDownload) → {Promise.<SegmentVerifyResult>}

1005 | 1006 | 1007 | 1008 | 1009 | 1010 |
1011 | Verify that all segments referred to by this MPEG DASH manifest is OK 1012 |
1013 | 1014 | 1015 | 1016 | 1017 | 1018 | 1019 | 1020 | 1021 | 1022 |
Parameters:
1023 | 1024 | 1025 | 1026 | 1027 | 1028 | 1029 | 1030 | 1031 | 1032 | 1033 | 1034 | 1035 | 1036 | 1037 | 1038 | 1039 | 1040 | 1041 | 1042 | 1043 | 1044 | 1045 | 1046 | 1047 | 1048 | 1049 | 1050 | 1058 | 1059 | 1060 | 1061 | 1062 | 1063 | 1065 | 1066 | 1067 | 1068 | 1069 | 1070 | 1071 | 1072 | 1073 | 1074 | 1082 | 1083 | 1084 | 1085 | 1086 | 1087 | 1088 | 1089 | 1090 | 1091 | 1092 |
NameTypeDescription
verifyFn 1051 | 1052 | 1053 | function 1054 | 1055 | 1056 | 1057 | Function that is called to verify a segment. 1064 | If not provided a default will be used
doDownload 1075 | 1076 | 1077 | boolean 1078 | 1079 | 1080 | 1081 | When true use GET instead of HEAD
1093 | 1094 | 1095 | 1096 | 1097 | 1098 | 1099 |
1100 | 1101 | 1102 | 1103 | 1104 | 1105 | 1106 | 1107 | 1108 | 1109 | 1110 | 1111 | 1112 | 1113 | 1114 | 1115 | 1116 | 1117 | 1118 | 1119 | 1120 | 1121 | 1122 | 1123 | 1124 | 1125 | 1126 |
Source:
1127 |
1130 | 1131 | 1132 | 1133 | 1134 | 1135 | 1136 | 1137 |
1138 | 1139 | 1140 | 1141 | 1142 | 1143 | 1144 | 1145 | 1146 | 1147 | 1148 | 1149 | 1150 | 1151 |
Returns:
1152 | 1153 | 1154 |
1155 | a Promise that resolves when all segments are verified. 1156 |
1157 | 1158 | 1159 | 1160 |
1161 |
1162 | Type 1163 |
1164 |
1165 | 1166 | Promise.<SegmentVerifyResult> 1167 | 1168 | 1169 |
1170 |
1171 | 1172 | 1173 | 1174 | 1175 | 1176 | 1177 | 1178 | 1179 | 1180 | 1181 |

verifyManifest(verifyFn) → {Promise.<ManifestVerifyResult>}

1182 | 1183 | 1184 | 1185 | 1186 | 1187 |
1188 | Verify that the manifest is ok. 1189 |
1190 | 1191 | 1192 | 1193 | 1194 | 1195 | 1196 | 1197 | 1198 | 1199 |
Parameters:
1200 | 1201 | 1202 | 1203 | 1204 | 1205 | 1206 | 1207 | 1208 | 1209 | 1210 | 1211 | 1212 | 1213 | 1214 | 1215 | 1216 | 1217 | 1218 | 1219 | 1220 | 1221 | 1222 | 1223 | 1224 | 1225 | 1226 | 1227 | 1235 | 1236 | 1237 | 1238 | 1239 | 1240 | 1242 | 1243 | 1244 | 1245 | 1246 |
NameTypeDescription
verifyFn 1228 | 1229 | 1230 | function 1231 | 1232 | 1233 | 1234 | Function that is called to verify a manifest. 1241 | If not provided a default will be used.
1247 | 1248 | 1249 | 1250 | 1251 | 1252 | 1253 |
1254 | 1255 | 1256 | 1257 | 1258 | 1259 | 1260 | 1261 | 1262 | 1263 | 1264 | 1265 | 1266 | 1267 | 1268 | 1269 | 1270 | 1271 | 1272 | 1273 | 1274 | 1275 | 1276 | 1277 | 1278 | 1279 | 1280 |
Source:
1281 |
1284 | 1285 | 1286 | 1287 | 1288 | 1289 | 1290 | 1291 |
1292 | 1293 | 1294 | 1295 | 1296 | 1297 | 1298 | 1299 | 1300 | 1301 | 1302 | 1303 | 1304 | 1305 |
Returns:
1306 | 1307 | 1308 |
1309 | a Promise that resolves when the manifest 1310 | is verified. 1311 |
1312 | 1313 | 1314 | 1315 |
1316 |
1317 | Type 1318 |
1319 |
1320 | 1321 | Promise.<ManifestVerifyResult> 1322 | 1323 | 1324 |
1325 |
1326 | 1327 | 1328 | 1329 | 1330 | 1331 | 1332 | 1333 | 1334 | 1335 | 1336 |

verifySegments(verifyFn, segments, doDownload) → {Promise.<SegmentVerifyResult>}

1337 | 1338 | 1339 | 1340 | 1341 | 1342 |
1343 | Verify that a list of segments can be downloaded and have correct HTTP headers 1344 | Applicable for both live and VOD. 1345 |
1346 | 1347 | 1348 | 1349 | 1350 | 1351 | 1352 | 1353 | 1354 | 1355 |
Parameters:
1356 | 1357 | 1358 | 1359 | 1360 | 1361 | 1362 | 1363 | 1364 | 1365 | 1366 | 1367 | 1368 | 1369 | 1370 | 1371 | 1372 | 1373 | 1374 | 1375 | 1376 | 1377 | 1378 | 1379 | 1380 | 1381 | 1382 | 1383 | 1391 | 1392 | 1393 | 1394 | 1395 | 1396 | 1398 | 1399 | 1400 | 1401 | 1402 | 1403 | 1404 | 1405 | 1406 | 1407 | 1415 | 1416 | 1417 | 1418 | 1419 | 1420 | 1421 | 1422 | 1423 | 1424 | 1425 | 1426 | 1427 | 1428 | 1429 | 1430 | 1438 | 1439 | 1440 | 1441 | 1442 | 1443 | 1444 | 1445 | 1446 | 1447 | 1448 |
NameTypeDescription
verifyFn 1384 | 1385 | 1386 | function 1387 | 1388 | 1389 | 1390 | Function that is called to verify a segment. 1397 | If not provided a default will be used
segments 1408 | 1409 | 1410 | Array.<string> 1411 | 1412 | 1413 | 1414 | An array of segment URIs
doDownload 1431 | 1432 | 1433 | boolean 1434 | 1435 | 1436 | 1437 | When true use GET instead of HEAD
1449 | 1450 | 1451 | 1452 | 1453 | 1454 | 1455 |
1456 | 1457 | 1458 | 1459 | 1460 | 1461 | 1462 | 1463 | 1464 | 1465 | 1466 | 1467 | 1468 | 1469 | 1470 | 1471 | 1472 | 1473 | 1474 | 1475 | 1476 | 1477 | 1478 | 1479 | 1480 | 1481 | 1482 |
Source:
1483 |
1486 | 1487 | 1488 | 1489 | 1490 | 1491 | 1492 | 1493 |
1494 | 1495 | 1496 | 1497 | 1498 | 1499 | 1500 | 1501 | 1502 | 1503 | 1504 | 1505 | 1506 | 1507 |
Returns:
1508 | 1509 | 1510 |
1511 | a Promise that resolves when all segments are verified. 1512 |
1513 | 1514 | 1515 | 1516 |
1517 |
1518 | Type 1519 |
1520 |
1521 | 1522 | Promise.<SegmentVerifyResult> 1523 | 1524 | 1525 |
1526 |
1527 | 1528 | 1529 | 1530 | 1531 | 1532 | 1533 | 1534 | 1535 | 1536 | 1537 | 1538 |
1539 | 1540 |
1541 | 1542 | 1543 | 1544 | 1545 |
1546 | 1547 |
1548 | 1549 | 1552 | 1553 | 1554 | 1555 | 1556 | -------------------------------------------------------------------------------- /docs/module-dash-validator.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | dash-validator - Documentation 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 22 | 23 | 24 | 25 | 28 | 29 |
30 | 31 |

dash-validator

32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
40 | 41 |
42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 |
50 | 51 |
52 |
53 | 54 | 55 |
MPEG DASH Validator 56 | 57 | A Javascript library that can be used to validate MPEG DASH streams (VOD and Live). 58 | Source available on GitHub
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 |
Source:
106 |
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 |

module:dash-validator

139 | 140 | 141 | 142 | 143 | 144 |
145 | Create a Dash Validator object 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 |
Source:
188 |
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 |

Classes

225 | 226 |
227 |
DashValidator
228 |
229 |
230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 |

Type Definitions

242 | 243 | 244 | 245 |

FailedInfo

246 | 247 | 248 | 249 | 250 | 251 | 252 |
Type:
253 |
    254 |
  • 255 | 256 | Object 257 | 258 | 259 |
  • 260 |
261 | 262 | 263 | 264 | 265 | 266 |
Properties:
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 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 |
NameTypeDescription
uri 296 | 297 | 298 | string 299 | 300 | 301 | 302 | URI to the segment that failed
headers 319 | 320 | 321 | Object 322 | 323 | 324 | 325 | The actual HTTP response headers
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 |
Source:
369 |
372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 |
380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 |

ManifestVerifyResult

389 | 390 | 391 | 392 | 393 | 394 | 395 |
Type:
396 |
    397 |
  • 398 | 399 | Object 400 | 401 | 402 |
  • 403 |
404 | 405 | 406 | 407 | 408 | 409 |
Properties:
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 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 |
NameTypeDescription
ok 439 | 440 | 441 | boolean 442 | 443 | 444 | 445 | True if successful
headers 462 | 463 | 464 | Object 465 | 466 | 467 | 468 | The response headers for the manifest request.
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 |
Source:
512 |
515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 |
523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 |

SegmentVerifyResult

532 | 533 | 534 | 535 | 536 | 537 | 538 |
Type:
539 |
    540 |
  • 541 | 542 | Object 543 | 544 | 545 |
  • 546 |
547 | 548 | 549 | 550 | 551 | 552 |
Properties:
553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 |
NameTypeDescription
failed 582 | 583 | 584 | Array.<FailedInfo> 585 | 586 | 587 | 588 | An array of all segments that failed
ok 605 | 606 | 607 | Array.<SuccessInfo> 608 | 609 | 610 | 611 | An array of all segments that were ok
623 | 624 | 625 | 626 | 627 |
628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 |
Source:
655 |
658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 |
666 | 667 | 668 | 669 | 670 | 671 | 672 | 673 | 674 |

SuccessInfo

675 | 676 | 677 | 678 | 679 | 680 | 681 |
Type:
682 |
    683 |
  • 684 | 685 | Object 686 | 687 | 688 |
  • 689 |
690 | 691 | 692 | 693 | 694 | 695 |
Properties:
696 | 697 | 698 | 699 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 724 | 732 | 733 | 734 | 735 | 736 | 737 | 738 | 739 | 740 | 741 | 742 |
NameTypeDescription
uri 725 | 726 | 727 | string 728 | 729 | 730 | 731 | URI to the successful segment
743 | 744 | 745 | 746 | 747 |
748 | 749 | 750 | 751 | 752 | 753 | 754 | 755 | 756 | 757 | 758 | 759 | 760 | 761 | 762 | 763 | 764 | 765 | 766 | 767 | 768 | 769 | 770 | 771 | 772 | 773 | 774 |
Source:
775 |
778 | 779 | 780 | 781 | 782 | 783 | 784 | 785 |
786 | 787 | 788 | 789 | 790 | 791 | 792 | 793 | 794 |

TimestampResult

795 | 796 | 797 | 798 | 799 |
800 | Verifies that the timestamp of the last segment for a MPEG DASH live-stream 801 | does not differ more than 10 seconds (default) from actual time. 802 | 803 | This is only applicable for live-streams and for VOD will always return OK 804 |
805 | 806 | 807 | 808 |
Type:
809 |
    810 |
  • 811 | 812 | Object 813 | 814 | 815 |
  • 816 |
817 | 818 | 819 | 820 | 821 | 822 |
Properties:
823 | 824 | 825 | 826 | 827 | 828 | 829 | 830 | 831 | 832 | 833 | 834 | 835 | 836 | 837 | 838 | 839 | 840 | 841 | 842 | 843 | 844 | 845 | 846 | 847 | 848 | 849 | 850 | 851 | 859 | 860 | 861 | 862 | 863 | 864 | 865 | 866 | 867 | 868 | 869 | 870 | 871 | 872 | 873 | 874 | 882 | 883 | 884 | 885 | 886 | 887 | 888 | 889 | 890 | 891 | 892 |
NameTypeDescription
clock 852 | 853 | 854 | string 855 | 856 | 857 | 858 | "OK" if ok or "BAD" if diff > allowedDiff
clockOffset 875 | 876 | 877 | string 878 | 879 | 880 | 881 | The actual diff between last segment and now
893 | 894 | 895 | 896 | 897 |
898 | 899 | 900 | 901 | 902 | 903 | 904 | 905 | 906 | 907 | 908 | 909 | 910 | 911 | 912 | 913 | 914 | 915 | 916 | 917 | 918 | 919 | 920 | 921 | 922 | 923 | 924 |
Source:
925 |
928 | 929 | 930 | 931 | 932 | 933 | 934 | 935 |
936 | 937 | 938 | 939 | 940 | 941 | 942 | 943 | 944 | 945 | 946 |
947 | 948 |
949 | 950 | 951 | 952 | 953 |
954 | 955 |
956 | 957 | 960 | 961 | 962 | 963 | 964 | -------------------------------------------------------------------------------- /docs/scripts/linenumber.js: -------------------------------------------------------------------------------- 1 | /*global document */ 2 | (function() { 3 | var source = document.getElementsByClassName('prettyprint source linenums'); 4 | var i = 0; 5 | var lineNumber = 0; 6 | var lineId; 7 | var lines; 8 | var totalLines; 9 | var anchorHash; 10 | 11 | if (source && source[0]) { 12 | anchorHash = document.location.hash.substring(1); 13 | lines = source[0].getElementsByTagName('li'); 14 | totalLines = lines.length; 15 | 16 | for (; i < totalLines; i++) { 17 | lineNumber++; 18 | lineId = 'line' + lineNumber; 19 | lines[i].id = lineId; 20 | if (lineId === anchorHash) { 21 | lines[i].className += ' selected'; 22 | } 23 | } 24 | } 25 | })(); 26 | -------------------------------------------------------------------------------- /docs/scripts/prettify/Apache-License-2.0.txt: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /docs/scripts/prettify/lang-css.js: -------------------------------------------------------------------------------- 1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\f\r ]+/,null," \t\r\n "]],[["str",/^"(?:[^\n\f\r"\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*"/,null],["str",/^'(?:[^\n\f\r'\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*'/,null],["lang-css-str",/^url\(([^"')]*)\)/i],["kwd",/^(?:url|rgb|!important|@import|@page|@media|@charset|inherit)(?=[^\w-]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*)\s*:/i],["com",/^\/\*[^*]*\*+(?:[^*/][^*]*\*+)*\//],["com", 2 | /^(?:<\!--|--\>)/],["lit",/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],["lit",/^#[\da-f]{3,6}/i],["pln",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i],["pun",/^[^\s\w"']+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[["kwd",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[["str",/^[^"')]+/]]),["css-str"]); 3 | -------------------------------------------------------------------------------- /docs/scripts/prettify/prettify.js: -------------------------------------------------------------------------------- 1 | var q=null;window.PR_SHOULD_USE_CONTINUATION=!0; 2 | (function(){function L(a){function m(a){var f=a.charCodeAt(0);if(f!==92)return f;var b=a.charAt(1);return(f=r[b])?f:"0"<=b&&b<="7"?parseInt(a.substring(1),8):b==="u"||b==="x"?parseInt(a.substring(2),16):a.charCodeAt(1)}function e(a){if(a<32)return(a<16?"\\x0":"\\x")+a.toString(16);a=String.fromCharCode(a);if(a==="\\"||a==="-"||a==="["||a==="]")a="\\"+a;return a}function h(a){for(var f=a.substring(1,a.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),a= 3 | [],b=[],o=f[0]==="^",c=o?1:0,i=f.length;c122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;ci[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m), 9 | l=[],p={},d=0,g=e.length;d=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/, 10 | q,"'\"`"]):m.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&e.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var h=a.hashComments;h&&(a.cStyleComments?(h>1?m.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):m.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),e.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):m.push(["com",/^#[^\n\r]*/, 11 | q,"#"]));a.cStyleComments&&(e.push(["com",/^\/\/[^\n\r]*/,q]),e.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));a.regexLiterals&&e.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]);(h=a.types)&&e.push(["typ",h]);a=(""+a.keywords).replace(/^ | $/g, 12 | "");a.length&&e.push(["kwd",RegExp("^(?:"+a.replace(/[\s,]+/g,"|")+")\\b"),q]);m.push(["pln",/^\s+/,q," \r\n\t\xa0"]);e.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]);return x(m,e)}function D(a,m){function e(a){switch(a.nodeType){case 1:if(k.test(a.className))break;if("BR"===a.nodeName)h(a), 13 | a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)e(a);break;case 3:case 4:if(p){var b=a.nodeValue,d=b.match(t);if(d){var c=b.substring(0,d.index);a.nodeValue=c;(b=b.substring(d.index+d[0].length))&&a.parentNode.insertBefore(s.createTextNode(b),a.nextSibling);h(a);c||a.parentNode.removeChild(a)}}}}function h(a){function b(a,d){var e=d?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),g=a.nextSibling;f.appendChild(e);for(var h=g;h;h=g)g=h.nextSibling,f.appendChild(h)}return e} 14 | for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),e;(e=a.parentNode)&&e.nodeType===1;)a=e;d.push(a)}var k=/(?:^|\s)nocode(?:\s|$)/,t=/\r\n?|\n/,s=a.ownerDocument,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=s.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);for(l=s.createElement("LI");a.firstChild;)l.appendChild(a.firstChild);for(var d=[l],g=0;g=0;){var h=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}function C(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*=o&&(h+=2);e>=c&&(a+=2)}}catch(w){"console"in window&&console.log(w&&w.stack?w.stack:w)}}var v=["break,continue,do,else,for,if,return,while"],w=[[v,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"], 18 | "catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],F=[w,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],G=[w,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"], 19 | H=[G,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],w=[w,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],I=[v,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"], 20 | J=[v,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=[v,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],K=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,N=/\S/,O=u({keywords:[F,H,w,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+ 21 | I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),A={};k(O,["default-code"]);k(x([],[["pln",/^[^]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]), 22 | ["default-markup","htm","html","mxml","xhtml","xml","xsl"]);k(x([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/],["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css", 23 | /^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);k(x([],[["atv",/^[\S\s]+/]]),["uq.val"]);k(u({keywords:F,hashComments:!0,cStyleComments:!0,types:K}),["c","cc","cpp","cxx","cyc","m"]);k(u({keywords:"null,true,false"}),["json"]);k(u({keywords:H,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:K}),["cs"]);k(u({keywords:G,cStyleComments:!0}),["java"]);k(u({keywords:v,hashComments:!0,multiLineStrings:!0}),["bsh","csh","sh"]);k(u({keywords:I,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}), 24 | ["cv","py"]);k(u({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["perl","pl","pm"]);k(u({keywords:J,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb"]);k(u({keywords:w,cStyleComments:!0,regexLiterals:!0}),["js"]);k(u({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes", 25 | hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);k(x([],[["str",/^[\S\s]+/]]),["regex"]);window.prettyPrintOne=function(a,m,e){var h=document.createElement("PRE");h.innerHTML=a;e&&D(h,e);E({g:m,i:e,h:h});return h.innerHTML};window.prettyPrint=function(a){function m(){for(var e=window.PR_SHOULD_USE_CONTINUATION?l.now()+250:Infinity;p=0){var k=k.match(g),f,b;if(b= 26 | !k){b=n;for(var o=void 0,c=b.firstChild;c;c=c.nextSibling)var i=c.nodeType,o=i===1?o?b:c:i===3?N.test(c.nodeValue)?b:o:o;b=(f=o===b?void 0:o)&&"CODE"===f.tagName}b&&(k=f.className.match(g));k&&(k=k[1]);b=!1;for(o=n.parentNode;o;o=o.parentNode)if((o.tagName==="pre"||o.tagName==="code"||o.tagName==="xmp")&&o.className&&o.className.indexOf("prettyprint")>=0){b=!0;break}b||((b=(b=n.className.match(/\blinenums\b(?::(\d+))?/))?b[1]&&b[1].length?+b[1]:!0:!1)&&D(n,b),d={g:k,h:n,i:b},E(d))}}p ul { 179 | padding: 0 10px; 180 | } 181 | 182 | nav > ul > li > a { 183 | color: #000; 184 | } 185 | 186 | nav ul ul { 187 | margin-bottom: 10px 188 | } 189 | 190 | nav ul ul a { 191 | color: hsl(207, 1%, 60%); 192 | border-left: 1px solid hsl(207, 10%, 86%); 193 | } 194 | 195 | nav ul ul a, 196 | nav ul ul a:active { 197 | padding-left: 20px 198 | } 199 | 200 | nav h2 { 201 | font-size: 12px; 202 | margin: 0; 203 | padding: 0; 204 | } 205 | 206 | nav > h2 > a { 207 | display: block; 208 | margin: 10px 0 -10px; 209 | color: hsl(202, 71%, 50%) !important; 210 | } 211 | 212 | footer { 213 | color: hsl(0, 0%, 28%); 214 | margin-left: 250px; 215 | display: block; 216 | padding: 15px; 217 | font-style: italic; 218 | font-size: 90%; 219 | } 220 | 221 | .ancestors { 222 | color: #999 223 | } 224 | 225 | .ancestors a { 226 | color: #999 !important; 227 | text-decoration: none; 228 | } 229 | 230 | .clear { 231 | clear: both 232 | } 233 | 234 | .important { 235 | font-weight: bold; 236 | color: #950B02; 237 | } 238 | 239 | .yes-def { 240 | text-indent: -1000px 241 | } 242 | 243 | .type-signature { 244 | color: #aaa 245 | } 246 | 247 | .name, .signature { 248 | font-family: Consolas, Monaco, 'Andale Mono', monospace 249 | } 250 | 251 | .details { 252 | margin-top: 14px; 253 | border-left: 2px solid #DDD; 254 | line-height: 30px; 255 | } 256 | 257 | .details dt { 258 | width: 120px; 259 | float: left; 260 | padding-left: 10px; 261 | } 262 | 263 | .details dd { 264 | margin-left: 70px 265 | } 266 | 267 | .details ul { 268 | margin: 0 269 | } 270 | 271 | .details ul { 272 | list-style-type: none 273 | } 274 | 275 | .details li { 276 | margin-left: 30px 277 | } 278 | 279 | .details pre.prettyprint { 280 | margin: 0 281 | } 282 | 283 | .details .object-value { 284 | padding-top: 0 285 | } 286 | 287 | .description { 288 | margin-bottom: 1em; 289 | margin-top: 1em; 290 | } 291 | 292 | .code-caption { 293 | font-style: italic; 294 | font-size: 107%; 295 | margin: 0; 296 | } 297 | 298 | .prettyprint { 299 | font-size: 13px; 300 | border: 1px solid #ddd; 301 | border-radius: 3px; 302 | box-shadow: 0 1px 3px hsla(0, 0%, 0%, 0.05); 303 | overflow: auto; 304 | } 305 | 306 | .prettyprint.source { 307 | width: inherit 308 | } 309 | 310 | .prettyprint code { 311 | font-size: 100%; 312 | line-height: 18px; 313 | display: block; 314 | margin: 0 30px; 315 | background-color: #fff; 316 | color: #4D4E53; 317 | } 318 | 319 | .prettyprint > code { 320 | padding: 15px 321 | } 322 | 323 | .prettyprint .linenums code { 324 | padding: 0 15px 325 | } 326 | 327 | .prettyprint .linenums li:first-of-type code { 328 | padding-top: 15px 329 | } 330 | 331 | .prettyprint code span.line { 332 | display: inline-block 333 | } 334 | 335 | .prettyprint.linenums { 336 | padding-left: 70px; 337 | -webkit-user-select: none; 338 | -moz-user-select: none; 339 | -ms-user-select: none; 340 | user-select: none; 341 | } 342 | 343 | .prettyprint.linenums ol { 344 | padding-left: 0 345 | } 346 | 347 | .prettyprint.linenums li { 348 | border-left: 3px #ddd solid 349 | } 350 | 351 | .prettyprint.linenums li.selected, .prettyprint.linenums li.selected * { 352 | background-color: lightyellow 353 | } 354 | 355 | .prettyprint.linenums li * { 356 | -webkit-user-select: text; 357 | -moz-user-select: text; 358 | -ms-user-select: text; 359 | user-select: text; 360 | } 361 | 362 | .params, .props { 363 | border-spacing: 0; 364 | border: 1px solid #ddd; 365 | border-collapse: collapse; 366 | border-radius: 3px; 367 | box-shadow: 0 1px 3px rgba(0,0,0,0.1); 368 | width: 100%; 369 | font-size: 14px; 370 | } 371 | 372 | .params .name, .props .name, .name code { 373 | color: #4D4E53; 374 | font-family: Consolas, Monaco, 'Andale Mono', monospace; 375 | font-size: 100%; 376 | } 377 | 378 | .params td, .params th, .props td, .props th { 379 | margin: 0px; 380 | text-align: left; 381 | vertical-align: top; 382 | padding: 10px; 383 | display: table-cell; 384 | } 385 | 386 | .params td { 387 | border-top: 1px solid #eee 388 | } 389 | 390 | .params thead tr, .props thead tr { 391 | background-color: #fff; 392 | font-weight: bold; 393 | } 394 | 395 | .params .params thead tr, .props .props thead tr { 396 | background-color: #fff; 397 | font-weight: bold; 398 | } 399 | 400 | .params td.description > p:first-child, .props td.description > p:first-child { 401 | margin-top: 0; 402 | padding-top: 0; 403 | } 404 | 405 | .params td.description > p:last-child, .props td.description > p:last-child { 406 | margin-bottom: 0; 407 | padding-bottom: 0; 408 | } 409 | 410 | dl.param-type { 411 | border-bottom: 1px solid hsl(0, 0%, 87%); 412 | margin-bottom: 30px; 413 | padding-bottom: 30px; 414 | } 415 | 416 | .param-type dt, .param-type dd { 417 | display: inline-block 418 | } 419 | 420 | .param-type dd { 421 | font-family: Consolas, Monaco, 'Andale Mono', monospace 422 | } 423 | 424 | .disabled { 425 | color: #454545 426 | } 427 | 428 | /* navicon button */ 429 | .navicon-button { 430 | display: none; 431 | position: relative; 432 | padding: 2.0625rem 1.5rem; 433 | transition: 0.25s; 434 | cursor: pointer; 435 | user-select: none; 436 | opacity: .8; 437 | } 438 | .navicon-button .navicon:before, .navicon-button .navicon:after { 439 | transition: 0.25s; 440 | } 441 | .navicon-button:hover { 442 | transition: 0.5s; 443 | opacity: 1; 444 | } 445 | .navicon-button:hover .navicon:before, .navicon-button:hover .navicon:after { 446 | transition: 0.25s; 447 | } 448 | .navicon-button:hover .navicon:before { 449 | top: .825rem; 450 | } 451 | .navicon-button:hover .navicon:after { 452 | top: -.825rem; 453 | } 454 | 455 | /* navicon */ 456 | .navicon { 457 | position: relative; 458 | width: 2.5em; 459 | height: .3125rem; 460 | background: #000; 461 | transition: 0.3s; 462 | border-radius: 2.5rem; 463 | } 464 | .navicon:before, .navicon:after { 465 | display: block; 466 | content: ""; 467 | height: .3125rem; 468 | width: 2.5rem; 469 | background: #000; 470 | position: absolute; 471 | z-index: -1; 472 | transition: 0.3s 0.25s; 473 | border-radius: 1rem; 474 | } 475 | .navicon:before { 476 | top: .625rem; 477 | } 478 | .navicon:after { 479 | top: -.625rem; 480 | } 481 | 482 | /* open */ 483 | .nav-trigger:checked + label:not(.steps) .navicon:before, 484 | .nav-trigger:checked + label:not(.steps) .navicon:after { 485 | top: 0 !important; 486 | } 487 | 488 | .nav-trigger:checked + label .navicon:before, 489 | .nav-trigger:checked + label .navicon:after { 490 | transition: 0.5s; 491 | } 492 | 493 | /* Minus */ 494 | .nav-trigger:checked + label { 495 | transform: scale(0.75); 496 | } 497 | 498 | /* × and + */ 499 | .nav-trigger:checked + label.plus .navicon, 500 | .nav-trigger:checked + label.x .navicon { 501 | background: transparent; 502 | } 503 | 504 | .nav-trigger:checked + label.plus .navicon:before, 505 | .nav-trigger:checked + label.x .navicon:before { 506 | transform: rotate(-45deg); 507 | background: #FFF; 508 | } 509 | 510 | .nav-trigger:checked + label.plus .navicon:after, 511 | .nav-trigger:checked + label.x .navicon:after { 512 | transform: rotate(45deg); 513 | background: #FFF; 514 | } 515 | 516 | .nav-trigger:checked + label.plus { 517 | transform: scale(0.75) rotate(45deg); 518 | } 519 | 520 | .nav-trigger:checked ~ nav { 521 | left: 0 !important; 522 | } 523 | 524 | .nav-trigger:checked ~ .overlay { 525 | display: block; 526 | } 527 | 528 | .nav-trigger { 529 | position: fixed; 530 | top: 0; 531 | clip: rect(0, 0, 0, 0); 532 | } 533 | 534 | .overlay { 535 | display: none; 536 | position: fixed; 537 | top: 0; 538 | bottom: 0; 539 | left: 0; 540 | right: 0; 541 | width: 100%; 542 | height: 100%; 543 | background: hsla(0, 0%, 0%, 0.5); 544 | z-index: 1; 545 | } 546 | 547 | @media only screen and (min-width: 320px) and (max-width: 680px) { 548 | body { 549 | overflow-x: hidden; 550 | } 551 | 552 | nav { 553 | background: #FFF; 554 | width: 250px; 555 | height: 100%; 556 | position: fixed; 557 | top: 0; 558 | right: 0; 559 | bottom: 0; 560 | left: -250px; 561 | z-index: 3; 562 | padding: 0 10px; 563 | transition: left 0.2s; 564 | } 565 | 566 | .navicon-button { 567 | display: inline-block; 568 | position: fixed; 569 | top: 1.5em; 570 | right: 0; 571 | z-index: 2; 572 | } 573 | 574 | #main { 575 | width: 100%; 576 | min-width: 360px; 577 | } 578 | 579 | #main h1.page-title { 580 | margin: 1em 0; 581 | } 582 | 583 | #main section { 584 | padding: 0; 585 | } 586 | 587 | footer { 588 | margin-left: 0; 589 | } 590 | } 591 | -------------------------------------------------------------------------------- /docs/styles/prettify-jsdoc.css: -------------------------------------------------------------------------------- 1 | /* JSDoc prettify.js theme */ 2 | 3 | /* plain text */ 4 | .pln { 5 | color: #000000; 6 | font-weight: normal; 7 | font-style: normal; 8 | } 9 | 10 | /* string content */ 11 | .str { 12 | color: hsl(104, 100%, 24%); 13 | font-weight: normal; 14 | font-style: normal; 15 | } 16 | 17 | /* a keyword */ 18 | .kwd { 19 | color: #000000; 20 | font-weight: bold; 21 | font-style: normal; 22 | } 23 | 24 | /* a comment */ 25 | .com { 26 | font-weight: normal; 27 | font-style: italic; 28 | } 29 | 30 | /* a type name */ 31 | .typ { 32 | color: #000000; 33 | font-weight: normal; 34 | font-style: normal; 35 | } 36 | 37 | /* a literal value */ 38 | .lit { 39 | color: #006400; 40 | font-weight: normal; 41 | font-style: normal; 42 | } 43 | 44 | /* punctuation */ 45 | .pun { 46 | color: #000000; 47 | font-weight: bold; 48 | font-style: normal; 49 | } 50 | 51 | /* lisp open bracket */ 52 | .opn { 53 | color: #000000; 54 | font-weight: bold; 55 | font-style: normal; 56 | } 57 | 58 | /* lisp close bracket */ 59 | .clo { 60 | color: #000000; 61 | font-weight: bold; 62 | font-style: normal; 63 | } 64 | 65 | /* a markup tag name */ 66 | .tag { 67 | color: #006400; 68 | font-weight: normal; 69 | font-style: normal; 70 | } 71 | 72 | /* a markup attribute name */ 73 | .atn { 74 | color: #006400; 75 | font-weight: normal; 76 | font-style: normal; 77 | } 78 | 79 | /* a markup attribute value */ 80 | .atv { 81 | color: #006400; 82 | font-weight: normal; 83 | font-style: normal; 84 | } 85 | 86 | /* a declaration */ 87 | .dec { 88 | color: #000000; 89 | font-weight: bold; 90 | font-style: normal; 91 | } 92 | 93 | /* a variable name */ 94 | .var { 95 | color: #000000; 96 | font-weight: normal; 97 | font-style: normal; 98 | } 99 | 100 | /* a function name */ 101 | .fun { 102 | color: #000000; 103 | font-weight: bold; 104 | font-style: normal; 105 | } 106 | 107 | /* Specify class=linenums on a pre to get line numbering */ 108 | ol.linenums { 109 | margin-top: 0; 110 | margin-bottom: 0; 111 | } 112 | -------------------------------------------------------------------------------- /docs/styles/prettify-tomorrow.css: -------------------------------------------------------------------------------- 1 | /* Tomorrow Theme */ 2 | /* Original theme - https://github.com/chriskempson/tomorrow-theme */ 3 | /* Pretty printing styles. Used with prettify.js. */ 4 | /* SPAN elements with the classes below are added by prettyprint. */ 5 | /* plain text */ 6 | .pln { 7 | color: #4d4d4c; } 8 | 9 | @media screen { 10 | /* string content */ 11 | .str { 12 | color: hsl(104, 100%, 24%); } 13 | 14 | /* a keyword */ 15 | .kwd { 16 | color: hsl(240, 100%, 50%); } 17 | 18 | /* a comment */ 19 | .com { 20 | color: hsl(0, 0%, 60%); } 21 | 22 | /* a type name */ 23 | .typ { 24 | color: hsl(240, 100%, 32%); } 25 | 26 | /* a literal value */ 27 | .lit { 28 | color: hsl(240, 100%, 40%); } 29 | 30 | /* punctuation */ 31 | .pun { 32 | color: #000000; } 33 | 34 | /* lisp open bracket */ 35 | .opn { 36 | color: #000000; } 37 | 38 | /* lisp close bracket */ 39 | .clo { 40 | color: #000000; } 41 | 42 | /* a markup tag name */ 43 | .tag { 44 | color: #c82829; } 45 | 46 | /* a markup attribute name */ 47 | .atn { 48 | color: #f5871f; } 49 | 50 | /* a markup attribute value */ 51 | .atv { 52 | color: #3e999f; } 53 | 54 | /* a declaration */ 55 | .dec { 56 | color: #f5871f; } 57 | 58 | /* a variable name */ 59 | .var { 60 | color: #c82829; } 61 | 62 | /* a function name */ 63 | .fun { 64 | color: #4271ae; } } 65 | /* Use higher contrast and text-weight for printable form. */ 66 | @media print, projection { 67 | .str { 68 | color: #060; } 69 | 70 | .kwd { 71 | color: #006; 72 | font-weight: bold; } 73 | 74 | .com { 75 | color: #600; 76 | font-style: italic; } 77 | 78 | .typ { 79 | color: #404; 80 | font-weight: bold; } 81 | 82 | .lit { 83 | color: #044; } 84 | 85 | .pun, .opn, .clo { 86 | color: #440; } 87 | 88 | .tag { 89 | color: #006; 90 | font-weight: bold; } 91 | 92 | .atn { 93 | color: #404; } 94 | 95 | .atv { 96 | color: #060; } } 97 | /* Style */ 98 | /* 99 | pre.prettyprint { 100 | background: white; 101 | font-family: Consolas, Monaco, 'Andale Mono', monospace; 102 | font-size: 12px; 103 | line-height: 1.5; 104 | border: 1px solid #ccc; 105 | padding: 10px; } 106 | */ 107 | 108 | /* Specify class=linenums on a pre to get line numbering */ 109 | ol.linenums { 110 | margin-top: 0; 111 | margin-bottom: 0; } 112 | 113 | /* IE indents via margin-left */ 114 | li.L0, 115 | li.L1, 116 | li.L2, 117 | li.L3, 118 | li.L4, 119 | li.L5, 120 | li.L6, 121 | li.L7, 122 | li.L8, 123 | li.L9 { 124 | /* */ } 125 | 126 | /* Alternate shading for lines */ 127 | li.L1, 128 | li.L3, 129 | li.L5, 130 | li.L7, 131 | li.L9 { 132 | /* */ } 133 | -------------------------------------------------------------------------------- /example.js: -------------------------------------------------------------------------------- 1 | const DashValidator = require("dash-validator"); 2 | 3 | const validator = new DashValidator("http://example.com/test.mpd"); 4 | validator.load().then(() => { 5 | console.log("Loaded manifest"); 6 | console.log(validator.duration()); 7 | validator.verifyAllSegments(verifyFn).then(result => { 8 | console.log(result); 9 | }); 10 | }).catch(console.error); 11 | 12 | function verifyFn(headers) { 13 | return (typeof headers["x-my-custom-header"] !== "undefined"); 14 | } 15 | -------------------------------------------------------------------------------- /global_exports.js: -------------------------------------------------------------------------------- 1 | window.DashValidator = require("./index.js"); 2 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Eyevinn Technology. All rights reserved 2 | // Use of this source code is governed by a MIT License 3 | // license that can be found in the LICENSE file. 4 | // Author: Jonas Birme (Eyevinn Technology) 5 | const DashParser = require("./lib/dash_parser.js"); 6 | const DashValidatorRunner = require("./lib/dash_validator_runner.js"); 7 | const util = require("./lib/util.js"); 8 | 9 | /** 10 | * MPEG DASH Validator 11 | * 12 | * A Javascript library that can be used to validate MPEG DASH streams (VOD and Live). 13 | * Source available on {@link https://github.com/Eyevinn/dash-validator-js GitHub} 14 | * 15 | * @module dash-validator 16 | */ 17 | 18 | /** 19 | * Creates a new Dash Validator object 20 | * @constructor 21 | * 22 | * @param {string} src URI to MPEG DASH manifest, e.g. http://example.com/example.mpd 23 | * @returns {DashValidator} 24 | */ 25 | const DashValidator = function constructor(src) { 26 | this._src = src; 27 | this._manifest; 28 | this._base = ""; 29 | this._manifestHeaders; 30 | this._runner; 31 | }; 32 | 33 | /** 34 | * Download and parses MPEG DASH manifest 35 | * 36 | * @returns {Promise} a Promise that resolves when the manifest is downloaded and parsed. 37 | */ 38 | DashValidator.prototype.load = function load() { 39 | return new Promise((resolve, reject) => { 40 | this._base = util.getBaseUrl(this._src) + "/"; 41 | util.requestXml(this._src).then(resp => { 42 | this._manifestHeaders = resp.headers; 43 | 44 | const parser = new DashParser(); 45 | parser.parse(resp.xml).then((manifest) => { 46 | this._manifest = manifest; 47 | this._runner = new DashValidatorRunner(this._manifest, this._manifestHeaders, 10); 48 | resolve(); 49 | }).catch(reject); 50 | }).catch(reject); 51 | }); 52 | }; 53 | 54 | /** 55 | * @typedef FailedInfo 56 | * @type {Object} 57 | * @property {string} uri URI to the segment that failed 58 | * @property {Object} headers The actual HTTP response headers 59 | */ 60 | 61 | /** 62 | * @typedef SuccessInfo 63 | * @type {Object} 64 | * @property {string} uri URI to the successful segment 65 | */ 66 | 67 | /** 68 | * @typedef SegmentVerifyResult 69 | * @type {Object} 70 | * @property {Array.} failed An array of all segments that failed 71 | * @property {Array.} ok An array of all segments that were ok 72 | */ 73 | 74 | /** 75 | * @typedef ManifestVerifyResult 76 | * @type {Object} 77 | * @property {boolean} ok True if successful 78 | * @property {Object} headers The response headers for the manifest request. 79 | */ 80 | 81 | /** 82 | * Verifies that the timestamp of the last segment for a MPEG DASH live-stream 83 | * does not differ more than 10 seconds (default) from actual time. 84 | * 85 | * This is only applicable for live-streams and for VOD will always return OK 86 | * 87 | * @typedef TimestampResult 88 | * @type {Object} 89 | * @property {string} clock "OK" if ok or "BAD" if diff > allowedDiff 90 | * @property {string} clockOffset The actual diff between last segment and now 91 | * 92 | * @param {number} allowedDiff The allowed diff (in millisec, default is 10000) 93 | * @returns {Promise.} a Promise that resolves when the timing has been checked. 94 | */ 95 | DashValidator.prototype.verifyTimestamps = function verifyTimestamps(allowedDiff) { 96 | return new Promise((resolve, reject) => { 97 | const diffCriteria = allowedDiff || 10000; 98 | const result = {}; 99 | if (this._manifest.type === "static") { 100 | result.clock = "OK"; 101 | } else { 102 | const timeAtHead = this._manifest.timeAtHead; 103 | const d = new Date().getTime(); 104 | if (Math.abs(timeAtHead - d) > diffCriteria) { 105 | result.clock = "BAD"; 106 | result.clockOffset = Math.abs(timeAtHead - d); 107 | } else { 108 | result.clock = "OK"; 109 | result.clockOffset = Math.abs(timeAtHead - d); 110 | } 111 | } 112 | resolve(result); 113 | }); 114 | } 115 | 116 | /** 117 | * Verify that a list of segments can be downloaded and have correct HTTP headers 118 | * Applicable for both live and VOD. 119 | * 120 | * @param {Function(Object)} verifyFn Function that is called to verify a segment. 121 | * If not provided a default will be used 122 | * @param {Array.} segments An array of segment URIs 123 | * @param {boolean} doDownload When true use GET instead of HEAD 124 | * @returns {Promise.} a Promise that resolves when all segments are verified. 125 | */ 126 | DashValidator.prototype.verifySegments = function verifySegments(verifyFn, segments, doDownload) { 127 | return new Promise((resolve, reject) => { 128 | let failed = []; 129 | let ok = []; 130 | 131 | let it = util.iteratorFromArray(segments); 132 | const base = this._base; 133 | 134 | function checkSegment(doneCb) { 135 | const iter = it.next(); 136 | if (iter.done) { 137 | doneCb(); 138 | } else { 139 | const segmentUrl = iter.value; 140 | verifySegment(verifyFn || defaultVerifyFn, base + segmentUrl, doDownload).then((result) => { 141 | if (result.ok) { 142 | ok.push({ uri: segmentUrl }); 143 | } else { 144 | failed.push({ uri: segmentUrl, reason: result.reason, headers: result.headers }); 145 | } 146 | util.sleep(50); 147 | checkSegment(doneCb); 148 | }).catch((error) => { 149 | console.error(error); 150 | }); 151 | } 152 | } 153 | 154 | checkSegment(() => { 155 | resolve({ failed: failed, ok: ok}); 156 | }); 157 | }); 158 | }; 159 | 160 | /** 161 | * Verify that the manifest is ok. 162 | * 163 | * @param {Function(headers, type)} verifyFn Function that is called to verify a manifest. 164 | * If not provided a default will be used. 165 | * @returns {Promise.} a Promise that resolves when the manifest 166 | * is verified. 167 | */ 168 | DashValidator.prototype.verifyManifest = function verifyManifest(verifyFn) { 169 | return new Promise((resolve, reject) => { 170 | const verify = verifyFn || defaultManifestVerifyFn; 171 | const result = {}; 172 | result.ok = verify(this._manifestHeaders, this._manifest.type); 173 | result.headers = this._manifestHeaders; 174 | resolve(result); 175 | }); 176 | }; 177 | 178 | /** 179 | * Verify that all segments referred to by this MPEG DASH manifest is OK 180 | * 181 | * @param {Function(Object)} verifyFn Function that is called to verify a segment. 182 | * If not provided a default will be used 183 | * @param {boolean} doDownload When true use GET instead of HEAD 184 | * @returns {Promise.} a Promise that resolves when all segments are verified. 185 | */ 186 | DashValidator.prototype.verifyAllSegments = function verifyAllSegments(verifyFn, doDownload) { 187 | const segments = this._manifest.segments; 188 | return this.verifySegments(verifyFn, segments, doDownload); 189 | }; 190 | 191 | /** 192 | * Verify a random sample of segments (spotcheck) 193 | * 194 | * @param {Function(Object)} verifyFn Function that is called to verify a segment. 195 | * If not provided a default will be used 196 | * @param {number} noSamples The number of spotchecks to do 197 | * @param {boolean} doDownload When true use GET instead of HEAD 198 | * @returns {Promise.} a Promise that resolves when all segments are verified. 199 | */ 200 | DashValidator.prototype.spotcheckSegments = function spotcheckSegments(verifyFn, noSamples, doDownload) { 201 | const segments = this._manifest.segments; 202 | let i = 0; 203 | let spotchecks = []; 204 | while(i < noSamples) { 205 | spotchecks.push(util.getRandomItem(segments)); 206 | i++; 207 | } 208 | return this.verifySegments(verifyFn, spotchecks, doDownload); 209 | } 210 | 211 | /** 212 | * Validate a dynamically updated MPEG DASH manifest usually used for live 213 | * streaming 214 | * 215 | * @param {number} iterations Number of iterations to test 216 | * @param {Function} _optIterator For testing purposes 217 | * @returns {Promise} 218 | */ 219 | DashValidator.prototype.validateDynamicManifest = function validateDynamicManifest(iterations, _optIterator) { 220 | return new Promise((resolve, reject) => { 221 | this._runner.start(iterations, () => { 222 | return new Promise((resolveUpdateMpd) => { 223 | // Download, parse and update MPD 224 | util.requestXml(this._src).then(resp => { 225 | const parser = new DashParser(); 226 | parser.parse(resp.xml).then((manifest) => { 227 | this._manifest = manifest; 228 | this._runner.updateMpd(this._manifest, resp.headers); 229 | resolveUpdateMpd(); 230 | }) 231 | }); 232 | }); 233 | }, _optIterator) 234 | .then((result) => { 235 | resolve(result); 236 | }).catch(reject); 237 | }); 238 | }; 239 | 240 | DashValidator.prototype.on = function on(eventName, fn) { 241 | if (["invalidplayhead", "invalidheaders", "checking"].indexOf(eventName) != -1) { 242 | this._runner.on(eventName, fn); 243 | } 244 | }; 245 | 246 | /** 247 | * @returns {number} the total duration of the MPEG DASH manifest 248 | */ 249 | DashValidator.prototype.duration = function duration() { 250 | return this._manifest.totalDuration; 251 | }; 252 | 253 | /** 254 | * @returns {Array.} an array with all segment URIs referred to by this 255 | * MPEG DASH manifest 256 | */ 257 | DashValidator.prototype.segmentUrls = function segmentUrls() { 258 | return this._manifest.segments; 259 | }; 260 | 261 | /** 262 | * @returns {boolean} True if dynamic manifest, i.e. live stream 263 | */ 264 | DashValidator.prototype.isLive = function isLive() { 265 | return (this._manifest.type === "dynamic"); 266 | }; 267 | 268 | /** Private functions */ 269 | 270 | /** @private */ 271 | function defaultVerifyFn(headers) { 272 | let headersOk = true; 273 | if (typeof headers["cache-control"] === "undefined" || 274 | headers["access-control-expose-headers"].split(',').indexOf("Date") == -1 || 275 | headers["access-control-allow-headers"].split(',').indexOf("origin") == -1) 276 | { 277 | headersOk = false; 278 | } 279 | return headersOk; 280 | } 281 | 282 | function defaultManifestVerifyFn(headers, type) { 283 | if (type == "dynamic") { 284 | if (!headers["cache-control"]) { 285 | return false; 286 | } 287 | const m = headers["cache-control"].match(/max-age=(\d+)/); 288 | if (!m) { 289 | return false; 290 | } 291 | if (m[1] > 10) { 292 | // Max age for dynamic manifest should not cache this long 293 | return false; 294 | } 295 | } 296 | return true; 297 | } 298 | 299 | function verifySegment(verifyFn, segmentUrl, doDownload) { 300 | return new Promise((resolve, reject) => { 301 | const result = {}; 302 | 303 | let reqFn; 304 | if (!doDownload) { 305 | reqFn = util.requestHeaders; 306 | } else { 307 | reqFn = util.requestCacheFill; 308 | } 309 | reqFn(segmentUrl).then((headers) => { 310 | result.ok = verifyFn(headers); 311 | result.headers = headers; 312 | resolve(result); 313 | }).catch((err) => { 314 | result.ok = false; 315 | result.reason = err; 316 | resolve(result); 317 | }); 318 | }); 319 | } 320 | 321 | /** Create a Dash Validator object */ 322 | module.exports = DashValidator; 323 | -------------------------------------------------------------------------------- /jsdoc.conf.json: -------------------------------------------------------------------------------- 1 | { 2 | "source": { 3 | "include": [ 4 | "index.js" 5 | ] 6 | }, 7 | "opts": { 8 | "destination": "./docs/", 9 | "template": "node_modules/minami" 10 | } 11 | } -------------------------------------------------------------------------------- /karma.conf.js: -------------------------------------------------------------------------------- 1 | var istanbul = require("browserify-istanbul"); 2 | 3 | module.exports = function (config) { 4 | var configuration = { 5 | basePath: '', 6 | frameworks: ['browserify', 'jasmine-jquery', 'jasmine'], 7 | browserify: { 8 | debug: true, 9 | transform: [ 10 | ['babelify', {plugins: ['babel-plugin-espower']}], 11 | istanbul({ 12 | ignore: ["test/**", "**/node_modules/**"], 13 | instrumenterConfig: { 14 | embedSource: true 15 | } 16 | }) 17 | ], 18 | }, 19 | reporters: ['progress', 'coverage'], 20 | preprocessors: { 21 | 'index.js': ['browserify', 'coverage'], 22 | 'lib/**/*.js': ['browserify', 'coverage'], 23 | 'test/**/*.js': ['browserify'], 24 | }, 25 | files: [ 26 | 'node_modules/babel-polyfill/dist/polyfill.js', 27 | 'test/**/*_unit.js', 28 | { pattern: 'test/support/testassets/*.mpd', 29 | watched: true, 30 | served: true, 31 | included: false 32 | } 33 | ], 34 | browsers: ['Chrome'], 35 | singleRun: true, 36 | concurrency: Infinity, 37 | logLevel: config.LOG_INFO, 38 | browserNoActivityTimeout: 5 * 60 * 1000, 39 | customLaunchers: { 40 | Chrome_travis_ci: { 41 | base: 'Chrome', 42 | flags: ['--no-sandbox'] 43 | } 44 | }, 45 | coverageReporter: { 46 | dir: "coverage/", 47 | reporters: [ 48 | { type: "text-summary" }, 49 | { type: "html", subdir: "./" }, 50 | { type: "lcovonly", subdir: "./" } 51 | ] 52 | } 53 | }; 54 | if (process.env.TRAVIS) { 55 | configuration.browsers = ['Chrome_travis_ci']; 56 | } 57 | config.set(configuration); 58 | }; 59 | -------------------------------------------------------------------------------- /lib/dash_manifest.js: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Eyevinn Technology. All rights reserved 2 | // Use of this source code is governed by a MIT License 3 | // license that can be found in the LICENSE file. 4 | // Author: Jonas Birme (Eyevinn Technology) 5 | 6 | const util = require("./util.js"); 7 | 8 | const DashManifest = function constructor(internalMpd) { 9 | const self = { 10 | mpd: internalMpd, 11 | get type() { return this.mpd.type; }, 12 | get availabilityStartTime() { return util.dateInSeconds(this.mpd.availabilityStartTime); }, 13 | get publishTime() { return util.dateInSeconds(this.mpd.publishTime); }, 14 | get timeShiftBufferDepth() { return util.durationInSeconds(this.mpd.timeShiftBufferDepth); }, 15 | get periods() { return this.mpd.periods; }, 16 | get segments() { 17 | let segmentUrls = []; 18 | defaultFilterFn = function(as) { 19 | return (as.mimeType == "video/mp4"); 20 | }; 21 | filterFn = defaultFilterFn; 22 | this.mpd.periods.forEach((p) => { 23 | p.adaptationSets.filter(filterFn).forEach((as) => { 24 | as.representations.forEach((r) => { 25 | r.segments.forEach((seg) => { 26 | segmentUrls.push(p.baseUrl + seg.uri); 27 | }); 28 | }); 29 | }); 30 | }); 31 | return segmentUrls; 32 | }, 33 | get totalDuration() { 34 | let duration = 0; 35 | if (this.mpd.type === "dynamic") { return undefined; } 36 | this.mpd.periods.forEach((p) => { 37 | p.adaptationSets.filter((as) => as.mimeType == "video/mp4").forEach((as) => { 38 | duration += as.representations[0].segments.map(s => s.durationInSeconds).reduce((total, value) => total + value); 39 | }); 40 | }); 41 | return duration; 42 | }, 43 | get timeAtHead() { 44 | const lastPeriod = this.mpd.periods[this.mpd.periods.length - 1]; 45 | const as = lastPeriod.adaptationSets.filter(as => as.mimeType == "video/mp4")[0]; 46 | const segments = as.representations[0].segments; 47 | const lastSegment = segments[segments.length - 1]; 48 | return (lastSegment.end * 1000); 49 | }, 50 | }; 51 | return self; 52 | }; 53 | 54 | module.exports = DashManifest; 55 | -------------------------------------------------------------------------------- /lib/dash_parser.js: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Eyevinn Technology. All rights reserved 2 | // Use of this source code is governed by a MIT License 3 | // license that can be found in the LICENSE file. 4 | // Author: Jonas Birme (Eyevinn Technology) 5 | const DOMParser = require("xmldom").DOMParser; 6 | 7 | const DashManifest = require("./dash_manifest.js"); 8 | const DashSegmentList = require("./dash_segmentlist.js"); 9 | const DashRepresentation = require("./dash_representation.js"); 10 | const util = require("./util.js"); 11 | 12 | function parsePeriods(xml) { 13 | const periods = []; 14 | 15 | const children = util.findChildren(xml, "Period"); 16 | for(let i=0; i 0) { 45 | const segmentTemplateXml = segmentTemplateXmlChildren[0]; 46 | const timescale = segmentTemplateXml.getAttribute("timescale"); 47 | const media = segmentTemplateXml.getAttribute("media"); 48 | const segmentXmlChildren = util.findChildren(segmentTemplateXml, "SegmentTimeline"); 49 | const segmentListXmlChildren = util.findChildren(segmentXmlChildren[0], "S"); 50 | const timeline = []; 51 | for (let j=0; j { 67 | const representation = new DashRepresentation({ 68 | id: reprXml.getAttribute("id"), 69 | width: util.toNumber(reprXml.getAttribute("width")), 70 | height: util.toNumber(reprXml.getAttribute("height")), 71 | codecs: reprXml.getAttribute("codecs"), 72 | }, as.segmentList); 73 | as.representations.push(representation); 74 | }); 75 | adaptationsSets.push(as); 76 | } 77 | 78 | return adaptationsSets; 79 | } 80 | 81 | const DashParser = function constructor() { 82 | this.internalMpd = {}; 83 | return this; 84 | }; 85 | 86 | DashParser.prototype.parse = function parse(string) { 87 | let parser = new DOMParser(); 88 | let xml = null; 89 | 90 | return new Promise((resolve, reject) => { 91 | try { 92 | xml = parser.parseFromString(string, "text/xml"); 93 | } catch (exception) { reject(exception); } 94 | if (xml) { 95 | if (xml.documentElement.tagName == "MPD") { 96 | this.internalMpd.xml = xml.documentElement; 97 | } 98 | } 99 | if (!this.internalMpd.xml) { 100 | reject("Invalid XML"); 101 | } 102 | const mpdXml = this.internalMpd.xml; 103 | this.internalMpd.type = mpdXml.getAttribute("type") || "static"; 104 | this.internalMpd.availabilityStartTime = mpdXml.getAttribute("availabilityStartTime"); 105 | this.internalMpd.publishTime = mpdXml.getAttribute("publishTime"); 106 | this.internalMpd.timeShiftBufferDepth = mpdXml.getAttribute("timeShiftBufferDepth"); 107 | this.internalMpd.periods = parsePeriods(mpdXml); 108 | 109 | resolve(new DashManifest(this.internalMpd)); 110 | }); 111 | }; 112 | 113 | module.exports = DashParser; 114 | -------------------------------------------------------------------------------- /lib/dash_representation.js: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Eyevinn Technology. All rights reserved 2 | // Use of this source code is governed by a MIT License 3 | // license that can be found in the LICENSE file. 4 | // Author: Jonas Birme (Eyevinn Technology) 5 | 6 | const DashRepresentation = function constructor(representation, segmentList) { 7 | let segments_ = []; 8 | segmentList.segments.forEach((s) => { 9 | const segment = { 10 | t: s.t, 11 | start: s.start, 12 | end: s.end, 13 | durationInSeconds: s.durationInSeconds, 14 | uri: uriFromTemplate(segmentList.media, representation.id, s.t), 15 | }; 16 | segments_.push(segment); 17 | }); 18 | 19 | return { 20 | id: representation.id, 21 | rendition: { w: representation.width, h: representation.height }, 22 | codecs: representation.codecs, 23 | segmentUrls: segments_, 24 | 25 | get segments() { return this.segmentUrls; }, 26 | }; 27 | }; 28 | 29 | function uriFromTemplate(template, id, time) { 30 | let s = template; 31 | s = s.replace(/\$RepresentationID\$/, id); 32 | s = s.replace(/\$Time\$/, time); 33 | return s; 34 | } 35 | 36 | module.exports = DashRepresentation; 37 | -------------------------------------------------------------------------------- /lib/dash_segmentlist.js: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Eyevinn Technology. All rights reserved 2 | // Use of this source code is governed by a MIT License 3 | // license that can be found in the LICENSE file. 4 | // Author: Jonas Birme (Eyevinn Technology) 5 | 6 | const DashSegmentList = function constructor(template) { 7 | return { 8 | ts: template.timescale, 9 | mediaTemplate: template.media, 10 | startNumber: template.startNumber, 11 | segmentList: [], 12 | 13 | get timescale() { return this.ts; }, 14 | get segments() { return this.segmentList; }, 15 | get media() { return this.mediaTemplate; }, 16 | 17 | fromSegmentTimeline: function create(timeline) { 18 | let nextStart; 19 | 20 | for(let i=0; i { 35 | function timerFn() { 36 | mpdUpdateFn().then(() => { 37 | let allOk = true; 38 | this.trigger("checking", { mpd: this.mpd, headers: this.headers }); 39 | if (!hasValidPlayhead(this.mpd, this.headers)) { 40 | let failed = {}; 41 | failed.iteration = this.result.iterations; 42 | failed.reason = "Time at playhead is invalid"; 43 | failed.timeAtHead = new Date(this.mpd.timeAtHead).toISOString(); 44 | failed.timeNow = new Date().toISOString(); 45 | this.trigger("invalidplayhead", failed); 46 | this.result.failed.push(failed); 47 | allOk = false; 48 | } 49 | if (this.headers && !hasValidHeaders(this.lastHeaders, this.headers)) { 50 | let failed = {}; 51 | failed.iteration = this.result.iterations; 52 | failed.reason = "Invalid headers"; 53 | failed.headers = this.headers; 54 | this.trigger("invalidheaders", failed); 55 | this.result.failed.push(failed); 56 | allOk = false; 57 | } 58 | if (allOk) { 59 | this.result.ok++; 60 | } 61 | this.result.iterations++; 62 | this.lastHeaders = this.headers; 63 | if (this.result.iterations >= iterations) { 64 | resolve(this.result); 65 | } else { 66 | setTimeout(timerFn.bind(this), this.updateTime * 1000); 67 | } 68 | }); 69 | } 70 | 71 | setTimeout(timerFn.bind(this), this.updateTime * 1000); 72 | if (_optIterator) { 73 | _optIterator(); 74 | } 75 | }); 76 | }; 77 | 78 | /** 79 | * @param {DashManifest} mpd Updated manifest 80 | * @param {Object} headers 81 | */ 82 | DashValidatorRunner.prototype.updateMpd = function updateMpd(mpd, headers) { 83 | this.mpd = mpd; 84 | this.headers = headers; 85 | }; 86 | 87 | 88 | /** 89 | * @param {DashValidatorRunnerEvent} runnerEvent 90 | * @param {Function} fn 91 | */ 92 | DashValidatorRunner.prototype.on = function on(runnerEvent, fn) { 93 | const listener = { 94 | eventName: runnerEvent, 95 | fn: fn, 96 | }; 97 | this.listeners.push(listener); 98 | }; 99 | 100 | DashValidatorRunner.prototype.trigger = function trigger(runnerEvent, ...args) { 101 | this.listeners.filter(l => l.eventName == runnerEvent).forEach((l) => { 102 | if (l.fn) { 103 | if (args.length == 1) { 104 | l.fn(args[0]); 105 | } else { 106 | l.fn(args); 107 | } 108 | } 109 | }); 110 | }; 111 | 112 | /** Private functions */ 113 | 114 | /** 115 | * @param {DashManifest} mpd 116 | */ 117 | function hasValidPlayhead(mpd, headers) { 118 | let now; 119 | if (headers && headers["date"]) { 120 | now = new Date(headers["date"]).getTime(); 121 | //util.log("Reading now from date header", now); 122 | } else { 123 | now = Date.now(); 124 | //util.log("Reading now from system clock", now); 125 | } 126 | 127 | if (Math.abs(mpd.timeAtHead - now) > 18000) { 128 | //util.log("Diff", mpd.timeAtHead - now); 129 | return false; 130 | } 131 | return true; 132 | } 133 | 134 | function hasValidHeaders(lastHeaders, currentHeaders) { 135 | const lastDate = new Date(lastHeaders["date"]); 136 | const currentDate = new Date(currentHeaders["date"]); 137 | const lastModifiedDate = new Date(lastHeaders["last-modified"]); 138 | const currentModifiedDate = new Date(currentHeaders["last-modified"]); 139 | 140 | if (lastModifiedDate >= currentModifiedDate) { 141 | return false; 142 | } 143 | 144 | if (lastDate >= currentDate) { 145 | return false; 146 | } 147 | return true; 148 | } 149 | 150 | module.exports = DashValidatorRunner; -------------------------------------------------------------------------------- /lib/util.js: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Eyevinn Technology. All rights reserved 2 | // Use of this source code is governed by a MIT License 3 | // license that can be found in the LICENSE file. 4 | // Author: Jonas Birme (Eyevinn Technology) 5 | const request = require("request"); 6 | const URL = require("url"); 7 | const http = require("http"); 8 | const fs = require("fs"); 9 | 10 | const dateInSeconds = function(dateString) { 11 | if (!dateString) 12 | return null; 13 | 14 | var result = Date.parse(dateString); 15 | return (!isNaN(result) ? Math.floor(result / 1000.0) : null); 16 | } 17 | 18 | const durationInSeconds = function(durationString) { 19 | if (!durationString) 20 | return null; 21 | 22 | var re = '^P(?:([0-9]*)Y)?(?:([0-9]*)M)?(?:([0-9]*)D)?' + 23 | '(?:T(?:([0-9]*)H)?(?:([0-9]*)M)?(?:([0-9.]*)S)?)?$'; 24 | var matches = new RegExp(re).exec(durationString); 25 | 26 | if (!matches) { 27 | return null; 28 | } 29 | 30 | // Note: Number(null) == 0 but Number(undefined) == NaN. 31 | var years = Number(matches[1] || null); 32 | var months = Number(matches[2] || null); 33 | var days = Number(matches[3] || null); 34 | var hours = Number(matches[4] || null); 35 | var minutes = Number(matches[5] || null); 36 | var seconds = Number(matches[6] || null); 37 | 38 | // Assume a year always has 365 days and a month always has 30 days. 39 | var d = (60 * 60 * 24 * 365) * years + 40 | (60 * 60 * 24 * 30) * months + 41 | (60 * 60 * 24) * days + 42 | (60 * 60) * hours + 43 | 60 * minutes + 44 | seconds; 45 | return isFinite(d) ? d : null; 46 | } 47 | 48 | const findChildren = function(elem, name) { 49 | const children = Array.prototype.filter.call(elem.childNodes, function(child) { 50 | return child.tagName === name; 51 | }); 52 | return children; 53 | } 54 | 55 | const toNumber = function(xmlattr) { 56 | if (typeof xmlattr !== "undefined" && xmlattr !== "") { 57 | return Number(xmlattr); 58 | } 59 | return undefined; 60 | } 61 | 62 | const getBaseUrl = function(uri) { 63 | const sp = uri.split("/"); 64 | const baseUrl = sp.slice(0, -1).join("/"); 65 | return baseUrl; 66 | } 67 | 68 | const requestXml = function(uri) { 69 | return new Promise((resolve, reject) => { 70 | request(uri, (error, response, body) => { 71 | if (!error && response.statusCode == 200) { 72 | resolve({xml: body, headers: response.headers}); 73 | } 74 | reject(error); 75 | }); 76 | }); 77 | } 78 | 79 | const requestCacheFill = function(uri) { 80 | return new Promise((resolve, reject) => { 81 | let headers; 82 | let statusCode; 83 | const f = fs.createWriteStream("/dev/null"); 84 | f.on("error", (error) => { 85 | reject(error); 86 | }); 87 | 88 | request 89 | .get(uri) 90 | .on("response", (response) => { 91 | headers = response.headers; 92 | statusCode = response.statusCode; 93 | if (statusCode != 200) { 94 | reject("HTTP error " + statusCode); 95 | } 96 | }) 97 | .pipe(f) 98 | .on("error", (error) => { 99 | reject(error); 100 | }) 101 | .on("finish", () => { 102 | resolve(headers); 103 | }); 104 | }); 105 | } 106 | 107 | const requestHeaders = function(uri) { 108 | return new Promise((resolve, reject) => { 109 | const url = URL.parse(uri); 110 | const options = { 111 | method: "HEAD", 112 | host: url.host, 113 | path: url.path, 114 | } 115 | const req = http.request(options, (response) => { 116 | if (response.statusCode == 200) { 117 | resolve(response.headers); 118 | } 119 | reject(response.statusCode); 120 | }); 121 | req.end(); 122 | }); 123 | } 124 | 125 | const iteratorFromArray = function(arr) { 126 | let nextIndex = 0; 127 | 128 | return { 129 | next: function() { 130 | return nextIndex < arr.length ? 131 | { value: arr[nextIndex++], done: false } : 132 | { done: true }; 133 | } 134 | }; 135 | } 136 | 137 | const getRandomItem = function(arr) { 138 | return arr[Math.floor(Math.random() * arr.length)]; 139 | } 140 | 141 | const sleep = function(millisec) { 142 | const date = new Date(); 143 | do { 144 | d = new Date(); 145 | } while (d - date < millisec); 146 | } 147 | 148 | const log = function(str, ...args) { 149 | if (args.length > 0) { 150 | console.log(str, args); 151 | } else { 152 | console.log(str); 153 | } 154 | } 155 | 156 | module.exports = { 157 | durationInSeconds, 158 | dateInSeconds, 159 | findChildren, 160 | toNumber, 161 | requestXml, 162 | requestHeaders, 163 | requestCacheFill, 164 | iteratorFromArray, 165 | getRandomItem, 166 | getBaseUrl, 167 | sleep, 168 | log, 169 | } 170 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dash-validator", 3 | "version": "0.5.1", 4 | "description": "JS library to validate MPEG DASH manifests and segments", 5 | "main": "index.js", 6 | "engines": { 7 | "node": "6.9.1" 8 | }, 9 | "repository": "https://github.com/Eyevinn/dash-validator-js", 10 | "scripts": { 11 | "docs": "$(npm bin)/jsdoc -c jsdoc.conf.json", 12 | "test": "$(npm bin)/karma start karma.conf.js", 13 | "coveralls": "cat ./coverage/lcov.info | coveralls", 14 | "clean": "rm -rf dist/* docs/*", 15 | "prebuild": "npm run clean && npm run test && npm run docs", 16 | "build": "browserify index.js global_exports.js -o dist/dashvalidator.js -t [ babelify --presets es2015 ] && $(npm bin)/uglifyjs dist/dashvalidator.js -o dist/dashvalidator.min.js", 17 | "version": "npm run build && git add -A dist && git add -A docs", 18 | "postversion": "git push && git push --tags" 19 | }, 20 | "author": "Jonas Birme (http://eyvinn.github.io)", 21 | "license": "MIT", 22 | "devDependencies": { 23 | "babel-plugin-espower": "^2.3.1", 24 | "babel-polyfill": "^6.20.0", 25 | "babel-preset-es2015": "^6.18.0", 26 | "babelify": "^7.3.0", 27 | "browserify": "^13.1.1", 28 | "browserify-istanbul": "^2.0.0", 29 | "coveralls": "^2.11.15", 30 | "jasmine": "^2.5.2", 31 | "jasmine-jquery": "^2.1.1", 32 | "jsdoc": "^3.4.3", 33 | "karma": "^1.3.0", 34 | "karma-browserify": "^5.1.0", 35 | "karma-chrome-launcher": "^2.0.0", 36 | "karma-coverage": "^1.1.1", 37 | "karma-generic-preprocessor": "^1.1.0", 38 | "karma-jasmine": "^1.1.0", 39 | "karma-jasmine-jquery": "^0.1.1", 40 | "minami": "^1.1.1", 41 | "mockdate": "^2.0.1", 42 | "watchify": "^3.8.0" 43 | }, 44 | "dependencies": { 45 | "request": "^2.79.0", 46 | "xmldom": "^0.1.27" 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /test/dash_validator_unit.js: -------------------------------------------------------------------------------- 1 | const MockDate = require("mockdate"); 2 | const DashValidator = require("../index.js"); 3 | const util = require("../lib/util.js"); 4 | const TestAssetsModule = require("./support/testassets.js"); 5 | 6 | describe("Dash Validator", () => { 7 | let failCount; 8 | let requestFailType; 9 | let mockManifestHeaders; 10 | let dynamicCount = 1; 11 | 12 | beforeEach((done) => { 13 | jasmine.clock().install(); 14 | 15 | spyOn(util, "requestXml").and.callFake((uri) => { 16 | return new Promise((resolve, reject) => { 17 | const testAssets = new TestAssetsModule(); 18 | if (uri.match("MOCK-DYNAMIC")) { 19 | const asset = testAssets.getAssetByName("dynamic." + dynamicCount + ".mpd"); 20 | dynamicCount++; 21 | resolve({ xml: asset.xml, headers: mockManifestHeaders }); 22 | } else { 23 | const m = uri.match(/^.*\/(.*?)\.mpd$/); 24 | const asset = testAssets.getAssetByName(m[1]); 25 | resolve({ xml: asset.xml, headers: mockManifestHeaders }); 26 | } 27 | }); 28 | }); 29 | 30 | spyOn(util, "sleep").and.callFake(() => { 31 | return; 32 | }); 33 | 34 | spyOn(util, "log").and.callFake(() => { 35 | return; 36 | }); 37 | 38 | failCount = 0; 39 | requestFailType = "headers"; /* {headers|httperror} */ 40 | mockManifestHeaders = {}; 41 | 42 | spyOn(util, "requestHeaders").and.callFake((uri) => { 43 | return new Promise((resolve, reject) => { 44 | const mockHeaders = { 45 | date: 'Thu, 12 Jan 2017 15:19:42 GMT', 46 | 'content-type': 'video/mp4', 47 | 'content-length': '24792', 48 | connection: 'close', 49 | 'cache-control': 'max-age=2592000', 50 | etag: '"1"', 51 | expires: 'Sun, 12 Feb 2017 08:36:45 GMT', 52 | 'last-modified': 'Thu, 12 Jan 2017 15:18:04 GMT', 53 | server: 'Apache/2.4.7 (Ubuntu)', 54 | 'access-control-allow-headers': 'origin, range, x-cdn-forward', 55 | 'access-control-allow-origin': '*', 56 | 'access-control-expose-headers': 'Server,range,Date,x-cdn-forward', 57 | 'timing-allow-origin': '*', 58 | 'x-cdn-forward': 'Level3', 59 | 'x-usp': 'version=1.7.18 (7923)', 60 | age: '623144', 61 | 'accept-ranges': 'bytes' 62 | }; 63 | const mockFailHeaders = { 64 | date: 'Thu, 12 Jan 2017 15:19:42 GMT', 65 | 'content-type': 'video/mp4', 66 | 'content-length': '24792', 67 | connection: 'close', 68 | etag: '"1"', 69 | 'last-modified': 'Thu, 12 Jan 2017 15:18:04 GMT', 70 | server: 'Apache/2.4.7 (Ubuntu)', 71 | 'access-control-allow-headers': 'range', 72 | 'access-control-allow-origin': '*', 73 | 'access-control-expose-headers': 'Server,range', 74 | 'timing-allow-origin': '*', 75 | 'x-usp': 'version=1.7.18 (7923)', 76 | age: '623144', 77 | 'accept-ranges': 'bytes' 78 | }; 79 | if (requestFailType === "headers") { 80 | if (failCount < 5) { 81 | resolve(mockFailHeaders); 82 | failCount++; 83 | } 84 | resolve(mockHeaders); 85 | } else if (requestFailType === "httperror") { 86 | reject("HTTP error 500"); 87 | } 88 | }); 89 | }); 90 | 91 | spyOn(util, "requestCacheFill").and.callFake((uri) => { 92 | return new Promise((resolve, reject) => { 93 | reject("HTTP error 404"); 94 | }); 95 | }); 96 | 97 | done(); 98 | }); 99 | 100 | afterEach((done) => { 101 | MockDate.reset(); 102 | jasmine.clock().uninstall(); 103 | done(); 104 | }); 105 | 106 | it("can load and parse an MPD", (done) => { 107 | const validator = new DashValidator("http://mock.example.com/usp-vod.mpd"); 108 | validator.load().then(() => { 109 | expect(validator.isLive()).toBe(false); 110 | const duration = validator.duration(); 111 | expect(duration).toBe(9719.68); 112 | done(); 113 | }).catch(fail).then(done); 114 | }); 115 | 116 | it("can verify a live manifest", (done) => { 117 | mockManifestHeaders = { 118 | "cache-control": "max-age=2000", 119 | }; 120 | const validator = new DashValidator("http://mock.example.com/usp-live.mpd"); 121 | validator.load().then(() => { 122 | expect(validator.isLive()).toBe(true); 123 | validator.verifyManifest().then(result => { 124 | expect(result.ok).toBe(false); 125 | expect(result.headers["cache-control"]).toBe("max-age=2000"); 126 | done(); 127 | }); 128 | }).catch(fail).then(done); 129 | }); 130 | 131 | it("can verify all segments", (done) => { 132 | requestFailType = "headers"; 133 | const validator = new DashValidator("http://mock.example.com/usp-vod.mpd"); 134 | validator.load().then(() => { 135 | validator.verifyAllSegments(null, false).then(result => { 136 | expect(result.failed.length).toBe(5); 137 | result.failed.forEach(f => { 138 | expect(f.headers["cache-control"]).toBe(undefined); 139 | expect(f.headers["access-control-expose-headers"].split(",").indexOf("Date")).toBe(-1); 140 | expect(f.headers["access-control-allow-headers"].split(",").indexOf("origin")).toBe(-1); 141 | }); 142 | done(); 143 | }); 144 | }).catch(fail).then(done); 145 | }); 146 | 147 | it("can verify all segments using a custom verify function", (done) => { 148 | requestFailType = "headers"; 149 | const validator = new DashValidator("http://mock.example.com/usp-vod.mpd"); 150 | function customVerifyFn(headers) { 151 | if (headers["server"] === "Apache/2.4.7 (Ubuntu)") { 152 | return false; 153 | } 154 | return true; 155 | } 156 | validator.load().then(() => { 157 | const segments = validator.segmentUrls().slice(0, 100); 158 | validator.verifySegments(customVerifyFn, segments, false).then(result => { 159 | expect(result.failed.length).toBe(100); 160 | done(); 161 | }); 162 | }).catch(fail).then(done); 163 | }); 164 | 165 | it("can spotcheck 10 segments using a custom verify function", (done) => { 166 | requestFailType = "headers"; 167 | const validator = new DashValidator("http://mock.example.com/usp-vod.mpd"); 168 | function customVerifyFn(headers) { 169 | if (headers["server"] === "Apache/2.4.7 (Ubuntu)") { 170 | return false; 171 | } 172 | return true; 173 | } 174 | validator.load().then(() => { 175 | validator.spotcheckSegments(customVerifyFn, 10, false).then(result => { 176 | expect(result.failed.length).toBe(10); 177 | done(); 178 | }); 179 | }).catch(fail).then(done); 180 | }); 181 | 182 | it("should fail a segment if HTTP request fails", (done) => { 183 | requestFailType = "httperror"; 184 | const validator = new DashValidator("http://mock.example.com/usp-vod.mpd"); 185 | validator.load().then(() => { 186 | const segments = validator.segmentUrls().slice(0, 100); 187 | validator.verifySegments(null, segments, false).then((result) => { 188 | expect(result.failed.length).toBe(100); 189 | expect(result.failed[0].reason).toBe("HTTP error 500"); 190 | done(); 191 | }).catch((error) => { 192 | console.error(error); 193 | }).then(done); 194 | }).catch(fail).then(done); 195 | }); 196 | 197 | it("should fail a segment if it cannot be downloaded", (done) => { 198 | const validator = new DashValidator("http://mock.example.com/usp-vod.mpd"); 199 | validator.load().then(() => { 200 | const segments = validator.segmentUrls().slice(50, 70); 201 | validator.verifySegments(null, segments, true).then((result) => { 202 | expect(result.failed.length).toBe(20); 203 | expect(result.failed[0].reason).toBe("HTTP error 404"); 204 | done(); 205 | }).catch((error) => { 206 | console.error(error); 207 | }).then(done); 208 | }).catch(fail).then(done); 209 | }); 210 | 211 | it("should fail a manifest if playhead is out of bounds", (done) => { 212 | MockDate.set(new Date("2016-12-23T19:20:58.692000Z")); 213 | const validator = new DashValidator("http://mock.example.com/usp-live.mpd"); 214 | validator.load().then(() => { 215 | validator.verifyTimestamps(10000).then((result) => { 216 | expect(result.clock).toBe("BAD"); 217 | expect(result.clockOffset).toBe(122000); 218 | done(); 219 | }).catch((error) => { 220 | console.error(error); 221 | }).then(done); 222 | }).catch(fail).then(done); 223 | }); 224 | 225 | it("should approve a manifest if playhead is within bounds", (done) => { 226 | MockDate.set(new Date("2016-12-23T19:18:59.692000Z")); 227 | const validator = new DashValidator("http://mock.example.com/usp-live.mpd"); 228 | validator.load().then(() => { 229 | validator.verifyTimestamps(10000).then((result) => { 230 | expect(result.clock).toBe("OK"); 231 | expect(result.clockOffset).toBe(3000); 232 | done(); 233 | }).catch((error) => { 234 | console.error(error); 235 | }).then(done); 236 | }).catch(fail).then(done); 237 | }); 238 | 239 | it("should approve a manifest that is static no matter what playhead it has", (done) => { 240 | MockDate.set(new Date("2016-12-21T19:18:59.692000Z")); 241 | const validator = new DashValidator("http://mock.example.com/usp-vod.mpd"); 242 | validator.load().then(() => { 243 | validator.verifyTimestamps(10000).then((result) => { 244 | expect(result.clock).toBe("OK"); 245 | done(); 246 | }).catch((error) => { 247 | console.error(error); 248 | }).then(done); 249 | }).catch(fail).then(done); 250 | }); 251 | 252 | it("should fail a dynamic manifest that is not updating headers correctly", (done) => { 253 | MockDate.set(new Date("2017-01-28T10:04:28.424270Z")); 254 | const validator = new DashValidator("http://mock.example.com/MOCK-DYNAMIC.mpd"); 255 | validator.load().then(() => { 256 | function onIteration() { 257 | jasmine.clock().tick(10000); 258 | } 259 | validator.validateDynamicManifest(2, onIteration).then((result) => { 260 | expect(result.iterations).toBe(2); 261 | expect(result.failed.length).toBe(2); 262 | done(); 263 | }).catch((error) => { 264 | console.error(error); 265 | }).then(done); 266 | }).catch(fail).then(done); 267 | }); 268 | }); 269 | -------------------------------------------------------------------------------- /test/lib/dash_manifest_unit.js: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Eyevinn Technology. All rights reserved 2 | // Use of this source code is governed by a MIT License 3 | // license that can be found in the LICENSE file. 4 | // Author: Jonas Birme (Eyevinn Technology) 5 | 6 | const DashManifest = require("../../lib/dash_manifest.js"); 7 | const DashParserModule = require("../../lib/dash_parser.js"); 8 | const TestAssetsModule = require("../support/testassets.js"); 9 | 10 | describe("DashManifest API", () => { 11 | it("can return type", () => { 12 | const mpd = new DashManifest({ type: "dynamic" }); 13 | expect(mpd.type).toBe("dynamic"); 14 | }); 15 | 16 | it("can return availability start time in seconds", () => { 17 | const mpdA = new DashManifest({ availabilityStartTime: "1970-01-01T00:00:00Z" }); 18 | expect(mpdA.availabilityStartTime).toBe(0); 19 | const mpdB = new DashManifest({ availabilityStartTime: "2016-12-24T09:04:06Z" }); 20 | expect(mpdB.availabilityStartTime).toBe(1482570246); 21 | const mpdC = new DashManifest({ availabilityStartTime: "2016-12-35T09:04:06Z" }); 22 | expect(mpdC.availabilityStartTime).toBe(null); 23 | }); 24 | 25 | it("can return publish time in seconds", () => { 26 | const mpd = new DashManifest({ publishTime: "2016-12-23T19:17:47.832317Z" }); 27 | expect(mpd.publishTime).toBe(1482520667); 28 | }); 29 | 30 | it("can return timeshift buffer depth in seconds", () => { 31 | const mpd = new DashManifest({ timeShiftBufferDepth: "PT1H" }); 32 | expect(mpd.timeShiftBufferDepth).toBe(3600); 33 | }); 34 | 35 | it("can return an array of periods", () => { 36 | const periods = []; 37 | periods.push({ 38 | id: "1", 39 | start: 0, 40 | adaptationsSets: [{ 41 | contentType: "audio", 42 | mimeType: "audio/mp4", 43 | bandwidth: { min: 96000, max: 96000 }, 44 | }], 45 | }); 46 | const mpd = new DashManifest({ periods: periods }); 47 | expect(mpd.periods.length).toBe(1); 48 | expect(mpd.periods[0].id).toBe("1"); 49 | expect(mpd.periods[0].start).toBe(0); 50 | expect(mpd.periods[0].adaptationsSets[0].contentType).toBe("audio"); 51 | }); 52 | 53 | it("can return a list of all segment urls", (done) => { 54 | const testAssets = new TestAssetsModule(); 55 | const asset = testAssets.getAssetByName("usp-vod"); 56 | const parser = new DashParserModule(); 57 | parser.parse(asset.xml).then((mpd) => { 58 | //console.log(mpd.segments); 59 | done(); 60 | }).catch(fail).then(done); 61 | }); 62 | 63 | it("can calculate a total duration for VOD", (done) => { 64 | const testAssets = new TestAssetsModule(); 65 | const asset = testAssets.getAssetByName("usp-vod"); 66 | const parser = new DashParserModule(); 67 | parser.parse(asset.xml).then((mpd) => { 68 | expect(mpd.totalDuration).toBe(9719.68); 69 | done(); 70 | }).catch(fail).then(done); 71 | }); 72 | 73 | it("is not able to calculate a total duration for Live", (done) => { 74 | const testAssets = new TestAssetsModule(); 75 | const asset = testAssets.getAssetByName("usp-live"); 76 | const parser = new DashParserModule(); 77 | parser.parse(asset.xml).then((mpd) => { 78 | expect(mpd.totalDuration).toBe(undefined); 79 | done(); 80 | }).catch(fail).then(done); 81 | }); 82 | }); 83 | -------------------------------------------------------------------------------- /test/lib/dash_parser_unit.js: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Eyevinn Technology. All rights reserved 2 | // Use of this source code is governed by a MIT License 3 | // license that can be found in the LICENSE file. 4 | // Author: Jonas Birme (Eyevinn Technology) 5 | 6 | const DashParserModule = require("../../lib/dash_parser.js"); 7 | const TestAssetsModule = require("../support/testassets.js"); 8 | 9 | describe("Dash Parser", () => { 10 | it("can parse an MPEG DASH live manifest from USP", function t(done) { 11 | const testAssets = new TestAssetsModule(); 12 | const asset = testAssets.getAssetByName("usp-live"); 13 | const parser = new DashParserModule(); 14 | parser.parse(asset.xml).then((mpd) => { 15 | expect(mpd.type).toBe("dynamic"); 16 | expect(mpd.availabilityStartTime).toBe(0); 17 | expect(mpd.publishTime).toBe(1482520667); 18 | expect(mpd.timeShiftBufferDepth).toBe(3600); 19 | expect(mpd.periods.length).toBe(1); 20 | expect(mpd.periods[0].start).toBe(0); 21 | expect(mpd.periods[0].adaptationSets.length).toBe(3); 22 | expect(mpd.periods[0].adaptationSets[0].bandwidth.min).toBe(96000); 23 | 24 | const segments = mpd.periods[0].adaptationSets[0].segmentList.segments; 25 | expect(Math.floor(segments[0].start)).toBe(1482517136); 26 | 27 | done(); 28 | }).catch(fail).then(done); 29 | }); 30 | 31 | it("can parse an MPEG DASH vod manifest from USP", function t(done) { 32 | const testAssets = new TestAssetsModule(); 33 | const asset = testAssets.getAssetByName("usp-vod"); 34 | const parser = new DashParserModule(); 35 | parser.parse(asset.xml).then((mpd) => { 36 | expect(mpd.type).toBe("static"); 37 | 38 | expect(mpd.periods[0].adaptationSets[5].contentType).toBe("video"); 39 | expect(mpd.periods[0].baseUrl).toBe("dash/"); 40 | const segments = mpd.periods[0].adaptationSets[5].segmentList.segments; 41 | expect(segments.length).toBe(3240); 42 | expect(segments[0].start).toBe(0); 43 | expect(segments[0].end).toBe(3); 44 | expect(segments[1].t).toBe(75); 45 | 46 | const representations = mpd.periods[0].adaptationSets[5].representations; 47 | expect(representations.length).toBe(7); 48 | expect(representations[0].id).toBe("video=253000"); 49 | representations[0].segments.forEach((seg) => { 50 | expect(seg.uri).toBe("INTERSTELLAR(3541935_ISM)-" + representations[0].id + "-" + seg.t + ".dash"); 51 | }); 52 | const numSegments = representations[0].segments.length; 53 | expect(representations[0].segments[numSegments-1].t).toBe(242925); 54 | done(); 55 | }).catch(fail).then(done); 56 | }); 57 | }); 58 | -------------------------------------------------------------------------------- /test/lib/dash_representation_unit.js: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Eyevinn Technology. All rights reserved 2 | // Use of this source code is governed by a MIT License 3 | // license that can be found in the LICENSE file. 4 | // Author: Jonas Birme (Eyevinn Technology) 5 | 6 | const DashRepresentation = require("../../lib/dash_representation.js"); 7 | const DashSegmentList = require("../../lib/dash_segmentlist.js"); 8 | 9 | describe("DashRepresentation", () => { 10 | it("can handle four video representations", () => { 11 | const segmentList = new DashSegmentList({ 12 | timescale: 25, 13 | media: "INTERSTELLAR(3541935_ISM)-$RepresentationID$-$Time$.dash", 14 | startNumber: 1, 15 | }); 16 | segmentList.fromSegmentTimeline([ {t: 0, d: 75, r:3239}, {d:67} ]); 17 | expect(segmentList.media).toBe("INTERSTELLAR(3541935_ISM)-$RepresentationID$-$Time$.dash"); 18 | const representations = [ 19 | { id: "video=253000", width: 384, height: 216, codecs: "avc1.42401E" }, 20 | { id: "video=1404000", width: 768, height: 432, codecs: "avc1.4D401E" }, 21 | { id: "video=3216000", width: 1280, height: 720, codecs: "avc1.4D4032" }, 22 | { id: "video=6002000", width: 1920, height: 1080, codecs: "avc1.4D4032" }, 23 | ]; 24 | representations.forEach((r) => { 25 | const representation = new DashRepresentation(r, segmentList); 26 | const segments = representation.segments; 27 | expect(segments.length).toBe(3240); 28 | expect(segments[0].uri).toBe("INTERSTELLAR(3541935_ISM)-" + r.id + "-0.dash"); 29 | expect(segments[1].uri).toBe("INTERSTELLAR(3541935_ISM)-" + r.id + "-75.dash"); 30 | expect(segments[2].uri).toBe("INTERSTELLAR(3541935_ISM)-" + r.id + "-150.dash"); 31 | expect(segments[3239].uri).toBe("INTERSTELLAR(3541935_ISM)-" + r.id + "-242925.dash"); 32 | }); 33 | }); 34 | }); 35 | -------------------------------------------------------------------------------- /test/lib/dash_segmentlist_unit.js: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Eyevinn Technology. All rights reserved 2 | // Use of this source code is governed by a MIT License 3 | // license that can be found in the LICENSE file. 4 | // Author: Jonas Birme (Eyevinn Technology) 5 | 6 | const DashSegmentList = require("../../lib/dash_segmentlist.js"); 7 | 8 | describe("DashSegmentList", () => { 9 | 10 | it("can handle a timeline based on segment template", () => { 11 | const segmentList = new DashSegmentList({ 12 | timescale: 48000, 13 | }); 14 | const timeline = [ 15 | { t: 71160822564966, d: 96256 }, 16 | { d: 95232 }, 17 | { d: 96256, r: 2 }, 18 | ]; 19 | segmentList.fromSegmentTimeline(timeline); 20 | expect(segmentList.timescale).toBe(48000); 21 | expect(Math.floor(segmentList.segments[0].start)).toBe(1482517136); 22 | expect(segmentList.segments[0].t).toBe(71160822564966); 23 | expect(Math.floor(segmentList.segments[1].start)).toBe(1482517138); 24 | expect(Math.floor(segmentList.segments[2].start)).toBe(1482517140); 25 | expect(segmentList.segments.length).toBe(4); 26 | }); 27 | it("can handle a VOD timeline based on segment template", () => { 28 | const segmentList = new DashSegmentList({ 29 | timescale: 25, 30 | }); 31 | const timeline = [ 32 | { t: 0, d: 75, r: 3239 }, 33 | { d: 67 }, 34 | ]; 35 | segmentList.fromSegmentTimeline(timeline); 36 | expect(segmentList.timescale).toBe(25); 37 | expect(segmentList.segments.length).toBe(3240); 38 | expect(segmentList.segments[0].start).toBe(0); 39 | expect(segmentList.segments[0].end).toBe(3); 40 | expect(segmentList.segments[1].t).toBe(75); 41 | expect(segmentList.segments[1].durationInSeconds).toBe(3); 42 | expect(segmentList.segments[3239].t).toBe(242925); 43 | }); 44 | }); 45 | -------------------------------------------------------------------------------- /test/lib/dash_validator_runner_unit.js: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Eyevinn Technology. All rights reserved 2 | // Use of this source code is governed by a MIT License 3 | // license that can be found in the LICENSE file. 4 | // Author: Jonas Birme (Eyevinn Technology) 5 | const MockDate = require("mockdate"); 6 | const DashValidatorRunner = require("../../lib/dash_validator_runner.js"); 7 | const DashManifest = require("../../lib/dash_manifest.js"); 8 | const TestAssetsModule = require("../support/testassets.js"); 9 | 10 | describe("Dash Validator Runner", () => { 11 | let testAssets; 12 | let publishTime; 13 | 14 | beforeEach((done) => { 15 | testAssets = new TestAssetsModule(); 16 | publishTime = new Date("2016-12-23T19:17:47.832317Z"); 17 | jasmine.clock().install(); 18 | done(); 19 | }); 20 | 21 | afterEach((done) => { 22 | MockDate.reset(); 23 | jasmine.clock().uninstall(); 24 | done(); 25 | }); 26 | 27 | it("can handle a correct dynamic mpd", (done) => { 28 | let d = new Date("2017-01-23T17:15:00.000000Z"); 29 | MockDate.set(d); 30 | let start = new Date("2017-01-23T16:15:00.000000Z"); 31 | let dynamicMpd = 32 | testAssets.generateDynamicManifest(publishTime, start, 3); 33 | let mpd = new DashManifest(dynamicMpd); 34 | const validatorRunner = new DashValidatorRunner(mpd, null, 10); 35 | let loopCount = 1; 36 | 37 | function mpdUpdater() { 38 | return new Promise((resolve) => { 39 | dynamicMpd = 40 | testAssets.generateDynamicManifest(publishTime, 41 | new Date(start.getTime() + (10000 * loopCount)), 3); 42 | mpd = new DashManifest(dynamicMpd); 43 | validatorRunner.updateMpd(mpd, null); 44 | MockDate.set(d.getTime() + (10000 * loopCount)); 45 | loopCount++; 46 | resolve(); 47 | }); 48 | } 49 | 50 | validatorRunner.start(1, mpdUpdater).then((result) => { 51 | expect(result.ok).toBe(1); 52 | expect(result.iterations).toBe(1); 53 | done(); 54 | }).catch(fail).then(done); 55 | jasmine.clock().tick(10000); 56 | }); 57 | 58 | it("can handle a stale dynamic mpd", (done) => { 59 | const d = new Date("2017-01-24T08:10:00.000000Z"); 60 | MockDate.set(d); 61 | const start = new Date("2017-01-24T07:00:00.000000Z"); 62 | const staleMpd = testAssets.generateDynamicManifest(publishTime, start, 3); 63 | let mpd = new DashManifest(staleMpd); 64 | const validatorRunner = new DashValidatorRunner(staleMpd, null, 10); 65 | let loopCount = 1; 66 | 67 | function mpdUpdater() { 68 | return new Promise((resolve) => { 69 | validatorRunner.updateMpd(mpd, null); 70 | MockDate.set(d.getTime() + (10000 * loopCount)); 71 | loopCount++; 72 | resolve(); 73 | }); 74 | }; 75 | validatorRunner.start(1, mpdUpdater).then((result) => { 76 | expect(result.ok).toBe(0); 77 | expect(result.iterations).toBe(1); 78 | done(); 79 | }); 80 | jasmine.clock().tick(10000); 81 | }); 82 | 83 | it("can handle a dynamic mpd with bad headers", (done) => { 84 | let d = new Date("2017-01-23T17:15:00.000000Z"); 85 | MockDate.set(d); 86 | let start = new Date("2017-01-23T16:15:00.000000Z"); 87 | let dynamicMpd = 88 | testAssets.generateDynamicManifest(publishTime, start, 3); 89 | let mpd = new DashManifest(dynamicMpd); 90 | const badHeaders = { 91 | date: new Date("2017-01-23T17:15:00.000000Z"), 92 | "last-modified": new Date("2017-01-23T17:15:00.000000Z") 93 | } 94 | const validatorRunner = new DashValidatorRunner(mpd, badHeaders, 10); 95 | let loopCount = 1; 96 | 97 | function mpdUpdater() { 98 | return new Promise((resolve) => { 99 | dynamicMpd = 100 | testAssets.generateDynamicManifest(publishTime, 101 | new Date(start.getTime() + (10000 * loopCount)), 3); 102 | mpd = new DashManifest(dynamicMpd); 103 | validatorRunner.updateMpd(mpd, badHeaders); 104 | MockDate.set(d.getTime() + (10000 * loopCount)); 105 | loopCount++; 106 | resolve(); 107 | }); 108 | } 109 | 110 | validatorRunner.start(1, mpdUpdater).then((result) => { 111 | expect(result.failed.length).toBe(1); 112 | expect(result.iterations).toBe(1); 113 | done(); 114 | }).catch(fail).then(done); 115 | jasmine.clock().tick(10000); 116 | }); 117 | 118 | it("can handle a dynamic mpd with correct headers", (done) => { 119 | let d = new Date("2017-01-23T17:15:00.000000Z"); 120 | MockDate.set(d); 121 | let start = new Date("2017-01-23T16:15:00.000000Z"); 122 | let dynamicMpd = 123 | testAssets.generateDynamicManifest(publishTime, start, 3); 124 | let mpd = new DashManifest(dynamicMpd); 125 | const correctHeaders = { 126 | date: new Date("2017-01-23T17:15:00.000000Z"), 127 | "last-modified": new Date("2017-01-23T17:15:00.000000Z"), 128 | } 129 | const validatorRunner = new DashValidatorRunner(mpd, correctHeaders, 10); 130 | let loopCount = 1; 131 | 132 | function mpdUpdater() { 133 | return new Promise((resolve) => { 134 | const newCorrectHeaders = { 135 | date: new Date("2017-01-23T17:15:15.000000Z"), 136 | "last-modified": new Date("2017-01-23T17:15:15.000000Z") 137 | }; 138 | dynamicMpd = 139 | testAssets.generateDynamicManifest(publishTime, 140 | new Date(start.getTime() + (10000 * loopCount)), 3); 141 | mpd = new DashManifest(dynamicMpd); 142 | validatorRunner.updateMpd(mpd, newCorrectHeaders); 143 | MockDate.set(d.getTime() + (10000 * loopCount)); 144 | loopCount++; 145 | resolve(); 146 | }); 147 | } 148 | 149 | validatorRunner.start(1, mpdUpdater).then((result) => { 150 | expect(result.ok).toBe(1); 151 | expect(result.iterations).toBe(1); 152 | done(); 153 | }).catch(fail).then(done); 154 | jasmine.clock().tick(10000); 155 | }); 156 | it("can handle event listeners", (done) => { 157 | const runner = new DashValidatorRunner({}, null, 10); 158 | runner.on("testevent1", args => { 159 | expect(args.foo).toBe("bar"); 160 | }); 161 | runner.on("testevent2", args => { 162 | expect(args[0]).toBe("arg1"); 163 | expect(args[1]).toBe("arg2"); 164 | }); 165 | runner.trigger("testevent1", { foo: "bar" }); 166 | runner.trigger("testevent2", "arg1", "arg2"); 167 | done(); 168 | }); 169 | }); -------------------------------------------------------------------------------- /test/lib/util_unit.js: -------------------------------------------------------------------------------- 1 | const util = require("../../lib/util.js"); 2 | const request = require("request"); 3 | const TestAssetsModule = require("../support/testassets.js"); 4 | 5 | describe("Util Function", () => { 6 | describe("request helpers", () => { 7 | it("can request an XML body", (done) => { 8 | const testAssets = new TestAssetsModule(); 9 | const asset = testAssets.getAssetByName("usp-vod"); 10 | spyOn(request, "Request").and.callFake((params) => { 11 | params.callback(null, { statusCode: 200, headers: {} }, asset.xml); 12 | }); 13 | const expectedResponse = { 14 | xml: asset.xml, 15 | headers: {}, 16 | }; 17 | util.requestXml("http://mock.example.com/test.mpd").then((response) => { 18 | expect(response).toEqual(expectedResponse); 19 | done(); 20 | }); 21 | }); 22 | }); 23 | 24 | describe("getRandomItem", () => { 25 | it("returns a random item from an array", () => { 26 | spyOn(Math, "random").and.returnValue(0.3); 27 | const array = [{ a: 5 }, {a: 7}, {a: 9}, {a: 11}, {a: 20}]; 28 | const itm = util.getRandomItem(array); 29 | expect(itm).toEqual({a: 7}); 30 | }); 31 | }); 32 | }); -------------------------------------------------------------------------------- /test/support/testassets.js: -------------------------------------------------------------------------------- 1 | jasmine.getFixtures().fixturesPath = '/base/test/support/testassets'; 2 | 3 | function loadAsset(name, file) { 4 | const data = readFixtures(file); 5 | return { 6 | name: name, 7 | xml: data 8 | }; 9 | } 10 | 11 | const TestAssets = function constructor() { 12 | this.assets = []; 13 | 14 | this.assets.push(loadAsset("usp-live", "usp.live.mpd")); 15 | this.assets.push(loadAsset("usp-vod", "usp.vod.mpd")); 16 | this.assets.push(loadAsset("dynamic.1.mpd", "dynamic.1.mpd")); 17 | this.assets.push(loadAsset("dynamic.2.mpd", "dynamic.2.mpd")); 18 | this.assets.push(loadAsset("dynamic.3.mpd", "dynamic.3.mpd")); 19 | }; 20 | 21 | TestAssets.prototype.getAssetByName = function(name) { 22 | return this.assets.find((n) => { 23 | return n.name === name; 24 | }); 25 | }; 26 | 27 | /** 28 | * @param {Date} publishTime 29 | * @param {Date} startTime 30 | * @param {number} segmentLength 31 | * @return {Object} Internal MPD object that is used to create a DashManifest object 32 | */ 33 | TestAssets.prototype.generateDynamicManifest = function(publishTime, startTime, segmentLength) { 34 | const internalMpd = { 35 | type: "dynamic", 36 | availabilityStartTime: "1970-01-01T00:00:00Z", 37 | minBufferTime: "PT10S", 38 | timeshiftBufferDepth: "PT1H", 39 | maxSegmentDuration: "PT" + segmentLength + "S", 40 | publishTime: publishTime.toISOString(), 41 | }; 42 | 43 | const adaptationSetAudio = { 44 | contentType: "audio", 45 | mimeType: "audio/mp4", 46 | bandwidth: { 47 | min: 96000, 48 | max: 96000, 49 | }, 50 | }; 51 | adaptationSetAudio.segmentList = 52 | this.createMockSegmentList(48000, 53 | startTime, 3600, 54 | segmentLength, "live-$RepresentationID$-$Time$.dash"); 55 | adaptationSetAudio.representations = [ 56 | this.createMockRepresentation(adaptationSetAudio.segmentList, 96000, "audio101_swe=96000") 57 | ]; 58 | 59 | const adaptationSetVideo = { 60 | contentType: "video", 61 | mimeType: "video/mp4", 62 | bandwidth: { 63 | min: 254000, 64 | max: 254000, 65 | }, 66 | }; 67 | adaptationSetVideo.segmentList = 68 | this.createMockSegmentList(25, startTime, 3600, 69 | segmentLength, "live-$RepresentationID$-$Time$.dash"); 70 | adaptationSetVideo.representations = [ 71 | this.createMockRepresentation(adaptationSetVideo.segmentList, 254000, "video=254000", 384, 216) 72 | ]; 73 | 74 | const period = { 75 | id: "1", 76 | start: "PT0S", 77 | baseUrl: "dash/", 78 | adaptationSets: [ adaptationSetAudio, adaptationSetVideo ], 79 | }; 80 | 81 | internalMpd.periods = [ period ]; 82 | 83 | return internalMpd; 84 | }; 85 | 86 | /** 87 | * @param {number} timescale 88 | * @param {Date} startTime 89 | * @param {number} duration (seconds) 90 | * @param {number} segmentLength 91 | * @param {string} mediaTemplate 92 | */ 93 | TestAssets.prototype.createMockSegmentList = function(timescale, startTime, duration, segmentLength, mediaTemplate) { 94 | let segmentList = []; 95 | 96 | for (let i=0; i<(duration/segmentLength); i++) { 97 | const segment = { 98 | start: (startTime.getTime() / 1000), 99 | t: (startTime.getTime() / 1000) * timescale, 100 | durationInSeconds: segmentLength, 101 | end: (startTime.getTime() / 1000) + duration, 102 | }; 103 | segmentList.push(segment); 104 | } 105 | return { 106 | get timescale() { return timescale; }, 107 | get media() { return mediaTemplate; }, 108 | get segments() { return segmentList; }, 109 | }; 110 | }; 111 | 112 | TestAssets.prototype.createMockRepresentation = function(segmentList, bandwidth, id, width, height) { 113 | const segments_ = []; 114 | segmentList.segments.forEach((s) => { 115 | segments_.push({ 116 | t: s.t, 117 | start: s.start, 118 | end: s.end, 119 | durationInSeconds: s.durationInSeconds, 120 | uri: uriFromTemplate(segmentList.media, id, s.t), 121 | }); 122 | }); 123 | return { 124 | id: id, 125 | get segments() { return segments_; }, 126 | }; 127 | }; 128 | 129 | function uriFromTemplate(template, id, time) { 130 | let s = template; 131 | s = s.replace(/\$RepresentationID\$/, id); 132 | s = s.replace(/\$Time\$/, time); 133 | return s; 134 | } 135 | 136 | module.exports = TestAssets; 137 | -------------------------------------------------------------------------------- /test/support/testassets/dynamic.1.mpd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 17 | 20 | dash/ 21 | 31 | 34 | 35 | 36 | 40 | 41 | 42 | 45 | 46 | 47 | 50 | 51 | 52 | 54 | 55 | 56 | 58 | 59 | urn:marlin:kid:bc104bad0b460bd0a0cdf8c14255b1a5 60 | 61 | 62 | 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 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 671 | 672 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 680 | 681 | 682 | 683 | 684 | 685 | 686 | 687 | 688 | 689 | 690 | 691 | 692 | 693 | 694 | 695 | 696 | 697 | 698 | 699 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 724 | 725 | 726 | 727 | 728 | 729 | 730 | 731 | 732 | 733 | 734 | 735 | 736 | 737 | 738 | 739 | 740 | 741 | 742 | 743 | 744 | 745 | 746 | 747 | 748 | 749 | 750 | 751 | 752 | 753 | 754 | 755 | 756 | 757 | 758 | 759 | 760 | 761 | 762 | 763 | 764 | 765 | 766 | 767 | 768 | 769 | 770 | 771 | 772 | 773 | 774 | 775 | 776 | 777 | 778 | 779 | 780 | 781 | 782 | 783 | 784 | 785 | 786 | 787 | 788 | 789 | 790 | 791 | 792 | 793 | 794 | 795 | 796 | 797 | 798 | 799 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 829 | 830 | 831 | 832 | 833 | 834 | 835 | 836 | 837 | 838 | 839 | 840 | 841 | 842 | 843 | 844 | 845 | 846 | 847 | 848 | 849 | 850 | 851 | 852 | 853 | 854 | 855 | 856 | 857 | 858 | 859 | 860 | 861 | 862 | 863 | 864 | 865 | 866 | 867 | 868 | 869 | 870 | 871 | 872 | 873 | 874 | 875 | 876 | 877 | 878 | 879 | 880 | 881 | 882 | 883 | 884 | 885 | 886 | 887 | 888 | 889 | 890 | 891 | 892 | 893 | 894 | 895 | 896 | 897 | 898 | 899 | 900 | 901 | 902 | 903 | 904 | 905 | 906 | 907 | 908 | 909 | 910 | 911 | 912 | 913 | 914 | 915 | 916 | 917 | 918 | 919 | 920 | 921 | 922 | 923 | 924 | 925 | 926 | 927 | 928 | 929 | 930 | 931 | 932 | 933 | 934 | 935 | 936 | 937 | 938 | 939 | 940 | 941 | 942 | 943 | 944 | 945 | 946 | 947 | 948 | 949 | 950 | 951 | 952 | 953 | 954 | 955 | 956 | 957 | 958 | 959 | 960 | 961 | 962 | 963 | 964 | 965 | 966 | 967 | 968 | 969 | 970 | 971 | 974 | 975 | 976 | 989 | 990 | 994 | 995 | 996 | 999 | 1000 | 1001 | 1004 | 1005 | 1006 | 1008 | 1009 | 1010 | 1012 | 1013 | urn:marlin:kid:bc104bad0b460bd0a0cdf8c14255b1a5 1014 | 1015 | 1016 | 1021 | 1022 | 1023 | 1024 | 1025 | 1026 | 1033 | 1034 | 1041 | 1042 | 1049 | 1050 | 1057 | 1058 | 1065 | 1066 | 1073 | 1074 | 1081 | 1082 | 1083 | 1084 | 1085 | -------------------------------------------------------------------------------- /test/support/testassets/usp.vod.mpd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 14 | 16 | dash/ 17 | 26 | 29 | 30 | 31 | 35 | 36 | 37 | 40 | 41 | 42 | 44 | 45 | 46 | 48 | 49 | urn:marlin:kid:215571c54e0915389452aa424b34c40b 50 | 51 | 52 | 57 | 58 | 59 | 60 | 61 | 62 | 65 | 66 | 67 | 75 | 80 | 81 | 82 | 83 | 84 | 85 | 88 | 89 | 90 | 98 | 103 | 104 | 105 | 106 | 107 | 108 | 111 | 112 | 113 | 121 | 126 | 127 | 128 | 129 | 130 | 131 | 134 | 135 | 136 | 144 | 149 | 150 | 151 | 152 | 153 | 154 | 157 | 158 | 159 | 173 | 174 | 178 | 179 | 180 | 183 | 184 | 185 | 187 | 188 | 189 | 191 | 192 | urn:marlin:kid:215571c54e0915389452aa424b34c40b 193 | 194 | 195 | 200 | 201 | 202 | 203 | 204 | 205 | 212 | 213 | 220 | 221 | 228 | 229 | 236 | 237 | 244 | 245 | 252 | 253 | 260 | 261 | 262 | 263 | 264 | --------------------------------------------------------------------------------