/*! @name videojs-contrib-dash @version 5.1.1 @license Apache-2.0 */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('video.js'), require('global/window'), require('global/document')) : typeof define === 'function' && define.amd ? define(['video.js', 'global/window', 'global/document'], factory) : (global.videojsDash = factory(global.videojs,global.window,global.document)); }(this, (function (videojs,window$1,document$1) { 'use strict'; videojs = videojs && videojs.hasOwnProperty('default') ? videojs['default'] : videojs; window$1 = window$1 && window$1.hasOwnProperty('default') ? window$1['default'] : window$1; document$1 = document$1 && document$1.hasOwnProperty('default') ? document$1['default'] : document$1; function unwrapExports (x) { return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; } function createCommonjsModule(fn, module) { return module = { exports: {} }, fn(module, module.exports), module.exports; } var dash_all_debug = createCommonjsModule(function (module, exports) { (function webpackUniversalModuleDefinition(root, factory) { module.exports = factory(); })(window, function() { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); /******/ } /******/ }; /******/ /******/ // define __esModule on exports /******/ __webpack_require__.r = function(exports) { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ /******/ // create a fake namespace object /******/ // mode & 1: value is a module id, require it /******/ // mode & 2: merge all properties of value into the ns /******/ // mode & 4: return value when already ns object /******/ // mode & 8|1: behave like require /******/ __webpack_require__.t = function(value, mode) { /******/ if(mode & 1) value = __webpack_require__(value); /******/ if(mode & 8) return value; /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; /******/ var ns = Object.create(null); /******/ __webpack_require__.r(ns); /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); /******/ return ns; /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = "/dist/"; /******/ /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = "./index.js"); /******/ }) /************************************************************************/ /******/ ({ /***/ "./externals/base64.js": /*!*****************************!*\ !*** ./externals/base64.js ***! \*****************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { /* $Date: 2007-06-12 18:02:31 $ */ // from: http://bannister.us/weblog/2007/06/09/simple-base64-encodedecode-javascript/ // Handles encode/decode of ASCII and Unicode strings. var UTF8 = {}; UTF8.encode = function (s) { var u = []; for (var i = 0; i < s.length; ++i) { var c = s.charCodeAt(i); if (c < 0x80) { u.push(c); } else if (c < 0x800) { u.push(0xC0 | c >> 6); u.push(0x80 | 63 & c); } else if (c < 0x10000) { u.push(0xE0 | c >> 12); u.push(0x80 | 63 & c >> 6); u.push(0x80 | 63 & c); } else { u.push(0xF0 | c >> 18); u.push(0x80 | 63 & c >> 12); u.push(0x80 | 63 & c >> 6); u.push(0x80 | 63 & c); } } return u; }; UTF8.decode = function (u) { var a = []; var i = 0; while (i < u.length) { var v = u[i++]; if (v < 0x80) ; else if (v < 0xE0) { v = (31 & v) << 6; v |= 63 & u[i++]; } else if (v < 0xF0) { v = (15 & v) << 12; v |= (63 & u[i++]) << 6; v |= 63 & u[i++]; } else { v = (7 & v) << 18; v |= (63 & u[i++]) << 12; v |= (63 & u[i++]) << 6; v |= 63 & u[i++]; } a.push(String.fromCharCode(v)); } return a.join(''); }; var BASE64 = {}; (function (T) { var encodeArray = function encodeArray(u) { var i = 0; var a = []; var n = 0 | u.length / 3; while (0 < n--) { var v = (u[i] << 16) + (u[i + 1] << 8) + u[i + 2]; i += 3; a.push(T.charAt(63 & v >> 18)); a.push(T.charAt(63 & v >> 12)); a.push(T.charAt(63 & v >> 6)); a.push(T.charAt(63 & v)); } if (2 == u.length - i) { var v = (u[i] << 16) + (u[i + 1] << 8); a.push(T.charAt(63 & v >> 18)); a.push(T.charAt(63 & v >> 12)); a.push(T.charAt(63 & v >> 6)); a.push('='); } else if (1 == u.length - i) { var v = u[i] << 16; a.push(T.charAt(63 & v >> 18)); a.push(T.charAt(63 & v >> 12)); a.push('=='); } return a.join(''); }; var R = function () { var a = []; for (var i = 0; i < T.length; ++i) { a[T.charCodeAt(i)] = i; } a['='.charCodeAt(0)] = 0; return a; }(); var decodeArray = function decodeArray(s) { var i = 0; var u = []; var n = 0 | s.length / 4; while (0 < n--) { var v = (R[s.charCodeAt(i)] << 18) + (R[s.charCodeAt(i + 1)] << 12) + (R[s.charCodeAt(i + 2)] << 6) + R[s.charCodeAt(i + 3)]; u.push(255 & v >> 16); u.push(255 & v >> 8); u.push(255 & v); i += 4; } if (u) { if ('=' == s.charAt(i - 2)) { u.pop(); u.pop(); } else if ('=' == s.charAt(i - 1)) { u.pop(); } } return u; }; var ASCII = {}; ASCII.encode = function (s) { var u = []; for (var i = 0; i < s.length; ++i) { u.push(s.charCodeAt(i)); } return u; }; ASCII.decode = function (u) { for (var i = 0; i < s.length; ++i) { a[i] = String.fromCharCode(a[i]); } return a.join(''); }; BASE64.decodeArray = function (s) { var u = decodeArray(s); return new Uint8Array(u); }; BASE64.encodeASCII = function (s) { var u = ASCII.encode(s); return encodeArray(u); }; BASE64.decodeASCII = function (s) { var a = decodeArray(s); return ASCII.decode(a); }; BASE64.encode = function (s) { var u = UTF8.encode(s); return encodeArray(u); }; BASE64.decode = function (s) { var u = decodeArray(s); return UTF8.decode(u); }; })("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"); /*The following polyfills are not used in dash.js but have caused multiplayer integration issues. Therefore commenting them out. if (undefined === btoa) { var btoa = BASE64.encode; } if (undefined === atob) { var atob = BASE64.decode; } */ { exports.decode = BASE64.decode; exports.decodeArray = BASE64.decodeArray; exports.encode = BASE64.encode; exports.encodeASCII = BASE64.encodeASCII; } /***/ }), /***/ "./externals/cea608-parser.js": /*!************************************!*\ !*** ./externals/cea608-parser.js ***! \************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { /** * The copyright in this software is being made available under the BSD License, * included below. This software may be subject to other third party and contributor * rights, including patent rights, and no such rights are granted under this license. * * Copyright (c) 2015-2016, DASH Industry Forum. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * 2. Neither the name of Dash Industry Forum nor the names of its * contributors may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ (function (exports) { /** * Exceptions from regular ASCII. CodePoints are mapped to UTF-16 codes */ var specialCea608CharsCodes = { 0x2a: 0xe1, // lowercase a, acute accent 0x5c: 0xe9, // lowercase e, acute accent 0x5e: 0xed, // lowercase i, acute accent 0x5f: 0xf3, // lowercase o, acute accent 0x60: 0xfa, // lowercase u, acute accent 0x7b: 0xe7, // lowercase c with cedilla 0x7c: 0xf7, // division symbol 0x7d: 0xd1, // uppercase N tilde 0x7e: 0xf1, // lowercase n tilde 0x7f: 0x2588, // Full block // THIS BLOCK INCLUDES THE 16 EXTENDED (TWO-BYTE) LINE 21 CHARACTERS // THAT COME FROM HI BYTE=0x11 AND LOW BETWEEN 0x30 AND 0x3F // THIS MEANS THAT \x50 MUST BE ADDED TO THE VALUES 0x80: 0xae, // Registered symbol (R) 0x81: 0xb0, // degree sign 0x82: 0xbd, // 1/2 symbol 0x83: 0xbf, // Inverted (open) question mark 0x84: 0x2122, // Trademark symbol (TM) 0x85: 0xa2, // Cents symbol 0x86: 0xa3, // Pounds sterling 0x87: 0x266a, // Music 8'th note 0x88: 0xe0, // lowercase a, grave accent 0x89: 0x20, // transparent space (regular) 0x8a: 0xe8, // lowercase e, grave accent 0x8b: 0xe2, // lowercase a, circumflex accent 0x8c: 0xea, // lowercase e, circumflex accent 0x8d: 0xee, // lowercase i, circumflex accent 0x8e: 0xf4, // lowercase o, circumflex accent 0x8f: 0xfb, // lowercase u, circumflex accent // THIS BLOCK INCLUDES THE 32 EXTENDED (TWO-BYTE) LINE 21 CHARACTERS // THAT COME FROM HI BYTE=0x12 AND LOW BETWEEN 0x20 AND 0x3F 0x90: 0xc1, // capital letter A with acute 0x91: 0xc9, // capital letter E with acute 0x92: 0xd3, // capital letter O with acute 0x93: 0xda, // capital letter U with acute 0x94: 0xdc, // capital letter U with diaresis 0x95: 0xfc, // lowercase letter U with diaeresis 0x96: 0x2018, // opening single quote 0x97: 0xa1, // inverted exclamation mark 0x98: 0x2a, // asterisk 0x99: 0x2019, // closing single quote 0x9a: 0x2501, // box drawings heavy horizontal 0x9b: 0xa9, // copyright sign 0x9c: 0x2120, // Service mark 0x9d: 0x2022, // (round) bullet 0x9e: 0x201c, // Left double quotation mark 0x9f: 0x201d, // Right double quotation mark 0xa0: 0xc0, // uppercase A, grave accent 0xa1: 0xc2, // uppercase A, circumflex 0xa2: 0xc7, // uppercase C with cedilla 0xa3: 0xc8, // uppercase E, grave accent 0xa4: 0xca, // uppercase E, circumflex 0xa5: 0xcb, // capital letter E with diaresis 0xa6: 0xeb, // lowercase letter e with diaresis 0xa7: 0xce, // uppercase I, circumflex 0xa8: 0xcf, // uppercase I, with diaresis 0xa9: 0xef, // lowercase i, with diaresis 0xaa: 0xd4, // uppercase O, circumflex 0xab: 0xd9, // uppercase U, grave accent 0xac: 0xf9, // lowercase u, grave accent 0xad: 0xdb, // uppercase U, circumflex 0xae: 0xab, // left-pointing double angle quotation mark 0xaf: 0xbb, // right-pointing double angle quotation mark // THIS BLOCK INCLUDES THE 32 EXTENDED (TWO-BYTE) LINE 21 CHARACTERS // THAT COME FROM HI BYTE=0x13 AND LOW BETWEEN 0x20 AND 0x3F 0xb0: 0xc3, // Uppercase A, tilde 0xb1: 0xe3, // Lowercase a, tilde 0xb2: 0xcd, // Uppercase I, acute accent 0xb3: 0xcc, // Uppercase I, grave accent 0xb4: 0xec, // Lowercase i, grave accent 0xb5: 0xd2, // Uppercase O, grave accent 0xb6: 0xf2, // Lowercase o, grave accent 0xb7: 0xd5, // Uppercase O, tilde 0xb8: 0xf5, // Lowercase o, tilde 0xb9: 0x7b, // Open curly brace 0xba: 0x7d, // Closing curly brace 0xbb: 0x5c, // Backslash 0xbc: 0x5e, // Caret 0xbd: 0x5f, // Underscore 0xbe: 0x7c, // Pipe (vertical line) 0xbf: 0x223c, // Tilde operator 0xc0: 0xc4, // Uppercase A, umlaut 0xc1: 0xe4, // Lowercase A, umlaut 0xc2: 0xd6, // Uppercase O, umlaut 0xc3: 0xf6, // Lowercase o, umlaut 0xc4: 0xdf, // Esszett (sharp S) 0xc5: 0xa5, // Yen symbol 0xc6: 0xa4, // Generic currency sign 0xc7: 0x2503, // Box drawings heavy vertical 0xc8: 0xc5, // Uppercase A, ring 0xc9: 0xe5, // Lowercase A, ring 0xca: 0xd8, // Uppercase O, stroke 0xcb: 0xf8, // Lowercase o, strok 0xcc: 0x250f, // Box drawings heavy down and right 0xcd: 0x2513, // Box drawings heavy down and left 0xce: 0x2517, // Box drawings heavy up and right 0xcf: 0x251b // Box drawings heavy up and left }; /** * Get Unicode Character from CEA-608 byte code */ var getCharForByte = function getCharForByte(_byte) { var charCode = _byte; if (specialCea608CharsCodes.hasOwnProperty(_byte)) { charCode = specialCea608CharsCodes[_byte]; } return String.fromCharCode(charCode); }; var NR_ROWS = 15, NR_COLS = 32; // Tables to look up row from PAC data var rowsLowCh1 = { 0x11: 1, 0x12: 3, 0x15: 5, 0x16: 7, 0x17: 9, 0x10: 11, 0x13: 12, 0x14: 14 }; var rowsHighCh1 = { 0x11: 2, 0x12: 4, 0x15: 6, 0x16: 8, 0x17: 10, 0x13: 13, 0x14: 15 }; var rowsLowCh2 = { 0x19: 1, 0x1A: 3, 0x1D: 5, 0x1E: 7, 0x1F: 9, 0x18: 11, 0x1B: 12, 0x1C: 14 }; var rowsHighCh2 = { 0x19: 2, 0x1A: 4, 0x1D: 6, 0x1E: 8, 0x1F: 10, 0x1B: 13, 0x1C: 15 }; var backgroundColors = ['white', 'green', 'blue', 'cyan', 'red', 'yellow', 'magenta', 'black', 'transparent']; /** * Simple logger class to be able to write with time-stamps and filter on level. */ var logger = { verboseFilter: { 'DATA': 3, 'DEBUG': 3, 'INFO': 2, 'WARNING': 2, 'TEXT': 1, 'ERROR': 0 }, time: null, verboseLevel: 0, // Only write errors setTime: function setTime(newTime) { this.time = newTime; }, log: function log(severity, msg) { var minLevel = this.verboseFilter[severity]; if (this.verboseLevel >= minLevel) { console.log(this.time + " [" + severity + "] " + msg); } } }; var numArrayToHexArray = function numArrayToHexArray(numArray) { var hexArray = []; for (var j = 0; j < numArray.length; j++) { hexArray.push(numArray[j].toString(16)); } return hexArray; }; /** * State of CEA-608 pen or character * @constructor */ var PenState = function PenState(foreground, underline, italics, background, flash) { this.foreground = foreground || "white"; this.underline = underline || false; this.italics = italics || false; this.background = background || "black"; this.flash = flash || false; }; PenState.prototype = { reset: function reset() { this.foreground = "white"; this.underline = false; this.italics = false; this.background = "black"; this.flash = false; }, setStyles: function setStyles(styles) { var attribs = ["foreground", "underline", "italics", "background", "flash"]; for (var i = 0; i < attribs.length; i++) { var style = attribs[i]; if (styles.hasOwnProperty(style)) { this[style] = styles[style]; } } }, isDefault: function isDefault() { return this.foreground === "white" && !this.underline && !this.italics && this.background === "black" && !this.flash; }, equals: function equals(other) { return this.foreground === other.foreground && this.underline === other.underline && this.italics === other.italics && this.background === other.background && this.flash === other.flash; }, copy: function copy(newPenState) { this.foreground = newPenState.foreground; this.underline = newPenState.underline; this.italics = newPenState.italics; this.background = newPenState.background; this.flash = newPenState.flash; }, toString: function toString() { return "color=" + this.foreground + ", underline=" + this.underline + ", italics=" + this.italics + ", background=" + this.background + ", flash=" + this.flash; } }; /** * Unicode character with styling and background. * @constructor */ var StyledUnicodeChar = function StyledUnicodeChar(uchar, foreground, underline, italics, background, flash) { this.uchar = uchar || ' '; // unicode character this.penState = new PenState(foreground, underline, italics, background, flash); }; StyledUnicodeChar.prototype = { reset: function reset() { this.uchar = ' '; this.penState.reset(); }, setChar: function setChar(uchar, newPenState) { this.uchar = uchar; this.penState.copy(newPenState); }, setPenState: function setPenState(newPenState) { this.penState.copy(newPenState); }, equals: function equals(other) { return this.uchar === other.uchar && this.penState.equals(other.penState); }, copy: function copy(newChar) { this.uchar = newChar.uchar; this.penState.copy(newChar.penState); }, isEmpty: function isEmpty() { return this.uchar === ' ' && this.penState.isDefault(); } }; /** * CEA-608 row consisting of NR_COLS instances of StyledUnicodeChar. * @constructor */ var Row = function Row() { this.chars = []; for (var i = 0; i < NR_COLS; i++) { this.chars.push(new StyledUnicodeChar()); } this.pos = 0; this.currPenState = new PenState(); }; Row.prototype = { equals: function equals(other) { var equal = true; for (var i = 0; i < NR_COLS; i++) { if (!this.chars[i].equals(other.chars[i])) { equal = false; break; } } return equal; }, copy: function copy(other) { for (var i = 0; i < NR_COLS; i++) { this.chars[i].copy(other.chars[i]); } }, isEmpty: function isEmpty() { var empty = true; for (var i = 0; i < NR_COLS; i++) { if (!this.chars[i].isEmpty()) { empty = false; break; } } return empty; }, /** * Set the cursor to a valid column. */ setCursor: function setCursor(absPos) { if (this.pos !== absPos) { this.pos = absPos; } if (this.pos < 0) { logger.log("ERROR", "Negative cursor position " + this.pos); this.pos = 0; } else if (this.pos > NR_COLS) { logger.log("ERROR", "Too large cursor position " + this.pos); this.pos = NR_COLS; } }, /** * Move the cursor relative to current position. */ moveCursor: function moveCursor(relPos) { var newPos = this.pos + relPos; if (relPos > 1) { for (var i = this.pos + 1; i < newPos + 1; i++) { this.chars[i].setPenState(this.currPenState); } } this.setCursor(newPos); }, /** * Backspace, move one step back and clear character. */ backSpace: function backSpace() { this.moveCursor(-1); this.chars[this.pos].setChar(' ', this.currPenState); }, insertChar: function insertChar(_byte2) { if (_byte2 >= 0x90) { //Extended char this.backSpace(); } var _char = getCharForByte(_byte2); if (this.pos >= NR_COLS) { logger.log("ERROR", "Cannot insert " + _byte2.toString(16) + " (" + _char + ") at position " + this.pos + ". Skipping it!"); return; } this.chars[this.pos].setChar(_char, this.currPenState); this.moveCursor(1); }, clearFromPos: function clearFromPos(startPos) { var i; for (i = startPos; i < NR_COLS; i++) { this.chars[i].reset(); } }, clear: function clear() { this.clearFromPos(0); this.pos = 0; this.currPenState.reset(); }, clearToEndOfRow: function clearToEndOfRow() { this.clearFromPos(this.pos); }, getTextString: function getTextString() { var chars = []; var empty = true; for (var i = 0; i < NR_COLS; i++) { var _char2 = this.chars[i].uchar; if (_char2 !== " ") { empty = false; } chars.push(_char2); } if (empty) { return ""; } else { return chars.join(""); } }, setPenStyles: function setPenStyles(styles) { this.currPenState.setStyles(styles); var currChar = this.chars[this.pos]; currChar.setPenState(this.currPenState); } }; /** * Keep a CEA-608 screen of 32x15 styled characters * @constructor */ var CaptionScreen = function CaptionScreen() { this.rows = []; for (var i = 0; i < NR_ROWS; i++) { this.rows.push(new Row()); // Note that we use zero-based numbering (0-14) } this.currRow = NR_ROWS - 1; this.nrRollUpRows = null; this.reset(); }; CaptionScreen.prototype = { reset: function reset() { for (var i = 0; i < NR_ROWS; i++) { this.rows[i].clear(); } this.currRow = NR_ROWS - 1; }, equals: function equals(other) { var equal = true; for (var i = 0; i < NR_ROWS; i++) { if (!this.rows[i].equals(other.rows[i])) { equal = false; break; } } return equal; }, copy: function copy(other) { for (var i = 0; i < NR_ROWS; i++) { this.rows[i].copy(other.rows[i]); } }, isEmpty: function isEmpty() { var empty = true; for (var i = 0; i < NR_ROWS; i++) { if (!this.rows[i].isEmpty()) { empty = false; break; } } return empty; }, backSpace: function backSpace() { var row = this.rows[this.currRow]; row.backSpace(); }, clearToEndOfRow: function clearToEndOfRow() { var row = this.rows[this.currRow]; row.clearToEndOfRow(); }, /** * Insert a character (without styling) in the current row. */ insertChar: function insertChar(_char3) { var row = this.rows[this.currRow]; row.insertChar(_char3); }, setPen: function setPen(styles) { var row = this.rows[this.currRow]; row.setPenStyles(styles); }, moveCursor: function moveCursor(relPos) { var row = this.rows[this.currRow]; row.moveCursor(relPos); }, setCursor: function setCursor(absPos) { logger.log("INFO", "setCursor: " + absPos); var row = this.rows[this.currRow]; row.setCursor(absPos); }, setPAC: function setPAC(pacData) { logger.log("INFO", "pacData = " + JSON.stringify(pacData)); var newRow = pacData.row - 1; if (this.nrRollUpRows && newRow < this.nrRollUpRows - 1) { newRow = this.nrRollUpRows - 1; } this.currRow = newRow; var row = this.rows[this.currRow]; if (pacData.indent !== null) { var indent = pacData.indent; var prevPos = Math.max(indent - 1, 0); row.setCursor(pacData.indent); pacData.color = row.chars[prevPos].penState.foreground; } var styles = { foreground: pacData.color, underline: pacData.underline, italics: pacData.italics, background: 'black', flash: false }; this.setPen(styles); }, /** * Set background/extra foreground, but first do back_space, and then insert space (backwards compatibility). */ setBkgData: function setBkgData(bkgData) { logger.log("INFO", "bkgData = " + JSON.stringify(bkgData)); this.backSpace(); this.setPen(bkgData); this.insertChar(0x20); //Space }, setRollUpRows: function setRollUpRows(nrRows) { this.nrRollUpRows = nrRows; }, rollUp: function rollUp() { if (this.nrRollUpRows === null) { logger.log("DEBUG", "roll_up but nrRollUpRows not set yet"); return; //Not properly setup } logger.log("TEXT", this.getDisplayText()); var topRowIndex = this.currRow + 1 - this.nrRollUpRows; var topRow = this.rows.splice(topRowIndex, 1)[0]; topRow.clear(); this.rows.splice(this.currRow, 0, topRow); logger.log("INFO", "Rolling up"); //logger.log("TEXT", this.get_display_text()) }, /** * Get all non-empty rows with as unicode text. */ getDisplayText: function getDisplayText(asOneRow) { asOneRow = asOneRow || false; var displayText = []; var text = ""; var rowNr = -1; for (var i = 0; i < NR_ROWS; i++) { var rowText = this.rows[i].getTextString(); if (rowText) { rowNr = i + 1; if (asOneRow) { displayText.push("Row " + rowNr + ': "' + rowText + '"'); } else { displayText.push(rowText.trim()); } } } if (displayText.length > 0) { if (asOneRow) { text = "[" + displayText.join(" | ") + "]"; } else { text = displayText.join("\n"); } } return text; }, getTextAndFormat: function getTextAndFormat() { return this.rows; } }; /** * Handle a CEA-608 channel and send decoded data to outputFilter * @constructor * @param {Number} channelNumber (1 or 2) * @param {CueHandler} outputFilter Output from channel1 newCue(startTime, endTime, captionScreen) */ var Cea608Channel = function Cea608Channel(channelNumber, outputFilter) { this.chNr = channelNumber; this.outputFilter = outputFilter; this.mode = null; this.verbose = 0; this.displayedMemory = new CaptionScreen(); this.nonDisplayedMemory = new CaptionScreen(); this.lastOutputScreen = new CaptionScreen(); this.currRollUpRow = this.displayedMemory.rows[NR_ROWS - 1]; this.writeScreen = this.displayedMemory; this.mode = null; this.cueStartTime = null; // Keeps track of where a cue started. }; Cea608Channel.prototype = { modes: ["MODE_ROLL-UP", "MODE_POP-ON", "MODE_PAINT-ON", "MODE_TEXT"], reset: function reset() { this.mode = null; this.displayedMemory.reset(); this.nonDisplayedMemory.reset(); this.lastOutputScreen.reset(); this.currRollUpRow = this.displayedMemory.rows[NR_ROWS - 1]; this.writeScreen = this.displayedMemory; this.mode = null; this.cueStartTime = null; this.lastCueEndTime = null; }, getHandler: function getHandler() { return this.outputFilter; }, setHandler: function setHandler(newHandler) { this.outputFilter = newHandler; }, setPAC: function setPAC(pacData) { this.writeScreen.setPAC(pacData); }, setBkgData: function setBkgData(bkgData) { this.writeScreen.setBkgData(bkgData); }, setMode: function setMode(newMode) { if (newMode === this.mode) { return; } this.mode = newMode; logger.log("INFO", "MODE=" + newMode); if (this.mode == "MODE_POP-ON") { this.writeScreen = this.nonDisplayedMemory; } else { this.writeScreen = this.displayedMemory; this.writeScreen.reset(); } if (this.mode !== "MODE_ROLL-UP") { this.displayedMemory.nrRollUpRows = null; this.nonDisplayedMemory.nrRollUpRows = null; } this.mode = newMode; }, insertChars: function insertChars(chars) { for (var i = 0; i < chars.length; i++) { this.writeScreen.insertChar(chars[i]); } var screen = this.writeScreen === this.displayedMemory ? "DISP" : "NON_DISP"; logger.log("INFO", screen + ": " + this.writeScreen.getDisplayText(true)); if (this.mode === "MODE_PAINT-ON" || this.mode === "MODE_ROLL-UP") { logger.log("TEXT", "DISPLAYED: " + this.displayedMemory.getDisplayText(true)); this.outputDataUpdate(); } }, cc_RCL: function cc_RCL() { // Resume Caption Loading (switch mode to Pop On) logger.log("INFO", "RCL - Resume Caption Loading"); this.setMode("MODE_POP-ON"); }, cc_BS: function cc_BS() { // BackSpace logger.log("INFO", "BS - BackSpace"); if (this.mode === "MODE_TEXT") { return; } this.writeScreen.backSpace(); if (this.writeScreen === this.displayedMemory) { this.outputDataUpdate(); } }, cc_AOF: function cc_AOF() { // Reserved (formerly Alarm Off) return; }, cc_AON: function cc_AON() { // Reserved (formerly Alarm On) return; }, cc_DER: function cc_DER() { // Delete to End of Row logger.log("INFO", "DER- Delete to End of Row"); this.writeScreen.clearToEndOfRow(); this.outputDataUpdate(); }, cc_RU: function cc_RU(nrRows) { //Roll-Up Captions-2,3,or 4 Rows logger.log("INFO", "RU(" + nrRows + ") - Roll Up"); this.writeScreen = this.displayedMemory; this.setMode("MODE_ROLL-UP"); this.writeScreen.setRollUpRows(nrRows); }, cc_FON: function cc_FON() { //Flash On logger.log("INFO", "FON - Flash On"); this.writeScreen.setPen({ flash: true }); }, cc_RDC: function cc_RDC() { // Resume Direct Captioning (switch mode to PaintOn) logger.log("INFO", "RDC - Resume Direct Captioning"); this.setMode("MODE_PAINT-ON"); }, cc_TR: function cc_TR() { // Text Restart in text mode (not supported, however) logger.log("INFO", "TR"); this.setMode("MODE_TEXT"); }, cc_RTD: function cc_RTD() { // Resume Text Display in Text mode (not supported, however) logger.log("INFO", "RTD"); this.setMode("MODE_TEXT"); }, cc_EDM: function cc_EDM() { // Erase Displayed Memory logger.log("INFO", "EDM - Erase Displayed Memory"); this.displayedMemory.reset(); this.outputDataUpdate(); }, cc_CR: function cc_CR() { // Carriage Return logger.log("CR - Carriage Return"); this.writeScreen.rollUp(); this.outputDataUpdate(); }, cc_ENM: function cc_ENM() { //Erase Non-Displayed Memory logger.log("INFO", "ENM - Erase Non-displayed Memory"); this.nonDisplayedMemory.reset(); }, cc_EOC: function cc_EOC() { //End of Caption (Flip Memories) logger.log("INFO", "EOC - End Of Caption"); if (this.mode === "MODE_POP-ON") { var tmp = this.displayedMemory; this.displayedMemory = this.nonDisplayedMemory; this.nonDisplayedMemory = tmp; this.writeScreen = this.nonDisplayedMemory; logger.log("TEXT", "DISP: " + this.displayedMemory.getDisplayText()); } this.outputDataUpdate(); }, cc_TO: function cc_TO(nrCols) { // Tab Offset 1,2, or 3 columns logger.log("INFO", "TO(" + nrCols + ") - Tab Offset"); this.writeScreen.moveCursor(nrCols); }, cc_MIDROW: function cc_MIDROW(secondByte) { // Parse MIDROW command var styles = { flash: false }; styles.underline = secondByte % 2 === 1; styles.italics = secondByte >= 0x2e; if (!styles.italics) { var colorIndex = Math.floor(secondByte / 2) - 0x10; var colors = ["white", "green", "blue", "cyan", "red", "yellow", "magenta"]; styles.foreground = colors[colorIndex]; } else { styles.foreground = "white"; } logger.log("INFO", "MIDROW: " + JSON.stringify(styles)); this.writeScreen.setPen(styles); }, outputDataUpdate: function outputDataUpdate() { var t = logger.time; if (t === null) { return; } if (this.outputFilter) { if (this.outputFilter.updateData) { this.outputFilter.updateData(t, this.displayedMemory); } if (this.cueStartTime === null && !this.displayedMemory.isEmpty()) { // Start of a new cue this.cueStartTime = t; } else { if (!this.displayedMemory.equals(this.lastOutputScreen)) { if (this.outputFilter.newCue) { this.outputFilter.newCue(this.cueStartTime, t, this.lastOutputScreen); } this.cueStartTime = this.displayedMemory.isEmpty() ? null : t; } } this.lastOutputScreen.copy(this.displayedMemory); } }, cueSplitAtTime: function cueSplitAtTime(t) { if (this.outputFilter) { if (!this.displayedMemory.isEmpty()) { if (this.outputFilter.newCue) { this.outputFilter.newCue(this.cueStartTime, t, this.displayedMemory); } this.cueStartTime = t; } } } }; /** * Parse CEA-608 data and send decoded data to out1 and out2. * @constructor * @param {Number} field CEA-608 field (1 or 2) * @param {CueHandler} out1 Output from channel1 newCue(startTime, endTime, captionScreen) * @param {CueHandler} out2 Output from channel2 newCue(startTime, endTime, captionScreen) */ var Cea608Parser = function Cea608Parser(field, out1, out2) { this.field = field || 1; this.outputs = [out1, out2]; this.channels = [new Cea608Channel(1, out1), new Cea608Channel(2, out2)]; this.currChNr = -1; // Will be 1 or 2 this.lastCmdA = null; // First byte of last command this.lastCmdB = null; // Second byte of last command this.bufferedData = []; this.startTime = null; this.lastTime = null; this.dataCounters = { 'padding': 0, 'char': 0, 'cmd': 0, 'other': 0 }; }; Cea608Parser.prototype = { getHandler: function getHandler(index) { return this.channels[index].getHandler(); }, setHandler: function setHandler(index, newHandler) { this.channels[index].setHandler(newHandler); }, /** * Add data for time t in forms of list of bytes (unsigned ints). The bytes are treated as pairs. */ addData: function addData(t, byteList) { var cmdFound, a, b, charsFound = false; this.lastTime = t; logger.setTime(t); for (var i = 0; i < byteList.length; i += 2) { a = byteList[i] & 0x7f; b = byteList[i + 1] & 0x7f; if (a >= 0x10 && a <= 0x1f && a === this.lastCmdA && b === this.lastCmdB) { this.lastCmdA = null; this.lastCmdB = null; logger.log("DEBUG", "Repeated command (" + numArrayToHexArray([a, b]) + ") is dropped"); continue; // Repeated commands are dropped (once) } if (a === 0 && b === 0) { this.dataCounters.padding += 2; continue; } else { logger.log("DATA", "[" + numArrayToHexArray([byteList[i], byteList[i + 1]]) + "] -> (" + numArrayToHexArray([a, b]) + ")"); } cmdFound = this.parseCmd(a, b); if (!cmdFound) { cmdFound = this.parseMidrow(a, b); } if (!cmdFound) { cmdFound = this.parsePAC(a, b); } if (!cmdFound) { cmdFound = this.parseBackgroundAttributes(a, b); } if (!cmdFound) { charsFound = this.parseChars(a, b); if (charsFound) { if (this.currChNr && this.currChNr >= 0) { var channel = this.channels[this.currChNr - 1]; channel.insertChars(charsFound); } else { logger.log("WARNING", "No channel found yet. TEXT-MODE?"); } } } if (cmdFound) { this.dataCounters.cmd += 2; } else if (charsFound) { this.dataCounters["char"] += 2; } else { this.dataCounters.other += 2; logger.log("WARNING", "Couldn't parse cleaned data " + numArrayToHexArray([a, b]) + " orig: " + numArrayToHexArray([byteList[i], byteList[i + 1]])); } } }, /** * Parse Command. * @returns {Boolean} Tells if a command was found */ parseCmd: function parseCmd(a, b) { var chNr = null; var cond1 = (a === 0x14 || a === 0x15 || a === 0x1C || a === 0x1D) && 0x20 <= b && b <= 0x2F; var cond2 = (a === 0x17 || a === 0x1F) && 0x21 <= b && b <= 0x23; if (!(cond1 || cond2)) { return false; } if (a === 0x14 || a === 0x15 || a === 0x17) { chNr = 1; } else { chNr = 2; // (a === 0x1C || a === 0x1D || a=== 0x1f) } var channel = this.channels[chNr - 1]; if (a === 0x14 || a === 0x15 || a === 0x1C || a === 0x1D) { if (b === 0x20) { channel.cc_RCL(); } else if (b === 0x21) { channel.cc_BS(); } else if (b === 0x22) { channel.cc_AOF(); } else if (b === 0x23) { channel.cc_AON(); } else if (b === 0x24) { channel.cc_DER(); } else if (b === 0x25) { channel.cc_RU(2); } else if (b === 0x26) { channel.cc_RU(3); } else if (b === 0x27) { channel.cc_RU(4); } else if (b === 0x28) { channel.cc_FON(); } else if (b === 0x29) { channel.cc_RDC(); } else if (b === 0x2A) { channel.cc_TR(); } else if (b === 0x2B) { channel.cc_RTD(); } else if (b === 0x2C) { channel.cc_EDM(); } else if (b === 0x2D) { channel.cc_CR(); } else if (b === 0x2E) { channel.cc_ENM(); } else if (b === 0x2F) { channel.cc_EOC(); } } else { //a == 0x17 || a == 0x1F channel.cc_TO(b - 0x20); } this.lastCmdA = a; this.lastCmdB = b; this.currChNr = chNr; return true; }, /** * Parse midrow styling command * @returns {Boolean} */ parseMidrow: function parseMidrow(a, b) { var chNr = null; if ((a === 0x11 || a === 0x19) && 0x20 <= b && b <= 0x2f) { if (a === 0x11) { chNr = 1; } else { chNr = 2; } if (chNr !== this.currChNr) { logger.log("ERROR", "Mismatch channel in midrow parsing"); return false; } var channel = this.channels[chNr - 1]; // cea608 spec says midrow codes should inject a space channel.insertChars([0x20]); channel.cc_MIDROW(b); logger.log("DEBUG", "MIDROW (" + numArrayToHexArray([a, b]) + ")"); this.lastCmdA = a; this.lastCmdB = b; return true; } return false; }, /** * Parse Preable Access Codes (Table 53). * @returns {Boolean} Tells if PAC found */ parsePAC: function parsePAC(a, b) { var chNr = null; var row = null; var case1 = (0x11 <= a && a <= 0x17 || 0x19 <= a && a <= 0x1F) && 0x40 <= b && b <= 0x7F; var case2 = (a === 0x10 || a === 0x18) && 0x40 <= b && b <= 0x5F; if (!(case1 || case2)) { return false; } chNr = a <= 0x17 ? 1 : 2; if (0x40 <= b && b <= 0x5F) { row = chNr === 1 ? rowsLowCh1[a] : rowsLowCh2[a]; } else { // 0x60 <= b <= 0x7F row = chNr === 1 ? rowsHighCh1[a] : rowsHighCh2[a]; } var pacData = this.interpretPAC(row, b); var channel = this.channels[chNr - 1]; channel.setPAC(pacData); this.lastCmdA = a; this.lastCmdB = b; this.currChNr = chNr; return true; }, /** * Interpret the second byte of the pac, and return the information. * @returns {Object} pacData with style parameters. */ interpretPAC: function interpretPAC(row, _byte3) { var pacIndex = _byte3; var pacData = { color: null, italics: false, indent: null, underline: false, row: row }; if (_byte3 > 0x5F) { pacIndex = _byte3 - 0x60; } else { pacIndex = _byte3 - 0x40; } pacData.underline = (pacIndex & 1) === 1; if (pacIndex <= 0xd) { pacData.color = ['white', 'green', 'blue', 'cyan', 'red', 'yellow', 'magenta', 'white'][Math.floor(pacIndex / 2)]; } else if (pacIndex <= 0xf) { pacData.italics = true; pacData.color = 'white'; } else { pacData.indent = Math.floor((pacIndex - 0x10) / 2) * 4; } return pacData; // Note that row has zero offset. The spec uses 1. }, /** * Parse characters. * @returns An array with 1 to 2 codes corresponding to chars, if found. null otherwise. */ parseChars: function parseChars(a, b) { var channelNr = null, charCodes = null, charCode1 = null; if (a >= 0x19) { channelNr = 2; charCode1 = a - 8; } else { channelNr = 1; charCode1 = a; } if (0x11 <= charCode1 && charCode1 <= 0x13) { // Special character var oneCode = b; if (charCode1 === 0x11) { oneCode = b + 0x50; } else if (charCode1 === 0x12) { oneCode = b + 0x70; } else { oneCode = b + 0x90; } logger.log("INFO", "Special char '" + getCharForByte(oneCode) + "' in channel " + channelNr); charCodes = [oneCode]; this.lastCmdA = a; this.lastCmdB = b; } else if (0x20 <= a && a <= 0x7f) { charCodes = b === 0 ? [a] : [a, b]; this.lastCmdA = null; this.lastCmdB = null; } if (charCodes) { var hexCodes = numArrayToHexArray(charCodes); logger.log("DEBUG", "Char codes = " + hexCodes.join(",")); } return charCodes; }, /** * Parse extended background attributes as well as new foreground color black. * @returns{Boolean} Tells if background attributes are found */ parseBackgroundAttributes: function parseBackgroundAttributes(a, b) { var bkgData, index, chNr, channel; var case1 = (a === 0x10 || a === 0x18) && 0x20 <= b && b <= 0x2f; var case2 = (a === 0x17 || a === 0x1f) && 0x2d <= b && b <= 0x2f; if (!(case1 || case2)) { return false; } bkgData = {}; if (a === 0x10 || a === 0x18) { index = Math.floor((b - 0x20) / 2); bkgData.background = backgroundColors[index]; if (b % 2 === 1) { bkgData.background = bkgData.background + "_semi"; } } else if (b === 0x2d) { bkgData.background = "transparent"; } else { bkgData.foreground = "black"; if (b === 0x2f) { bkgData.underline = true; } } chNr = a < 0x18 ? 1 : 2; channel = this.channels[chNr - 1]; channel.setBkgData(bkgData); this.lastCmdA = a; this.lastCmdB = b; return true; }, /** * Reset state of parser and its channels. */ reset: function reset() { for (var i = 0; i < this.channels.length; i++) { if (this.channels[i]) { this.channels[i].reset(); } } this.lastCmdA = null; this.lastCmdB = null; }, /** * Trigger the generation of a cue, and the start of a new one if displayScreens are not empty. */ cueSplitAtTime: function cueSplitAtTime(t) { for (var i = 0; i < this.channels.length; i++) { if (this.channels[i]) { this.channels[i].cueSplitAtTime(t); } } } }; /** * Find ranges corresponding to SEA CEA-608 NALUS in sizeprepended NALU array. * @param {raw} dataView of binary data * @param {startPos} start position in raw * @param {size} total size of data in raw to consider * @returns */ var findCea608Nalus = function findCea608Nalus(raw, startPos, size) { var nalSize = 0, cursor = startPos, nalType = 0, cea608NaluRanges = [], // Check SEI data according to ANSI-SCTE 128 isCEA608SEI = function isCEA608SEI(payloadType, payloadSize, raw, pos) { if (payloadType !== 4 || payloadSize < 8) { return null; } var countryCode = raw.getUint8(pos); var providerCode = raw.getUint16(pos + 1); var userIdentifier = raw.getUint32(pos + 3); var userDataTypeCode = raw.getUint8(pos + 7); return countryCode == 0xB5 && providerCode == 0x31 && userIdentifier == 0x47413934 && userDataTypeCode == 0x3; }; while (cursor < startPos + size) { nalSize = raw.getUint32(cursor); nalType = raw.getUint8(cursor + 4) & 0x1F; //console.log(time + " NAL " + nalType); if (nalType === 6) { // SEI NAL Unit. The NAL header is the first byte //console.log("SEI NALU of size " + nalSize + " at time " + time); var pos = cursor + 5; var payloadType = -1; while (pos < cursor + 4 + nalSize - 1) { // The last byte should be rbsp_trailing_bits payloadType = 0; var b = 0xFF; while (b === 0xFF) { b = raw.getUint8(pos); payloadType += b; pos++; } var payloadSize = 0; b = 0xFF; while (b === 0xFF) { b = raw.getUint8(pos); payloadSize += b; pos++; } if (isCEA608SEI(payloadType, payloadSize, raw, pos)) { //console.log("CEA608 SEI " + time + " " + payloadSize); cea608NaluRanges.push([pos, payloadSize]); } pos += payloadSize; } } cursor += nalSize + 4; } return cea608NaluRanges; }; var extractCea608DataFromRange = function extractCea608DataFromRange(raw, cea608Range) { var pos = cea608Range[0]; var fieldData = [[], []]; pos += 8; // Skip the identifier up to userDataTypeCode var ccCount = raw.getUint8(pos) & 0x1f; pos += 2; // Advance 1 and skip reserved byte for (var i = 0; i < ccCount; i++) { var _byte4 = raw.getUint8(pos); var ccValid = _byte4 & 0x4; var ccType = _byte4 & 0x3; pos++; var ccData1 = raw.getUint8(pos); // Keep parity bit pos++; var ccData2 = raw.getUint8(pos); // Keep parity bit pos++; if (ccValid && (ccData1 & 0x7f) + (ccData2 & 0x7f) !== 0) { //Check validity and non-empty data if (ccType === 0) { fieldData[0].push(ccData1); fieldData[0].push(ccData2); } else if (ccType === 1) { fieldData[1].push(ccData1); fieldData[1].push(ccData2); } } } return fieldData; }; exports.logger = logger; exports.PenState = PenState; exports.CaptionScreen = CaptionScreen; exports.Cea608Parser = Cea608Parser; exports.findCea608Nalus = findCea608Nalus; exports.extractCea608DataFromRange = extractCea608DataFromRange; })( exports); /***/ }), /***/ "./externals/xml2json.js": /*!*******************************!*\ !*** ./externals/xml2json.js ***! \*******************************/ /*! exports provided: default */ /***/ (function(module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); /* Copyright 2011-2013 Abdulla Abdurakhmanov Original sources are available at https://code.google.com/p/x2js/ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Further modified for dashjs to: - keep track of children nodes in order in attribute __children. - add type conversion matchers - re-add ignoreRoot - allow zero-length attributePrefix - don't add white-space text nodes - remove explicit RequireJS support */ function X2JS(config) { var VERSION = "1.2.0"; config = config || {}; initConfigDefaults(); function initConfigDefaults() { if (config.escapeMode === undefined) { config.escapeMode = true; } if (config.attributePrefix === undefined) { config.attributePrefix = "_"; } config.arrayAccessForm = config.arrayAccessForm || "none"; config.emptyNodeForm = config.emptyNodeForm || "text"; if (config.enableToStringFunc === undefined) { config.enableToStringFunc = true; } config.arrayAccessFormPaths = config.arrayAccessFormPaths || []; if (config.skipEmptyTextNodesForObj === undefined) { config.skipEmptyTextNodesForObj = true; } if (config.stripWhitespaces === undefined) { config.stripWhitespaces = true; } config.datetimeAccessFormPaths = config.datetimeAccessFormPaths || []; if (config.useDoubleQuotes === undefined) { config.useDoubleQuotes = false; } config.xmlElementsFilter = config.xmlElementsFilter || []; config.jsonPropertiesFilter = config.jsonPropertiesFilter || []; if (config.keepCData === undefined) { config.keepCData = false; } if (config.ignoreRoot === undefined) { config.ignoreRoot = false; } } var DOMNodeTypes = { ELEMENT_NODE: 1, TEXT_NODE: 3, CDATA_SECTION_NODE: 4, COMMENT_NODE: 8, DOCUMENT_NODE: 9 }; function getNodeLocalName(node) { var nodeLocalName = node.localName; if (nodeLocalName == null) // Yeah, this is IE!! nodeLocalName = node.baseName; if (nodeLocalName == null || nodeLocalName == "") // =="" is IE too nodeLocalName = node.nodeName; return nodeLocalName; } function getNodePrefix(node) { return node.prefix; } function escapeXmlChars(str) { if (typeof str == "string") return str.replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, ''');else return str; } function checkInStdFiltersArrayForm(stdFiltersArrayForm, obj, name, path) { var idx = 0; for (; idx < stdFiltersArrayForm.length; idx++) { var filterPath = stdFiltersArrayForm[idx]; if (typeof filterPath === "string") { if (filterPath == path) break; } else if (filterPath instanceof RegExp) { if (filterPath.test(path)) break; } else if (typeof filterPath === "function") { if (filterPath(obj, name, path)) break; } } return idx != stdFiltersArrayForm.length; } function toArrayAccessForm(obj, childName, path) { switch (config.arrayAccessForm) { case "property": if (!(obj[childName] instanceof Array)) obj[childName + "_asArray"] = [obj[childName]];else obj[childName + "_asArray"] = obj[childName]; break; /*case "none": break;*/ } if (!(obj[childName] instanceof Array) && config.arrayAccessFormPaths.length > 0) { if (checkInStdFiltersArrayForm(config.arrayAccessFormPaths, obj, childName, path)) { obj[childName] = [obj[childName]]; } } } function fromXmlDateTime(prop) { // Implementation based up on http://stackoverflow.com/questions/8178598/xml-datetime-to-javascript-date-object // Improved to support full spec and optional parts var bits = prop.split(/[-T:+Z]/g); var d = new Date(bits[0], bits[1] - 1, bits[2]); var secondBits = bits[5].split("\."); d.setHours(bits[3], bits[4], secondBits[0]); if (secondBits.length > 1) d.setMilliseconds(secondBits[1]); // Get supplied time zone offset in minutes if (bits[6] && bits[7]) { var offsetMinutes = bits[6] * 60 + Number(bits[7]); var sign = /\d\d-\d\d:\d\d$/.test(prop) ? '-' : '+'; // Apply the sign offsetMinutes = 0 + (sign == '-' ? -1 * offsetMinutes : offsetMinutes); // Apply offset and local timezone d.setMinutes(d.getMinutes() - offsetMinutes - d.getTimezoneOffset()); } else if (prop.indexOf("Z", prop.length - 1) !== -1) { d = new Date(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds())); } // d is now a local time equivalent to the supplied time return d; } function checkFromXmlDateTimePaths(value, childName, fullPath) { if (config.datetimeAccessFormPaths.length > 0) { var path = fullPath.split("\.#")[0]; if (checkInStdFiltersArrayForm(config.datetimeAccessFormPaths, value, childName, path)) { return fromXmlDateTime(value); } else return value; } else return value; } function checkXmlElementsFilter(obj, childType, childName, childPath) { if (childType == DOMNodeTypes.ELEMENT_NODE && config.xmlElementsFilter.length > 0) { return checkInStdFiltersArrayForm(config.xmlElementsFilter, obj, childName, childPath); } else return true; } function parseDOMChildren(node, path) { if (node.nodeType == DOMNodeTypes.DOCUMENT_NODE) { var result = new Object(); var nodeChildren = node.childNodes; // Alternative for firstElementChild which is not supported in some environments for (var cidx = 0; cidx < nodeChildren.length; cidx++) { var child = nodeChildren[cidx]; if (child.nodeType == DOMNodeTypes.ELEMENT_NODE) { if (config.ignoreRoot) { result = parseDOMChildren(child); } else { result = {}; var childName = getNodeLocalName(child); result[childName] = parseDOMChildren(child); } } } return result; } else if (node.nodeType == DOMNodeTypes.ELEMENT_NODE) { var result = new Object(); result.__cnt = 0; var children = []; var nodeChildren = node.childNodes; // Children nodes for (var cidx = 0; cidx < nodeChildren.length; cidx++) { var child = nodeChildren[cidx]; var childName = getNodeLocalName(child); if (child.nodeType != DOMNodeTypes.COMMENT_NODE) { var childPath = path + "." + childName; if (checkXmlElementsFilter(result, child.nodeType, childName, childPath)) { result.__cnt++; if (result[childName] == null) { var c = parseDOMChildren(child, childPath); if (childName != "#text" || /[^\s]/.test(c)) { var o = {}; o[childName] = c; children.push(o); } result[childName] = c; toArrayAccessForm(result, childName, childPath); } else { if (result[childName] != null) { if (!(result[childName] instanceof Array)) { result[childName] = [result[childName]]; toArrayAccessForm(result, childName, childPath); } } var c = parseDOMChildren(child, childPath); if (childName != "#text" || /[^\s]/.test(c)) { // Don't add white-space text nodes var o = {}; o[childName] = c; children.push(o); } result[childName][result[childName].length] = c; } } } } result.__children = children; // Attributes var nodeLocalName = getNodeLocalName(node); for (var aidx = 0; aidx < node.attributes.length; aidx++) { var attr = node.attributes[aidx]; result.__cnt++; var value2 = attr.value; for (var m = 0, ml = config.matchers.length; m < ml; m++) { var matchobj = config.matchers[m]; if (matchobj.test(attr, nodeLocalName)) value2 = matchobj.converter(attr.value); } result[config.attributePrefix + attr.name] = value2; } // Node namespace prefix var nodePrefix = getNodePrefix(node); if (nodePrefix != null && nodePrefix != "") { result.__cnt++; result.__prefix = nodePrefix; } if (result["#text"] != null) { result.__text = result["#text"]; if (result.__text instanceof Array) { result.__text = result.__text.join("\n"); } //if(config.escapeMode) // result.__text = unescapeXmlChars(result.__text); if (config.stripWhitespaces) result.__text = result.__text.trim(); delete result["#text"]; if (config.arrayAccessForm == "property") delete result["#text_asArray"]; result.__text = checkFromXmlDateTimePaths(result.__text, childName, path + "." + childName); } if (result["#cdata-section"] != null) { result.__cdata = result["#cdata-section"]; delete result["#cdata-section"]; if (config.arrayAccessForm == "property") delete result["#cdata-section_asArray"]; } if (result.__cnt == 0 && config.emptyNodeForm == "text") { result = ''; } else if (result.__cnt == 1 && result.__text != null) { result = result.__text; } else if (result.__cnt == 1 && result.__cdata != null && !config.keepCData) { result = result.__cdata; } else if (result.__cnt > 1 && result.__text != null && config.skipEmptyTextNodesForObj) { if (config.stripWhitespaces && result.__text == "" || result.__text.trim() == "") { delete result.__text; } } delete result.__cnt; if (config.enableToStringFunc && (result.__text != null || result.__cdata != null)) { result.toString = function () { return (this.__text != null ? this.__text : '') + (this.__cdata != null ? this.__cdata : ''); }; } return result; } else if (node.nodeType == DOMNodeTypes.TEXT_NODE || node.nodeType == DOMNodeTypes.CDATA_SECTION_NODE) { return node.nodeValue; } } function startTag(jsonObj, element, attrList, closed) { var resultStr = "<" + (jsonObj != null && jsonObj.__prefix != null ? jsonObj.__prefix + ":" : "") + element; if (attrList != null) { for (var aidx = 0; aidx < attrList.length; aidx++) { var attrName = attrList[aidx]; var attrVal = jsonObj[attrName]; if (config.escapeMode) attrVal = escapeXmlChars(attrVal); resultStr += " " + attrName.substr(config.attributePrefix.length) + "="; if (config.useDoubleQuotes) resultStr += '"' + attrVal + '"';else resultStr += "'" + attrVal + "'"; } } if (!closed) resultStr += ">";else resultStr += "/>"; return resultStr; } function endTag(jsonObj, elementName) { return ""; } function endsWith(str, suffix) { return str.indexOf(suffix, str.length - suffix.length) !== -1; } function jsonXmlSpecialElem(jsonObj, jsonObjField) { if (config.arrayAccessForm == "property" && endsWith(jsonObjField.toString(), "_asArray") || jsonObjField.toString().indexOf(config.attributePrefix) == 0 || jsonObjField.toString().indexOf("__") == 0 || jsonObj[jsonObjField] instanceof Function) return true;else return false; } function jsonXmlElemCount(jsonObj) { var elementsCnt = 0; if (jsonObj instanceof Object) { for (var it in jsonObj) { if (jsonXmlSpecialElem(jsonObj, it)) continue; elementsCnt++; } } return elementsCnt; } function checkJsonObjPropertiesFilter(jsonObj, propertyName, jsonObjPath) { return config.jsonPropertiesFilter.length == 0 || jsonObjPath == "" || checkInStdFiltersArrayForm(config.jsonPropertiesFilter, jsonObj, propertyName, jsonObjPath); } function parseJSONAttributes(jsonObj) { var attrList = []; if (jsonObj instanceof Object) { for (var ait in jsonObj) { if (ait.toString().indexOf("__") == -1 && ait.toString().indexOf(config.attributePrefix) == 0) { attrList.push(ait); } } } return attrList; } function parseJSONTextAttrs(jsonTxtObj) { var result = ""; if (jsonTxtObj.__cdata != null) { result += ""; } if (jsonTxtObj.__text != null) { if (config.escapeMode) result += escapeXmlChars(jsonTxtObj.__text);else result += jsonTxtObj.__text; } return result; } function parseJSONTextObject(jsonTxtObj) { var result = ""; if (jsonTxtObj instanceof Object) { result += parseJSONTextAttrs(jsonTxtObj); } else if (jsonTxtObj != null) { if (config.escapeMode) result += escapeXmlChars(jsonTxtObj);else result += jsonTxtObj; } return result; } function getJsonPropertyPath(jsonObjPath, jsonPropName) { if (jsonObjPath === "") { return jsonPropName; } else return jsonObjPath + "." + jsonPropName; } function parseJSONArray(jsonArrRoot, jsonArrObj, attrList, jsonObjPath) { var result = ""; if (jsonArrRoot.length == 0) { result += startTag(jsonArrRoot, jsonArrObj, attrList, true); } else { for (var arIdx = 0; arIdx < jsonArrRoot.length; arIdx++) { result += startTag(jsonArrRoot[arIdx], jsonArrObj, parseJSONAttributes(jsonArrRoot[arIdx]), false); result += parseJSONObject(jsonArrRoot[arIdx], getJsonPropertyPath(jsonObjPath, jsonArrObj)); result += endTag(jsonArrRoot[arIdx], jsonArrObj); } } return result; } function parseJSONObject(jsonObj, jsonObjPath) { var result = ""; var elementsCnt = jsonXmlElemCount(jsonObj); if (elementsCnt > 0) { for (var it in jsonObj) { if (jsonXmlSpecialElem(jsonObj, it) || jsonObjPath != "" && !checkJsonObjPropertiesFilter(jsonObj, it, getJsonPropertyPath(jsonObjPath, it))) continue; var subObj = jsonObj[it]; var attrList = parseJSONAttributes(subObj); if (subObj == null || subObj == undefined) { result += startTag(subObj, it, attrList, true); } else if (subObj instanceof Object) { if (subObj instanceof Array) { result += parseJSONArray(subObj, it, attrList, jsonObjPath); } else if (subObj instanceof Date) { result += startTag(subObj, it, attrList, false); result += subObj.toISOString(); result += endTag(subObj, it); } else { var subObjElementsCnt = jsonXmlElemCount(subObj); if (subObjElementsCnt > 0 || subObj.__text != null || subObj.__cdata != null) { result += startTag(subObj, it, attrList, false); result += parseJSONObject(subObj, getJsonPropertyPath(jsonObjPath, it)); result += endTag(subObj, it); } else { result += startTag(subObj, it, attrList, true); } } } else { result += startTag(subObj, it, attrList, false); result += parseJSONTextObject(subObj); result += endTag(subObj, it); } } } result += parseJSONTextObject(jsonObj); return result; } this.parseXmlString = function (xmlDocStr) { var isIEParser = window.ActiveXObject || "ActiveXObject" in window; if (xmlDocStr === undefined) { return null; } var xmlDoc; if (window.DOMParser) { var parser = new window.DOMParser(); try { xmlDoc = parser.parseFromString(xmlDocStr, "text/xml"); if (xmlDoc.getElementsByTagNameNS("*", "parsererror").length > 0) { xmlDoc = null; } } catch (err) { xmlDoc = null; } } else { // IE :( if (xmlDocStr.indexOf("") + 2); } xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async = "false"; xmlDoc.loadXML(xmlDocStr); } return xmlDoc; }; this.asArray = function (prop) { if (prop === undefined || prop == null) return [];else if (prop instanceof Array) return prop;else return [prop]; }; this.toXmlDateTime = function (dt) { if (dt instanceof Date) return dt.toISOString();else if (typeof dt === 'number') return new Date(dt).toISOString();else return null; }; this.asDateTime = function (prop) { if (typeof prop == "string") { return fromXmlDateTime(prop); } else return prop; }; this.xml2json = function (xmlDoc) { return parseDOMChildren(xmlDoc); }; this.xml_str2json = function (xmlDocStr) { var xmlDoc = this.parseXmlString(xmlDocStr); if (xmlDoc != null) return this.xml2json(xmlDoc);else return null; }; this.json2xml_str = function (jsonObj) { return parseJSONObject(jsonObj, ""); }; this.json2xml = function (jsonObj) { var xmlDocStr = this.json2xml_str(jsonObj); return this.parseXmlString(xmlDocStr); }; this.getVersion = function () { return VERSION; }; } /* harmony default export */ __webpack_exports__["default"] = (X2JS); /***/ }), /***/ "./index.js": /*!******************!*\ !*** ./index.js ***! \******************/ /*! exports provided: default, MediaPlayer, Protection, MetricsReporting, MediaPlayerFactory, Debug, supportsMediaSource */ /***/ (function(module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); /* harmony import */ var _index_mediaplayerOnly__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./index_mediaplayerOnly */ "./index_mediaplayerOnly.js"); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MediaPlayer", function() { return _index_mediaplayerOnly__WEBPACK_IMPORTED_MODULE_0__["MediaPlayer"]; }); /* harmony import */ var _src_streaming_utils_Capabilities__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./src/streaming/utils/Capabilities */ "./src/streaming/utils/Capabilities.js"); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "supportsMediaSource", function() { return _src_streaming_utils_Capabilities__WEBPACK_IMPORTED_MODULE_1__["supportsMediaSource"]; }); /* harmony import */ var _src_streaming_metrics_MetricsReporting__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./src/streaming/metrics/MetricsReporting */ "./src/streaming/metrics/MetricsReporting.js"); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MetricsReporting", function() { return _src_streaming_metrics_MetricsReporting__WEBPACK_IMPORTED_MODULE_2__["default"]; }); /* harmony import */ var _src_streaming_protection_Protection__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./src/streaming/protection/Protection */ "./src/streaming/protection/Protection.js"); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Protection", function() { return _src_streaming_protection_Protection__WEBPACK_IMPORTED_MODULE_3__["default"]; }); /* harmony import */ var _src_streaming_MediaPlayerFactory__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./src/streaming/MediaPlayerFactory */ "./src/streaming/MediaPlayerFactory.js"); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MediaPlayerFactory", function() { return _src_streaming_MediaPlayerFactory__WEBPACK_IMPORTED_MODULE_4__["default"]; }); /* harmony import */ var _src_core_Debug__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./src/core/Debug */ "./src/core/Debug.js"); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Debug", function() { return _src_core_Debug__WEBPACK_IMPORTED_MODULE_5__["default"]; }); /** * The copyright in this software is being made available under the BSD License, * included below. This software may be subject to other third party and contributor * rights, including patent rights, and no such rights are granted under this license. * * Copyright (c) 2013, Dash Industry Forum. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * Neither the name of Dash Industry Forum nor the names of its * contributors may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ dashjs.Protection = _src_streaming_protection_Protection__WEBPACK_IMPORTED_MODULE_3__["default"]; dashjs.MetricsReporting = _src_streaming_metrics_MetricsReporting__WEBPACK_IMPORTED_MODULE_2__["default"]; dashjs.MediaPlayerFactory = _src_streaming_MediaPlayerFactory__WEBPACK_IMPORTED_MODULE_4__["default"]; dashjs.Debug = _src_core_Debug__WEBPACK_IMPORTED_MODULE_5__["default"]; dashjs.supportsMediaSource = _src_streaming_utils_Capabilities__WEBPACK_IMPORTED_MODULE_1__["supportsMediaSource"]; /* harmony default export */ __webpack_exports__["default"] = (dashjs); /***/ }), /***/ "./index_mediaplayerOnly.js": /*!**********************************!*\ !*** ./index_mediaplayerOnly.js ***! \**********************************/ /*! exports provided: default, MediaPlayer, FactoryMaker, Debug */ /***/ (function(module, __webpack_exports__, __webpack_require__) { __webpack_require__.r(__webpack_exports__); /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _src_streaming_MediaPlayer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./src/streaming/MediaPlayer */ "./src/streaming/MediaPlayer.js"); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MediaPlayer", function() { return _src_streaming_MediaPlayer__WEBPACK_IMPORTED_MODULE_0__["default"]; }); /* harmony import */ var _src_core_FactoryMaker__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./src/core/FactoryMaker */ "./src/core/FactoryMaker.js"); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactoryMaker", function() { return _src_core_FactoryMaker__WEBPACK_IMPORTED_MODULE_1__["default"]; }); /* harmony import */ var _src_core_Debug__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./src/core/Debug */ "./src/core/Debug.js"); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Debug", function() { return _src_core_Debug__WEBPACK_IMPORTED_MODULE_2__["default"]; }); /* harmony import */ var _src_core_Version__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./src/core/Version */ "./src/core/Version.js"); /* harmony import */ var es6_promise_auto__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! es6-promise/auto */ "./node_modules/es6-promise/auto.js"); /* harmony import */ var es6_promise_auto__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(es6_promise_auto__WEBPACK_IMPORTED_MODULE_4__); /** * The copyright in this software is being made available under the BSD License, * included below. This software may be subject to other third party and contributor * rights, including patent rights, and no such rights are granted under this license. * * Copyright (c) 2013, Dash Industry Forum. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * Neither the name of Dash Industry Forum nor the names of its * contributors may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ // Shove both of these into the global scope var context = typeof window !== 'undefined' && window || global; var dashjs = context.dashjs; if (!dashjs) { dashjs = context.dashjs = {}; } dashjs.MediaPlayer = _src_streaming_MediaPlayer__WEBPACK_IMPORTED_MODULE_0__["default"]; dashjs.FactoryMaker = _src_core_FactoryMaker__WEBPACK_IMPORTED_MODULE_1__["default"]; dashjs.Debug = _src_core_Debug__WEBPACK_IMPORTED_MODULE_2__["default"]; dashjs.Version = Object(_src_core_Version__WEBPACK_IMPORTED_MODULE_3__["getVersionString"])(); /* harmony default export */ __webpack_exports__["default"] = (dashjs); /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./node_modules/webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js"))); /***/ }), /***/ "./node_modules/base64-js/index.js": /*!*****************************************!*\ !*** ./node_modules/base64-js/index.js ***! \*****************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { exports.byteLength = byteLength; exports.toByteArray = toByteArray; exports.fromByteArray = fromByteArray; var lookup = []; var revLookup = []; var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array; var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; for (var i = 0, len = code.length; i < len; ++i) { lookup[i] = code[i]; revLookup[code.charCodeAt(i)] = i; } // Support decoding URL-safe base64 strings, as Node.js does. // See: https://en.wikipedia.org/wiki/Base64#URL_applications revLookup['-'.charCodeAt(0)] = 62; revLookup['_'.charCodeAt(0)] = 63; function getLens (b64) { var len = b64.length; if (len % 4 > 0) { throw new Error('Invalid string. Length must be a multiple of 4') } // Trim off extra bytes after placeholder bytes are found // See: https://github.com/beatgammit/base64-js/issues/42 var validLen = b64.indexOf('='); if (validLen === -1) validLen = len; var placeHoldersLen = validLen === len ? 0 : 4 - (validLen % 4); return [validLen, placeHoldersLen] } // base64 is 4/3 + up to two characters of the original data function byteLength (b64) { var lens = getLens(b64); var validLen = lens[0]; var placeHoldersLen = lens[1]; return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen } function _byteLength (b64, validLen, placeHoldersLen) { return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen } function toByteArray (b64) { var tmp; var lens = getLens(b64); var validLen = lens[0]; var placeHoldersLen = lens[1]; var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)); var curByte = 0; // if there are placeholders, only get up to the last complete 4 chars var len = placeHoldersLen > 0 ? validLen - 4 : validLen; for (var i = 0; i < len; i += 4) { tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)]; arr[curByte++] = (tmp >> 16) & 0xFF; arr[curByte++] = (tmp >> 8) & 0xFF; arr[curByte++] = tmp & 0xFF; } if (placeHoldersLen === 2) { tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4); arr[curByte++] = tmp & 0xFF; } if (placeHoldersLen === 1) { tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2); arr[curByte++] = (tmp >> 8) & 0xFF; arr[curByte++] = tmp & 0xFF; } return arr } function tripletToBase64 (num) { return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F] } function encodeChunk (uint8, start, end) { var tmp; var output = []; for (var i = start; i < end; i += 3) { tmp = ((uint8[i] << 16) & 0xFF0000) + ((uint8[i + 1] << 8) & 0xFF00) + (uint8[i + 2] & 0xFF); output.push(tripletToBase64(tmp)); } return output.join('') } function fromByteArray (uint8) { var tmp; var len = uint8.length; var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes var parts = []; var maxChunkLength = 16383; // must be multiple of 3 // go through the array every three bytes, we'll deal with trailing stuff later for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { parts.push(encodeChunk( uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength) )); } // pad the end with zeros, but make sure to not forget the extra bytes if (extraBytes === 1) { tmp = uint8[len - 1]; parts.push( lookup[tmp >> 2] + lookup[(tmp << 4) & 0x3F] + '==' ); } else if (extraBytes === 2) { tmp = (uint8[len - 2] << 8) + uint8[len - 1]; parts.push( lookup[tmp >> 10] + lookup[(tmp >> 4) & 0x3F] + lookup[(tmp << 2) & 0x3F] + '=' ); } return parts.join('') } /***/ }), /***/ "./node_modules/codem-isoboxer/dist/iso_boxer.js": /*!*******************************************************!*\ !*** ./node_modules/codem-isoboxer/dist/iso_boxer.js ***! \*******************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { /*! codem-isoboxer v0.3.6 https://github.com/madebyhiro/codem-isoboxer/blob/master/LICENSE.txt */ var ISOBoxer = {}; ISOBoxer.parseBuffer = function(arrayBuffer) { return new ISOFile(arrayBuffer).parse(); }; ISOBoxer.addBoxProcessor = function(type, parser) { if (typeof type !== 'string' || typeof parser !== 'function') { return; } ISOBox.prototype._boxProcessors[type] = parser; }; ISOBoxer.createFile = function() { return new ISOFile(); }; // See ISOBoxer.append() for 'pos' parameter syntax ISOBoxer.createBox = function(type, parent, pos) { var newBox = ISOBox.create(type); if (parent) { parent.append(newBox, pos); } return newBox; }; // See ISOBoxer.append() for 'pos' parameter syntax ISOBoxer.createFullBox = function(type, parent, pos) { var newBox = ISOBoxer.createBox(type, parent, pos); newBox.version = 0; newBox.flags = 0; return newBox; }; ISOBoxer.Utils = {}; ISOBoxer.Utils.dataViewToString = function(dataView, encoding) { var impliedEncoding = encoding || 'utf-8'; if (typeof TextDecoder !== 'undefined') { return new TextDecoder(impliedEncoding).decode(dataView); } var a = []; var i = 0; if (impliedEncoding === 'utf-8') { /* The following algorithm is essentially a rewrite of the UTF8.decode at http://bannister.us/weblog/2007/simple-base64-encodedecode-javascript/ */ while (i < dataView.byteLength) { var c = dataView.getUint8(i++); if (c < 0x80) ; else if (c < 0xe0) { // 2-byte character (11 bits) c = (c & 0x1f) << 6; c |= (dataView.getUint8(i++) & 0x3f); } else if (c < 0xf0) { // 3-byte character (16 bits) c = (c & 0xf) << 12; c |= (dataView.getUint8(i++) & 0x3f) << 6; c |= (dataView.getUint8(i++) & 0x3f); } else { // 4-byte character (21 bits) c = (c & 0x7) << 18; c |= (dataView.getUint8(i++) & 0x3f) << 12; c |= (dataView.getUint8(i++) & 0x3f) << 6; c |= (dataView.getUint8(i++) & 0x3f); } a.push(String.fromCharCode(c)); } } else { // Just map byte-by-byte (probably wrong) while (i < dataView.byteLength) { a.push(String.fromCharCode(dataView.getUint8(i++))); } } return a.join(''); }; ISOBoxer.Utils.utf8ToByteArray = function(string) { // Only UTF-8 encoding is supported by TextEncoder var u, i; if (typeof TextEncoder !== 'undefined') { u = new TextEncoder().encode(string); } else { u = []; for (i = 0; i < string.length; ++i) { var c = string.charCodeAt(i); if (c < 0x80) { u.push(c); } else if (c < 0x800) { u.push(0xC0 | (c >> 6)); u.push(0x80 | (63 & c)); } else if (c < 0x10000) { u.push(0xE0 | (c >> 12)); u.push(0x80 | (63 & (c >> 6))); u.push(0x80 | (63 & c)); } else { u.push(0xF0 | (c >> 18)); u.push(0x80 | (63 & (c >> 12))); u.push(0x80 | (63 & (c >> 6))); u.push(0x80 | (63 & c)); } } } return u; }; // Method to append a box in the list of child boxes // The 'pos' parameter can be either: // - (number) a position index at which to insert the new box // - (string) the type of the box after which to insert the new box // - (object) the box after which to insert the new box ISOBoxer.Utils.appendBox = function(parent, box, pos) { box._offset = parent._cursor.offset; box._root = (parent._root ? parent._root : parent); box._raw = parent._raw; box._parent = parent; if (pos === -1) { // The new box is a sub-box of the parent but not added in boxes array, // for example when the new box is set as an entry (see dref and stsd for example) return; } if (pos === undefined || pos === null) { parent.boxes.push(box); return; } var index = -1, type; if (typeof pos === "number") { index = pos; } else { if (typeof pos === "string") { type = pos; } else if (typeof pos === "object" && pos.type) { type = pos.type; } else { parent.boxes.push(box); return; } for (var i = 0; i < parent.boxes.length; i++) { if (type === parent.boxes[i].type) { index = i + 1; break; } } } parent.boxes.splice(index, 0, box); }; { exports.parseBuffer = ISOBoxer.parseBuffer; exports.addBoxProcessor = ISOBoxer.addBoxProcessor; exports.createFile = ISOBoxer.createFile; exports.createBox = ISOBoxer.createBox; exports.createFullBox = ISOBoxer.createFullBox; exports.Utils = ISOBoxer.Utils; } ISOBoxer.Cursor = function(initialOffset) { this.offset = (typeof initialOffset == 'undefined' ? 0 : initialOffset); }; var ISOFile = function(arrayBuffer) { this._cursor = new ISOBoxer.Cursor(); this.boxes = []; if (arrayBuffer) { this._raw = new DataView(arrayBuffer); } }; ISOFile.prototype.fetch = function(type) { var result = this.fetchAll(type, true); return (result.length ? result[0] : null); }; ISOFile.prototype.fetchAll = function(type, returnEarly) { var result = []; ISOFile._sweep.call(this, type, result, returnEarly); return result; }; ISOFile.prototype.parse = function() { this._cursor.offset = 0; this.boxes = []; while (this._cursor.offset < this._raw.byteLength) { var box = ISOBox.parse(this); // Box could not be parsed if (typeof box.type === 'undefined') break; this.boxes.push(box); } return this; }; ISOFile._sweep = function(type, result, returnEarly) { if (this.type && this.type == type) result.push(this); for (var box in this.boxes) { if (result.length && returnEarly) return; ISOFile._sweep.call(this.boxes[box], type, result, returnEarly); } }; ISOFile.prototype.write = function() { var length = 0, i; for (i = 0; i < this.boxes.length; i++) { length += this.boxes[i].getLength(false); } var bytes = new Uint8Array(length); this._rawo = new DataView(bytes.buffer); this.bytes = bytes; this._cursor.offset = 0; for (i = 0; i < this.boxes.length; i++) { this.boxes[i].write(); } return bytes.buffer; }; ISOFile.prototype.append = function(box, pos) { ISOBoxer.Utils.appendBox(this, box, pos); }; var ISOBox = function() { this._cursor = new ISOBoxer.Cursor(); }; ISOBox.parse = function(parent) { var newBox = new ISOBox(); newBox._offset = parent._cursor.offset; newBox._root = (parent._root ? parent._root : parent); newBox._raw = parent._raw; newBox._parent = parent; newBox._parseBox(); parent._cursor.offset = newBox._raw.byteOffset + newBox._raw.byteLength; return newBox; }; ISOBox.create = function(type) { var newBox = new ISOBox(); newBox.type = type; newBox.boxes = []; return newBox; }; ISOBox.prototype._boxContainers = ['dinf', 'edts', 'mdia', 'meco', 'mfra', 'minf', 'moof', 'moov', 'mvex', 'stbl', 'strk', 'traf', 'trak', 'tref', 'udta', 'vttc', 'sinf', 'schi', 'encv', 'enca']; ISOBox.prototype._boxProcessors = {}; /////////////////////////////////////////////////////////////////////////////////////////////////// // Generic read/write functions ISOBox.prototype._procField = function (name, type, size) { if (this._parsing) { this[name] = this._readField(type, size); } else { this._writeField(type, size, this[name]); } }; ISOBox.prototype._procFieldArray = function (name, length, type, size) { var i; if (this._parsing) { this[name] = []; for (i = 0; i < length; i++) { this[name][i] = this._readField(type, size); } } else { for (i = 0; i < this[name].length; i++) { this._writeField(type, size, this[name][i]); } } }; ISOBox.prototype._procFullBox = function() { this._procField('version', 'uint', 8); this._procField('flags', 'uint', 24); }; ISOBox.prototype._procEntries = function(name, length, fn) { var i; if (this._parsing) { this[name] = []; for (i = 0; i < length; i++) { this[name].push({}); fn.call(this, this[name][i]); } } else { for (i = 0; i < length; i++) { fn.call(this, this[name][i]); } } }; ISOBox.prototype._procSubEntries = function(entry, name, length, fn) { var i; if (this._parsing) { entry[name] = []; for (i = 0; i < length; i++) { entry[name].push({}); fn.call(this, entry[name][i]); } } else { for (i = 0; i < length; i++) { fn.call(this, entry[name][i]); } } }; ISOBox.prototype._procEntryField = function (entry, name, type, size) { if (this._parsing) { entry[name] = this._readField(type, size); } else { this._writeField(type, size, entry[name]); } }; ISOBox.prototype._procSubBoxes = function(name, length) { var i; if (this._parsing) { this[name] = []; for (i = 0; i < length; i++) { this[name].push(ISOBox.parse(this)); } } else { for (i = 0; i < length; i++) { if (this._rawo) { this[name][i].write(); } else { this.size += this[name][i].getLength(); } } } }; /////////////////////////////////////////////////////////////////////////////////////////////////// // Read/parse functions ISOBox.prototype._readField = function(type, size) { switch (type) { case 'uint': return this._readUint(size); case 'int': return this._readInt(size); case 'template': return this._readTemplate(size); case 'string': return (size === -1) ? this._readTerminatedString() : this._readString(size); case 'data': return this._readData(size); case 'utf8': return this._readUTF8String(); default: return -1; } }; ISOBox.prototype._readInt = function(size) { var result = null, offset = this._cursor.offset - this._raw.byteOffset; switch(size) { case 8: result = this._raw.getInt8(offset); break; case 16: result = this._raw.getInt16(offset); break; case 32: result = this._raw.getInt32(offset); break; case 64: // Warning: JavaScript cannot handle 64-bit integers natively. // This will give unexpected results for integers >= 2^53 var s1 = this._raw.getInt32(offset); var s2 = this._raw.getInt32(offset + 4); result = (s1 * Math.pow(2,32)) + s2; break; } this._cursor.offset += (size >> 3); return result; }; ISOBox.prototype._readUint = function(size) { var result = null, offset = this._cursor.offset - this._raw.byteOffset, s1, s2; switch(size) { case 8: result = this._raw.getUint8(offset); break; case 16: result = this._raw.getUint16(offset); break; case 24: s1 = this._raw.getUint16(offset); s2 = this._raw.getUint8(offset + 2); result = (s1 << 8) + s2; break; case 32: result = this._raw.getUint32(offset); break; case 64: // Warning: JavaScript cannot handle 64-bit integers natively. // This will give unexpected results for integers >= 2^53 s1 = this._raw.getUint32(offset); s2 = this._raw.getUint32(offset + 4); result = (s1 * Math.pow(2,32)) + s2; break; } this._cursor.offset += (size >> 3); return result; }; ISOBox.prototype._readString = function(length) { var str = ''; for (var c = 0; c < length; c++) { var char = this._readUint(8); str += String.fromCharCode(char); } return str; }; ISOBox.prototype._readTemplate = function(size) { var pre = this._readUint(size / 2); var post = this._readUint(size / 2); return pre + (post / Math.pow(2, size / 2)); }; ISOBox.prototype._readTerminatedString = function() { var str = ''; while (this._cursor.offset - this._offset < this._raw.byteLength) { var char = this._readUint(8); if (char === 0) break; str += String.fromCharCode(char); } return str; }; ISOBox.prototype._readData = function(size) { var length = (size > 0) ? size : (this._raw.byteLength - (this._cursor.offset - this._offset)); if (length > 0) { var data = new Uint8Array(this._raw.buffer, this._cursor.offset, length); this._cursor.offset += length; return data; } else { return null; } }; ISOBox.prototype._readUTF8String = function() { var length = this._raw.byteLength - (this._cursor.offset - this._offset); var data = null; if (length > 0) { data = new DataView(this._raw.buffer, this._cursor.offset, length); this._cursor.offset += length; } return data ? ISOBoxer.Utils.dataViewToString(data) : data; }; ISOBox.prototype._parseBox = function() { this._parsing = true; this._cursor.offset = this._offset; // return immediately if there are not enough bytes to read the header if (this._offset + 8 > this._raw.buffer.byteLength) { this._root._incomplete = true; return; } this._procField('size', 'uint', 32); this._procField('type', 'string', 4); if (this.size === 1) { this._procField('largesize', 'uint', 64); } if (this.type === 'uuid') { this._procFieldArray('usertype', 16, 'uint', 8); } switch(this.size) { case 0: this._raw = new DataView(this._raw.buffer, this._offset, (this._raw.byteLength - this._cursor.offset + 8)); break; case 1: if (this._offset + this.size > this._raw.buffer.byteLength) { this._incomplete = true; this._root._incomplete = true; } else { this._raw = new DataView(this._raw.buffer, this._offset, this.largesize); } break; default: if (this._offset + this.size > this._raw.buffer.byteLength) { this._incomplete = true; this._root._incomplete = true; } else { this._raw = new DataView(this._raw.buffer, this._offset, this.size); } } // additional parsing if (!this._incomplete) { if (this._boxProcessors[this.type]) { this._boxProcessors[this.type].call(this); } if (this._boxContainers.indexOf(this.type) !== -1) { this._parseContainerBox(); } else{ // Unknown box => read and store box content this._data = this._readData(); } } }; ISOBox.prototype._parseFullBox = function() { this.version = this._readUint(8); this.flags = this._readUint(24); }; ISOBox.prototype._parseContainerBox = function() { this.boxes = []; while (this._cursor.offset - this._raw.byteOffset < this._raw.byteLength) { this.boxes.push(ISOBox.parse(this)); } }; /////////////////////////////////////////////////////////////////////////////////////////////////// // Write functions ISOBox.prototype.append = function(box, pos) { ISOBoxer.Utils.appendBox(this, box, pos); }; ISOBox.prototype.getLength = function() { this._parsing = false; this._rawo = null; this.size = 0; this._procField('size', 'uint', 32); this._procField('type', 'string', 4); if (this.size === 1) { this._procField('largesize', 'uint', 64); } if (this.type === 'uuid') { this._procFieldArray('usertype', 16, 'uint', 8); } if (this._boxProcessors[this.type]) { this._boxProcessors[this.type].call(this); } if (this._boxContainers.indexOf(this.type) !== -1) { for (var i = 0; i < this.boxes.length; i++) { this.size += this.boxes[i].getLength(); } } if (this._data) { this._writeData(this._data); } return this.size; }; ISOBox.prototype.write = function() { this._parsing = false; this._cursor.offset = this._parent._cursor.offset; switch(this.size) { case 0: this._rawo = new DataView(this._parent._rawo.buffer, this._cursor.offset, (this.parent._rawo.byteLength - this._cursor.offset)); break; case 1: this._rawo = new DataView(this._parent._rawo.buffer, this._cursor.offset, this.largesize); break; default: this._rawo = new DataView(this._parent._rawo.buffer, this._cursor.offset, this.size); } this._procField('size', 'uint', 32); this._procField('type', 'string', 4); if (this.size === 1) { this._procField('largesize', 'uint', 64); } if (this.type === 'uuid') { this._procFieldArray('usertype', 16, 'uint', 8); } if (this._boxProcessors[this.type]) { this._boxProcessors[this.type].call(this); } if (this._boxContainers.indexOf(this.type) !== -1) { for (var i = 0; i < this.boxes.length; i++) { this.boxes[i].write(); } } if (this._data) { this._writeData(this._data); } this._parent._cursor.offset += this.size; return this.size; }; ISOBox.prototype._writeInt = function(size, value) { if (this._rawo) { var offset = this._cursor.offset - this._rawo.byteOffset; switch(size) { case 8: this._rawo.setInt8(offset, value); break; case 16: this._rawo.setInt16(offset, value); break; case 32: this._rawo.setInt32(offset, value); break; case 64: // Warning: JavaScript cannot handle 64-bit integers natively. // This will give unexpected results for integers >= 2^53 var s1 = Math.floor(value / Math.pow(2,32)); var s2 = value - (s1 * Math.pow(2,32)); this._rawo.setUint32(offset, s1); this._rawo.setUint32(offset + 4, s2); break; } this._cursor.offset += (size >> 3); } else { this.size += (size >> 3); } }; ISOBox.prototype._writeUint = function(size, value) { if (this._rawo) { var offset = this._cursor.offset - this._rawo.byteOffset, s1, s2; switch(size) { case 8: this._rawo.setUint8(offset, value); break; case 16: this._rawo.setUint16(offset, value); break; case 24: s1 = (value & 0xFFFF00) >> 8; s2 = (value & 0x0000FF); this._rawo.setUint16(offset, s1); this._rawo.setUint8(offset + 2, s2); break; case 32: this._rawo.setUint32(offset, value); break; case 64: // Warning: JavaScript cannot handle 64-bit integers natively. // This will give unexpected results for integers >= 2^53 s1 = Math.floor(value / Math.pow(2,32)); s2 = value - (s1 * Math.pow(2,32)); this._rawo.setUint32(offset, s1); this._rawo.setUint32(offset + 4, s2); break; } this._cursor.offset += (size >> 3); } else { this.size += (size >> 3); } }; ISOBox.prototype._writeString = function(size, str) { for (var c = 0; c < size; c++) { this._writeUint(8, str.charCodeAt(c)); } }; ISOBox.prototype._writeTerminatedString = function(str) { if (str.length === 0) { return; } for (var c = 0; c < str.length; c++) { this._writeUint(8, str.charCodeAt(c)); } this._writeUint(8, 0); }; ISOBox.prototype._writeTemplate = function(size, value) { var pre = Math.floor(value); var post = (value - pre) * Math.pow(2, size / 2); this._writeUint(size / 2, pre); this._writeUint(size / 2, post); }; ISOBox.prototype._writeData = function(data) { var i; //data to copy if (data) { if (this._rawo) { //Array and Uint8Array has also to be managed if (data instanceof Array) { var offset = this._cursor.offset - this._rawo.byteOffset; for (var i = 0; i < data.length; i++) { this._rawo.setInt8(offset + i, data[i]); } this._cursor.offset += data.length; } if (data instanceof Uint8Array) { this._root.bytes.set(data, this._cursor.offset); this._cursor.offset += data.length; } } else { //nothing to copy only size to compute this.size += data.length; } } }; ISOBox.prototype._writeUTF8String = function(string) { var u = ISOBoxer.Utils.utf8ToByteArray(string); if (this._rawo) { var dataView = new DataView(this._rawo.buffer, this._cursor.offset, u.length); for (var i = 0; i < u.length; i++) { dataView.setUint8(i, u[i]); } } else { this.size += u.length; } }; ISOBox.prototype._writeField = function(type, size, value) { switch (type) { case 'uint': this._writeUint(size, value); break; case 'int': this._writeInt(size, value); break; case 'template': this._writeTemplate(size, value); break; case 'string': if (size == -1) { this._writeTerminatedString(value); } else { this._writeString(size, value); } break; case 'data': this._writeData(value); break; case 'utf8': this._writeUTF8String(value); break; default: break; } }; // ISO/IEC 14496-15:2014 - avc1 box ISOBox.prototype._boxProcessors['avc1'] = ISOBox.prototype._boxProcessors['encv'] = function() { // SampleEntry fields this._procFieldArray('reserved1', 6, 'uint', 8); this._procField('data_reference_index', 'uint', 16); // VisualSampleEntry fields this._procField('pre_defined1', 'uint', 16); this._procField('reserved2', 'uint', 16); this._procFieldArray('pre_defined2', 3, 'uint', 32); this._procField('width', 'uint', 16); this._procField('height', 'uint', 16); this._procField('horizresolution', 'template', 32); this._procField('vertresolution', 'template', 32); this._procField('reserved3', 'uint', 32); this._procField('frame_count', 'uint', 16); this._procFieldArray('compressorname', 32,'uint', 8); this._procField('depth', 'uint', 16); this._procField('pre_defined3', 'int', 16); // AVCSampleEntry fields this._procField('config', 'data', -1); }; // ISO/IEC 14496-12:2012 - 8.7.2 Data Reference Box ISOBox.prototype._boxProcessors['dref'] = function() { this._procFullBox(); this._procField('entry_count', 'uint', 32); this._procSubBoxes('entries', this.entry_count); }; // ISO/IEC 14496-12:2012 - 8.6.6 Edit List Box ISOBox.prototype._boxProcessors['elst'] = function() { this._procFullBox(); this._procField('entry_count', 'uint', 32); this._procEntries('entries', this.entry_count, function(entry) { this._procEntryField(entry, 'segment_duration', 'uint', (this.version === 1) ? 64 : 32); this._procEntryField(entry, 'media_time', 'int', (this.version === 1) ? 64 : 32); this._procEntryField(entry, 'media_rate_integer', 'int', 16); this._procEntryField(entry, 'media_rate_fraction', 'int', 16); }); }; // ISO/IEC 23009-1:2014 - 5.10.3.3 Event Message Box ISOBox.prototype._boxProcessors['emsg'] = function() { this._procFullBox(); if (this.version == 1) { this._procField('timescale', 'uint', 32); this._procField('presentation_time', 'uint', 64); this._procField('event_duration', 'uint', 32); this._procField('id', 'uint', 32); this._procField('scheme_id_uri', 'string', -1); this._procField('value', 'string', -1); } else { this._procField('scheme_id_uri', 'string', -1); this._procField('value', 'string', -1); this._procField('timescale', 'uint', 32); this._procField('presentation_time_delta', 'uint', 32); this._procField('event_duration', 'uint', 32); this._procField('id', 'uint', 32); } this._procField('message_data', 'data', -1); }; // ISO/IEC 14496-12:2012 - 8.1.2 Free Space Box ISOBox.prototype._boxProcessors['free'] = ISOBox.prototype._boxProcessors['skip'] = function() { this._procField('data', 'data', -1); }; // ISO/IEC 14496-12:2012 - 8.12.2 Original Format Box ISOBox.prototype._boxProcessors['frma'] = function() { this._procField('data_format', 'uint', 32); }; // ISO/IEC 14496-12:2012 - 4.3 File Type Box / 8.16.2 Segment Type Box ISOBox.prototype._boxProcessors['ftyp'] = ISOBox.prototype._boxProcessors['styp'] = function() { this._procField('major_brand', 'string', 4); this._procField('minor_version', 'uint', 32); var nbCompatibleBrands = -1; if (this._parsing) { nbCompatibleBrands = (this._raw.byteLength - (this._cursor.offset - this._raw.byteOffset)) / 4; } this._procFieldArray('compatible_brands', nbCompatibleBrands, 'string', 4); }; // ISO/IEC 14496-12:2012 - 8.4.3 Handler Reference Box ISOBox.prototype._boxProcessors['hdlr'] = function() { this._procFullBox(); this._procField('pre_defined', 'uint', 32); this._procField('handler_type', 'string', 4); this._procFieldArray('reserved', 3, 'uint', 32); this._procField('name', 'string', -1); }; // ISO/IEC 14496-12:2012 - 8.1.1 Media Data Box ISOBox.prototype._boxProcessors['mdat'] = function() { this._procField('data', 'data', -1); }; // ISO/IEC 14496-12:2012 - 8.4.2 Media Header Box ISOBox.prototype._boxProcessors['mdhd'] = function() { this._procFullBox(); this._procField('creation_time', 'uint', (this.version == 1) ? 64 : 32); this._procField('modification_time', 'uint', (this.version == 1) ? 64 : 32); this._procField('timescale', 'uint', 32); this._procField('duration', 'uint', (this.version == 1) ? 64 : 32); if (!this._parsing && typeof this.language === 'string') { // In case of writing and language has been set as a string, then convert it into char codes array this.language = ((this.language.charCodeAt(0) - 0x60) << 10) | ((this.language.charCodeAt(1) - 0x60) << 5) | ((this.language.charCodeAt(2) - 0x60)); } this._procField('language', 'uint', 16); if (this._parsing) { this.language = String.fromCharCode(((this.language >> 10) & 0x1F) + 0x60, ((this.language >> 5) & 0x1F) + 0x60, (this.language & 0x1F) + 0x60); } this._procField('pre_defined', 'uint', 16); }; // ISO/IEC 14496-12:2012 - 8.8.2 Movie Extends Header Box ISOBox.prototype._boxProcessors['mehd'] = function() { this._procFullBox(); this._procField('fragment_duration', 'uint', (this.version == 1) ? 64 : 32); }; // ISO/IEC 14496-12:2012 - 8.8.5 Movie Fragment Header Box ISOBox.prototype._boxProcessors['mfhd'] = function() { this._procFullBox(); this._procField('sequence_number', 'uint', 32); }; // ISO/IEC 14496-12:2012 - 8.8.11 Movie Fragment Random Access Box ISOBox.prototype._boxProcessors['mfro'] = function() { this._procFullBox(); this._procField('mfra_size', 'uint', 32); // Called mfra_size to distinguish from the normal "size" attribute of a box }; // ISO/IEC 14496-12:2012 - 8.5.2.2 mp4a box (use AudioSampleEntry definition and naming) ISOBox.prototype._boxProcessors['mp4a'] = ISOBox.prototype._boxProcessors['enca'] = function() { // SampleEntry fields this._procFieldArray('reserved1', 6, 'uint', 8); this._procField('data_reference_index', 'uint', 16); // AudioSampleEntry fields this._procFieldArray('reserved2', 2, 'uint', 32); this._procField('channelcount', 'uint', 16); this._procField('samplesize', 'uint', 16); this._procField('pre_defined', 'uint', 16); this._procField('reserved3', 'uint', 16); this._procField('samplerate', 'template', 32); // ESDescriptor fields this._procField('esds', 'data', -1); }; // ISO/IEC 14496-12:2012 - 8.2.2 Movie Header Box ISOBox.prototype._boxProcessors['mvhd'] = function() { this._procFullBox(); this._procField('creation_time', 'uint', (this.version == 1) ? 64 : 32); this._procField('modification_time', 'uint', (this.version == 1) ? 64 : 32); this._procField('timescale', 'uint', 32); this._procField('duration', 'uint', (this.version == 1) ? 64 : 32); this._procField('rate', 'template', 32); this._procField('volume', 'template', 16); this._procField('reserved1', 'uint', 16); this._procFieldArray('reserved2', 2, 'uint', 32); this._procFieldArray('matrix', 9, 'template', 32); this._procFieldArray('pre_defined', 6,'uint', 32); this._procField('next_track_ID', 'uint', 32); }; // ISO/IEC 14496-30:2014 - WebVTT Cue Payload Box. ISOBox.prototype._boxProcessors['payl'] = function() { this._procField('cue_text', 'utf8'); }; //ISO/IEC 23001-7:2011 - 8.1 Protection System Specific Header Box ISOBox.prototype._boxProcessors['pssh'] = function() { this._procFullBox(); this._procFieldArray('SystemID', 16, 'uint', 8); this._procField('DataSize', 'uint', 32); this._procFieldArray('Data', this.DataSize, 'uint', 8); }; // ISO/IEC 14496-12:2012 - 8.12.5 Scheme Type Box ISOBox.prototype._boxProcessors['schm'] = function() { this._procFullBox(); this._procField('scheme_type', 'uint', 32); this._procField('scheme_version', 'uint', 32); if (this.flags & 0x000001) { this._procField('scheme_uri', 'string', -1); } }; // ISO/IEC 14496-12:2012 - 8.6.4.1 sdtp box ISOBox.prototype._boxProcessors['sdtp'] = function() { this._procFullBox(); var sample_count = -1; if (this._parsing) { sample_count = (this._raw.byteLength - (this._cursor.offset - this._raw.byteOffset)); } this._procFieldArray('sample_dependency_table', sample_count, 'uint', 8); }; // ISO/IEC 14496-12:2012 - 8.16.3 Segment Index Box ISOBox.prototype._boxProcessors['sidx'] = function() { this._procFullBox(); this._procField('reference_ID', 'uint', 32); this._procField('timescale', 'uint', 32); this._procField('earliest_presentation_time', 'uint', (this.version == 1) ? 64 : 32); this._procField('first_offset', 'uint', (this.version == 1) ? 64 : 32); this._procField('reserved', 'uint', 16); this._procField('reference_count', 'uint', 16); this._procEntries('references', this.reference_count, function(entry) { if (!this._parsing) { entry.reference = (entry.reference_type & 0x00000001) << 31; entry.reference |= (entry.referenced_size & 0x7FFFFFFF); entry.sap = (entry.starts_with_SAP & 0x00000001) << 31; entry.sap |= (entry.SAP_type & 0x00000003) << 28; entry.sap |= (entry.SAP_delta_time & 0x0FFFFFFF); } this._procEntryField(entry, 'reference', 'uint', 32); this._procEntryField(entry, 'subsegment_duration', 'uint', 32); this._procEntryField(entry, 'sap', 'uint', 32); if (this._parsing) { entry.reference_type = (entry.reference >> 31) & 0x00000001; entry.referenced_size = entry.reference & 0x7FFFFFFF; entry.starts_with_SAP = (entry.sap >> 31) & 0x00000001; entry.SAP_type = (entry.sap >> 28) & 0x00000007; entry.SAP_delta_time = (entry.sap & 0x0FFFFFFF); } }); }; // ISO/IEC 14496-12:2012 - 8.4.5.3 Sound Media Header Box ISOBox.prototype._boxProcessors['smhd'] = function() { this._procFullBox(); this._procField('balance', 'uint', 16); this._procField('reserved', 'uint', 16); }; // ISO/IEC 14496-12:2012 - 8.16.4 Subsegment Index Box ISOBox.prototype._boxProcessors['ssix'] = function() { this._procFullBox(); this._procField('subsegment_count', 'uint', 32); this._procEntries('subsegments', this.subsegment_count, function(subsegment) { this._procEntryField(subsegment, 'ranges_count', 'uint', 32); this._procSubEntries(subsegment, 'ranges', subsegment.ranges_count, function(range) { this._procEntryField(range, 'level', 'uint', 8); this._procEntryField(range, 'range_size', 'uint', 24); }); }); }; // ISO/IEC 14496-12:2012 - 8.5.2 Sample Description Box ISOBox.prototype._boxProcessors['stsd'] = function() { this._procFullBox(); this._procField('entry_count', 'uint', 32); this._procSubBoxes('entries', this.entry_count); }; // ISO/IEC 14496-12:2015 - 8.7.7 Sub-Sample Information Box ISOBox.prototype._boxProcessors['subs'] = function () { this._procFullBox(); this._procField('entry_count', 'uint', 32); this._procEntries('entries', this.entry_count, function(entry) { this._procEntryField(entry, 'sample_delta', 'uint', 32); this._procEntryField(entry, 'subsample_count', 'uint', 16); this._procSubEntries(entry, 'subsamples', entry.subsample_count, function(subsample) { this._procEntryField(subsample, 'subsample_size', 'uint', (this.version === 1) ? 32 : 16); this._procEntryField(subsample, 'subsample_priority', 'uint', 8); this._procEntryField(subsample, 'discardable', 'uint', 8); this._procEntryField(subsample, 'codec_specific_parameters', 'uint', 32); }); }); }; //ISO/IEC 23001-7:2011 - 8.2 Track Encryption Box ISOBox.prototype._boxProcessors['tenc'] = function() { this._procFullBox(); this._procField('default_IsEncrypted', 'uint', 24); this._procField('default_IV_size', 'uint', 8); this._procFieldArray('default_KID', 16, 'uint', 8); }; // ISO/IEC 14496-12:2012 - 8.8.12 Track Fragmnent Decode Time ISOBox.prototype._boxProcessors['tfdt'] = function() { this._procFullBox(); this._procField('baseMediaDecodeTime', 'uint', (this.version == 1) ? 64 : 32); }; // ISO/IEC 14496-12:2012 - 8.8.7 Track Fragment Header Box ISOBox.prototype._boxProcessors['tfhd'] = function() { this._procFullBox(); this._procField('track_ID', 'uint', 32); if (this.flags & 0x01) this._procField('base_data_offset', 'uint', 64); if (this.flags & 0x02) this._procField('sample_description_offset', 'uint', 32); if (this.flags & 0x08) this._procField('default_sample_duration', 'uint', 32); if (this.flags & 0x10) this._procField('default_sample_size', 'uint', 32); if (this.flags & 0x20) this._procField('default_sample_flags', 'uint', 32); }; // ISO/IEC 14496-12:2012 - 8.8.10 Track Fragment Random Access Box ISOBox.prototype._boxProcessors['tfra'] = function() { this._procFullBox(); this._procField('track_ID', 'uint', 32); if (!this._parsing) { this.reserved = 0; this.reserved |= (this.length_size_of_traf_num & 0x00000030) << 4; this.reserved |= (this.length_size_of_trun_num & 0x0000000C) << 2; this.reserved |= (this.length_size_of_sample_num & 0x00000003); } this._procField('reserved', 'uint', 32); if (this._parsing) { this.length_size_of_traf_num = (this.reserved & 0x00000030) >> 4; this.length_size_of_trun_num = (this.reserved & 0x0000000C) >> 2; this.length_size_of_sample_num = (this.reserved & 0x00000003); } this._procField('number_of_entry', 'uint', 32); this._procEntries('entries', this.number_of_entry, function(entry) { this._procEntryField(entry, 'time', 'uint', (this.version === 1) ? 64 : 32); this._procEntryField(entry, 'moof_offset', 'uint', (this.version === 1) ? 64 : 32); this._procEntryField(entry, 'traf_number', 'uint', (this.length_size_of_traf_num + 1) * 8); this._procEntryField(entry, 'trun_number', 'uint', (this.length_size_of_trun_num + 1) * 8); this._procEntryField(entry, 'sample_number', 'uint', (this.length_size_of_sample_num + 1) * 8); }); }; // ISO/IEC 14496-12:2012 - 8.3.2 Track Header Box ISOBox.prototype._boxProcessors['tkhd'] = function() { this._procFullBox(); this._procField('creation_time', 'uint', (this.version == 1) ? 64 : 32); this._procField('modification_time', 'uint', (this.version == 1) ? 64 : 32); this._procField('track_ID', 'uint', 32); this._procField('reserved1', 'uint', 32); this._procField('duration', 'uint', (this.version == 1) ? 64 : 32); this._procFieldArray('reserved2', 2, 'uint', 32); this._procField('layer', 'uint', 16); this._procField('alternate_group', 'uint', 16); this._procField('volume', 'template', 16); this._procField('reserved3', 'uint', 16); this._procFieldArray('matrix', 9, 'template', 32); this._procField('width', 'template', 32); this._procField('height', 'template', 32); }; // ISO/IEC 14496-12:2012 - 8.8.3 Track Extends Box ISOBox.prototype._boxProcessors['trex'] = function() { this._procFullBox(); this._procField('track_ID', 'uint', 32); this._procField('default_sample_description_index', 'uint', 32); this._procField('default_sample_duration', 'uint', 32); this._procField('default_sample_size', 'uint', 32); this._procField('default_sample_flags', 'uint', 32); }; // ISO/IEC 14496-12:2012 - 8.8.8 Track Run Box // Note: the 'trun' box has a direct relation to the 'tfhd' box for defaults. // These defaults are not set explicitly here, but are left to resolve for the user. ISOBox.prototype._boxProcessors['trun'] = function() { this._procFullBox(); this._procField('sample_count', 'uint', 32); if (this.flags & 0x1) this._procField('data_offset', 'int', 32); if (this.flags & 0x4) this._procField('first_sample_flags', 'uint', 32); this._procEntries('samples', this.sample_count, function(sample) { if (this.flags & 0x100) this._procEntryField(sample, 'sample_duration', 'uint', 32); if (this.flags & 0x200) this._procEntryField(sample, 'sample_size', 'uint', 32); if (this.flags & 0x400) this._procEntryField(sample, 'sample_flags', 'uint', 32); if (this.flags & 0x800) this._procEntryField(sample, 'sample_composition_time_offset', (this.version === 1) ? 'int' : 'uint', 32); }); }; // ISO/IEC 14496-12:2012 - 8.7.2 Data Reference Box ISOBox.prototype._boxProcessors['url '] = ISOBox.prototype._boxProcessors['urn '] = function() { this._procFullBox(); if (this.type === 'urn ') { this._procField('name', 'string', -1); } this._procField('location', 'string', -1); }; // ISO/IEC 14496-30:2014 - WebVTT Source Label Box ISOBox.prototype._boxProcessors['vlab'] = function() { this._procField('source_label', 'utf8'); }; // ISO/IEC 14496-12:2012 - 8.4.5.2 Video Media Header Box ISOBox.prototype._boxProcessors['vmhd'] = function() { this._procFullBox(); this._procField('graphicsmode', 'uint', 16); this._procFieldArray('opcolor', 3, 'uint', 16); }; // ISO/IEC 14496-30:2014 - WebVTT Configuration Box ISOBox.prototype._boxProcessors['vttC'] = function() { this._procField('config', 'utf8'); }; // ISO/IEC 14496-30:2014 - WebVTT Empty Sample Box ISOBox.prototype._boxProcessors['vtte'] = function() { // Nothing should happen here. }; /***/ }), /***/ "./node_modules/core-util-is/lib/util.js": /*!***********************************************!*\ !*** ./node_modules/core-util-is/lib/util.js ***! \***********************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(Buffer) {// Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to permit // persons to whom the Software is furnished to do so, subject to the // following conditions: // // The above copyright notice and this permission notice shall be included // in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. // NOTE: These type checking functions intentionally don't use `instanceof` // because it is fragile and can be easily faked with `Object.create()`. function isArray(arg) { if (Array.isArray) { return Array.isArray(arg); } return objectToString(arg) === '[object Array]'; } exports.isArray = isArray; function isBoolean(arg) { return typeof arg === 'boolean'; } exports.isBoolean = isBoolean; function isNull(arg) { return arg === null; } exports.isNull = isNull; function isNullOrUndefined(arg) { return arg == null; } exports.isNullOrUndefined = isNullOrUndefined; function isNumber(arg) { return typeof arg === 'number'; } exports.isNumber = isNumber; function isString(arg) { return typeof arg === 'string'; } exports.isString = isString; function isSymbol(arg) { return typeof arg === 'symbol'; } exports.isSymbol = isSymbol; function isUndefined(arg) { return arg === void 0; } exports.isUndefined = isUndefined; function isRegExp(re) { return objectToString(re) === '[object RegExp]'; } exports.isRegExp = isRegExp; function isObject(arg) { return typeof arg === 'object' && arg !== null; } exports.isObject = isObject; function isDate(d) { return objectToString(d) === '[object Date]'; } exports.isDate = isDate; function isError(e) { return (objectToString(e) === '[object Error]' || e instanceof Error); } exports.isError = isError; function isFunction(arg) { return typeof arg === 'function'; } exports.isFunction = isFunction; function isPrimitive(arg) { return arg === null || typeof arg === 'boolean' || typeof arg === 'number' || typeof arg === 'string' || typeof arg === 'symbol' || // ES6 symbol typeof arg === 'undefined'; } exports.isPrimitive = isPrimitive; exports.isBuffer = Buffer.isBuffer; function objectToString(o) { return Object.prototype.toString.call(o); } /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../node-libs-browser/node_modules/buffer/index.js */ "./node_modules/node-libs-browser/node_modules/buffer/index.js").Buffer)); /***/ }), /***/ "./node_modules/es6-promise/auto.js": /*!******************************************!*\ !*** ./node_modules/es6-promise/auto.js ***! \******************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { // This file can be required in Browserify and Node.js for automatic polyfill // To use it: require('es6-promise/auto'); module.exports = __webpack_require__(/*! ./ */ "./node_modules/es6-promise/dist/es6-promise.js").polyfill(); /***/ }), /***/ "./node_modules/es6-promise/dist/es6-promise.js": /*!******************************************************!*\ !*** ./node_modules/es6-promise/dist/es6-promise.js ***! \******************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process, global) {/*! * @overview es6-promise - a tiny implementation of Promises/A+. * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald) * @license Licensed under MIT license * See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE * @version v4.2.8+1e68dce6 */ (function (global, factory) { module.exports = factory(); }(this, (function () { function objectOrFunction(x) { var type = typeof x; return x !== null && (type === 'object' || type === 'function'); } function isFunction(x) { return typeof x === 'function'; } var _isArray = void 0; if (Array.isArray) { _isArray = Array.isArray; } else { _isArray = function (x) { return Object.prototype.toString.call(x) === '[object Array]'; }; } var isArray = _isArray; var len = 0; var vertxNext = void 0; var customSchedulerFn = void 0; var asap = function asap(callback, arg) { queue[len] = callback; queue[len + 1] = arg; len += 2; if (len === 2) { // If len is 2, that means that we need to schedule an async flush. // If additional callbacks are queued before the queue is flushed, they // will be processed by this flush that we are scheduling. if (customSchedulerFn) { customSchedulerFn(flush); } else { scheduleFlush(); } } }; function setScheduler(scheduleFn) { customSchedulerFn = scheduleFn; } function setAsap(asapFn) { asap = asapFn; } var browserWindow = typeof window !== 'undefined' ? window : undefined; var browserGlobal = browserWindow || {}; var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver; var isNode = typeof self === 'undefined' && typeof process !== 'undefined' && {}.toString.call(process) === '[object process]'; // test for web worker but not in IE10 var isWorker = typeof Uint8ClampedArray !== 'undefined' && typeof importScripts !== 'undefined' && typeof MessageChannel !== 'undefined'; // node function useNextTick() { // node version 0.10.x displays a deprecation warning when nextTick is used recursively // see https://github.com/cujojs/when/issues/410 for details return function () { return process.nextTick(flush); }; } // vertx function useVertxTimer() { if (typeof vertxNext !== 'undefined') { return function () { vertxNext(flush); }; } return useSetTimeout(); } function useMutationObserver() { var iterations = 0; var observer = new BrowserMutationObserver(flush); var node = document.createTextNode(''); observer.observe(node, { characterData: true }); return function () { node.data = iterations = ++iterations % 2; }; } // web worker function useMessageChannel() { var channel = new MessageChannel(); channel.port1.onmessage = flush; return function () { return channel.port2.postMessage(0); }; } function useSetTimeout() { // Store setTimeout reference so es6-promise will be unaffected by // other code modifying setTimeout (like sinon.useFakeTimers()) var globalSetTimeout = setTimeout; return function () { return globalSetTimeout(flush, 1); }; } var queue = new Array(1000); function flush() { for (var i = 0; i < len; i += 2) { var callback = queue[i]; var arg = queue[i + 1]; callback(arg); queue[i] = undefined; queue[i + 1] = undefined; } len = 0; } function attemptVertx() { try { var vertx = Function('return this')().require('vertx'); vertxNext = vertx.runOnLoop || vertx.runOnContext; return useVertxTimer(); } catch (e) { return useSetTimeout(); } } var scheduleFlush = void 0; // Decide what async method to use to triggering processing of queued callbacks: if (isNode) { scheduleFlush = useNextTick(); } else if (BrowserMutationObserver) { scheduleFlush = useMutationObserver(); } else if (isWorker) { scheduleFlush = useMessageChannel(); } else if (browserWindow === undefined && "function" === 'function') { scheduleFlush = attemptVertx(); } else { scheduleFlush = useSetTimeout(); } function then(onFulfillment, onRejection) { var parent = this; var child = new this.constructor(noop); if (child[PROMISE_ID] === undefined) { makePromise(child); } var _state = parent._state; if (_state) { var callback = arguments[_state - 1]; asap(function () { return invokeCallback(_state, child, callback, parent._result); }); } else { subscribe(parent, child, onFulfillment, onRejection); } return child; } /** `Promise.resolve` returns a promise that will become resolved with the passed `value`. It is shorthand for the following: ```javascript let promise = new Promise(function(resolve, reject){ resolve(1); }); promise.then(function(value){ // value === 1 }); ``` Instead of writing the above, your code now simply becomes the following: ```javascript let promise = Promise.resolve(1); promise.then(function(value){ // value === 1 }); ``` @method resolve @static @param {Any} value value that the returned promise will be resolved with Useful for tooling. @return {Promise} a promise that will become fulfilled with the given `value` */ function resolve$1(object) { /*jshint validthis:true */ var Constructor = this; if (object && typeof object === 'object' && object.constructor === Constructor) { return object; } var promise = new Constructor(noop); resolve(promise, object); return promise; } var PROMISE_ID = Math.random().toString(36).substring(2); function noop() {} var PENDING = void 0; var FULFILLED = 1; var REJECTED = 2; function selfFulfillment() { return new TypeError("You cannot resolve a promise with itself"); } function cannotReturnOwn() { return new TypeError('A promises callback cannot return that same promise.'); } function tryThen(then$$1, value, fulfillmentHandler, rejectionHandler) { try { then$$1.call(value, fulfillmentHandler, rejectionHandler); } catch (e) { return e; } } function handleForeignThenable(promise, thenable, then$$1) { asap(function (promise) { var sealed = false; var error = tryThen(then$$1, thenable, function (value) { if (sealed) { return; } sealed = true; if (thenable !== value) { resolve(promise, value); } else { fulfill(promise, value); } }, function (reason) { if (sealed) { return; } sealed = true; reject(promise, reason); }, 'Settle: ' + (promise._label || ' unknown promise')); if (!sealed && error) { sealed = true; reject(promise, error); } }, promise); } function handleOwnThenable(promise, thenable) { if (thenable._state === FULFILLED) { fulfill(promise, thenable._result); } else if (thenable._state === REJECTED) { reject(promise, thenable._result); } else { subscribe(thenable, undefined, function (value) { return resolve(promise, value); }, function (reason) { return reject(promise, reason); }); } } function handleMaybeThenable(promise, maybeThenable, then$$1) { if (maybeThenable.constructor === promise.constructor && then$$1 === then && maybeThenable.constructor.resolve === resolve$1) { handleOwnThenable(promise, maybeThenable); } else { if (then$$1 === undefined) { fulfill(promise, maybeThenable); } else if (isFunction(then$$1)) { handleForeignThenable(promise, maybeThenable, then$$1); } else { fulfill(promise, maybeThenable); } } } function resolve(promise, value) { if (promise === value) { reject(promise, selfFulfillment()); } else if (objectOrFunction(value)) { var then$$1 = void 0; try { then$$1 = value.then; } catch (error) { reject(promise, error); return; } handleMaybeThenable(promise, value, then$$1); } else { fulfill(promise, value); } } function publishRejection(promise) { if (promise._onerror) { promise._onerror(promise._result); } publish(promise); } function fulfill(promise, value) { if (promise._state !== PENDING) { return; } promise._result = value; promise._state = FULFILLED; if (promise._subscribers.length !== 0) { asap(publish, promise); } } function reject(promise, reason) { if (promise._state !== PENDING) { return; } promise._state = REJECTED; promise._result = reason; asap(publishRejection, promise); } function subscribe(parent, child, onFulfillment, onRejection) { var _subscribers = parent._subscribers; var length = _subscribers.length; parent._onerror = null; _subscribers[length] = child; _subscribers[length + FULFILLED] = onFulfillment; _subscribers[length + REJECTED] = onRejection; if (length === 0 && parent._state) { asap(publish, parent); } } function publish(promise) { var subscribers = promise._subscribers; var settled = promise._state; if (subscribers.length === 0) { return; } var child = void 0, callback = void 0, detail = promise._result; for (var i = 0; i < subscribers.length; i += 3) { child = subscribers[i]; callback = subscribers[i + settled]; if (child) { invokeCallback(settled, child, callback, detail); } else { callback(detail); } } promise._subscribers.length = 0; } function invokeCallback(settled, promise, callback, detail) { var hasCallback = isFunction(callback), value = void 0, error = void 0, succeeded = true; if (hasCallback) { try { value = callback(detail); } catch (e) { succeeded = false; error = e; } if (promise === value) { reject(promise, cannotReturnOwn()); return; } } else { value = detail; } if (promise._state !== PENDING) ; else if (hasCallback && succeeded) { resolve(promise, value); } else if (succeeded === false) { reject(promise, error); } else if (settled === FULFILLED) { fulfill(promise, value); } else if (settled === REJECTED) { reject(promise, value); } } function initializePromise(promise, resolver) { try { resolver(function resolvePromise(value) { resolve(promise, value); }, function rejectPromise(reason) { reject(promise, reason); }); } catch (e) { reject(promise, e); } } var id = 0; function nextId() { return id++; } function makePromise(promise) { promise[PROMISE_ID] = id++; promise._state = undefined; promise._result = undefined; promise._subscribers = []; } function validationError() { return new Error('Array Methods must be provided an Array'); } var Enumerator = function () { function Enumerator(Constructor, input) { this._instanceConstructor = Constructor; this.promise = new Constructor(noop); if (!this.promise[PROMISE_ID]) { makePromise(this.promise); } if (isArray(input)) { this.length = input.length; this._remaining = input.length; this._result = new Array(this.length); if (this.length === 0) { fulfill(this.promise, this._result); } else { this.length = this.length || 0; this._enumerate(input); if (this._remaining === 0) { fulfill(this.promise, this._result); } } } else { reject(this.promise, validationError()); } } Enumerator.prototype._enumerate = function _enumerate(input) { for (var i = 0; this._state === PENDING && i < input.length; i++) { this._eachEntry(input[i], i); } }; Enumerator.prototype._eachEntry = function _eachEntry(entry, i) { var c = this._instanceConstructor; var resolve$$1 = c.resolve; if (resolve$$1 === resolve$1) { var _then = void 0; var error = void 0; var didError = false; try { _then = entry.then; } catch (e) { didError = true; error = e; } if (_then === then && entry._state !== PENDING) { this._settledAt(entry._state, i, entry._result); } else if (typeof _then !== 'function') { this._remaining--; this._result[i] = entry; } else if (c === Promise$1) { var promise = new c(noop); if (didError) { reject(promise, error); } else { handleMaybeThenable(promise, entry, _then); } this._willSettleAt(promise, i); } else { this._willSettleAt(new c(function (resolve$$1) { return resolve$$1(entry); }), i); } } else { this._willSettleAt(resolve$$1(entry), i); } }; Enumerator.prototype._settledAt = function _settledAt(state, i, value) { var promise = this.promise; if (promise._state === PENDING) { this._remaining--; if (state === REJECTED) { reject(promise, value); } else { this._result[i] = value; } } if (this._remaining === 0) { fulfill(promise, this._result); } }; Enumerator.prototype._willSettleAt = function _willSettleAt(promise, i) { var enumerator = this; subscribe(promise, undefined, function (value) { return enumerator._settledAt(FULFILLED, i, value); }, function (reason) { return enumerator._settledAt(REJECTED, i, reason); }); }; return Enumerator; }(); /** `Promise.all` accepts an array of promises, and returns a new promise which is fulfilled with an array of fulfillment values for the passed promises, or rejected with the reason of the first passed promise to be rejected. It casts all elements of the passed iterable to promises as it runs this algorithm. Example: ```javascript let promise1 = resolve(1); let promise2 = resolve(2); let promise3 = resolve(3); let promises = [ promise1, promise2, promise3 ]; Promise.all(promises).then(function(array){ // The array here would be [ 1, 2, 3 ]; }); ``` If any of the `promises` given to `all` are rejected, the first promise that is rejected will be given as an argument to the returned promises's rejection handler. For example: Example: ```javascript let promise1 = resolve(1); let promise2 = reject(new Error("2")); let promise3 = reject(new Error("3")); let promises = [ promise1, promise2, promise3 ]; Promise.all(promises).then(function(array){ // Code here never runs because there are rejected promises! }, function(error) { // error.message === "2" }); ``` @method all @static @param {Array} entries array of promises @param {String} label optional string for labeling the promise. Useful for tooling. @return {Promise} promise that is fulfilled when all `promises` have been fulfilled, or rejected if any of them become rejected. @static */ function all(entries) { return new Enumerator(this, entries).promise; } /** `Promise.race` returns a new promise which is settled in the same way as the first passed promise to settle. Example: ```javascript let promise1 = new Promise(function(resolve, reject){ setTimeout(function(){ resolve('promise 1'); }, 200); }); let promise2 = new Promise(function(resolve, reject){ setTimeout(function(){ resolve('promise 2'); }, 100); }); Promise.race([promise1, promise2]).then(function(result){ // result === 'promise 2' because it was resolved before promise1 // was resolved. }); ``` `Promise.race` is deterministic in that only the state of the first settled promise matters. For example, even if other promises given to the `promises` array argument are resolved, but the first settled promise has become rejected before the other promises became fulfilled, the returned promise will become rejected: ```javascript let promise1 = new Promise(function(resolve, reject){ setTimeout(function(){ resolve('promise 1'); }, 200); }); let promise2 = new Promise(function(resolve, reject){ setTimeout(function(){ reject(new Error('promise 2')); }, 100); }); Promise.race([promise1, promise2]).then(function(result){ // Code here never runs }, function(reason){ // reason.message === 'promise 2' because promise 2 became rejected before // promise 1 became fulfilled }); ``` An example real-world use case is implementing timeouts: ```javascript Promise.race([ajax('foo.json'), timeout(5000)]) ``` @method race @static @param {Array} promises array of promises to observe Useful for tooling. @return {Promise} a promise which settles in the same way as the first passed promise to settle. */ function race(entries) { /*jshint validthis:true */ var Constructor = this; if (!isArray(entries)) { return new Constructor(function (_, reject) { return reject(new TypeError('You must pass an array to race.')); }); } else { return new Constructor(function (resolve, reject) { var length = entries.length; for (var i = 0; i < length; i++) { Constructor.resolve(entries[i]).then(resolve, reject); } }); } } /** `Promise.reject` returns a promise rejected with the passed `reason`. It is shorthand for the following: ```javascript let promise = new Promise(function(resolve, reject){ reject(new Error('WHOOPS')); }); promise.then(function(value){ // Code here doesn't run because the promise is rejected! }, function(reason){ // reason.message === 'WHOOPS' }); ``` Instead of writing the above, your code now simply becomes the following: ```javascript let promise = Promise.reject(new Error('WHOOPS')); promise.then(function(value){ // Code here doesn't run because the promise is rejected! }, function(reason){ // reason.message === 'WHOOPS' }); ``` @method reject @static @param {Any} reason value that the returned promise will be rejected with. Useful for tooling. @return {Promise} a promise rejected with the given `reason`. */ function reject$1(reason) { /*jshint validthis:true */ var Constructor = this; var promise = new Constructor(noop); reject(promise, reason); return promise; } function needsResolver() { throw new TypeError('You must pass a resolver function as the first argument to the promise constructor'); } function needsNew() { throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function."); } /** Promise objects represent the eventual result of an asynchronous operation. The primary way of interacting with a promise is through its `then` method, which registers callbacks to receive either a promise's eventual value or the reason why the promise cannot be fulfilled. Terminology ----------- - `promise` is an object or function with a `then` method whose behavior conforms to this specification. - `thenable` is an object or function that defines a `then` method. - `value` is any legal JavaScript value (including undefined, a thenable, or a promise). - `exception` is a value that is thrown using the throw statement. - `reason` is a value that indicates why a promise was rejected. - `settled` the final resting state of a promise, fulfilled or rejected. A promise can be in one of three states: pending, fulfilled, or rejected. Promises that are fulfilled have a fulfillment value and are in the fulfilled state. Promises that are rejected have a rejection reason and are in the rejected state. A fulfillment value is never a thenable. Promises can also be said to *resolve* a value. If this value is also a promise, then the original promise's settled state will match the value's settled state. So a promise that *resolves* a promise that rejects will itself reject, and a promise that *resolves* a promise that fulfills will itself fulfill. Basic Usage: ------------ ```js let promise = new Promise(function(resolve, reject) { // on success resolve(value); // on failure reject(reason); }); promise.then(function(value) { // on fulfillment }, function(reason) { // on rejection }); ``` Advanced Usage: --------------- Promises shine when abstracting away asynchronous interactions such as `XMLHttpRequest`s. ```js function getJSON(url) { return new Promise(function(resolve, reject){ let xhr = new XMLHttpRequest(); xhr.open('GET', url); xhr.onreadystatechange = handler; xhr.responseType = 'json'; xhr.setRequestHeader('Accept', 'application/json'); xhr.send(); function handler() { if (this.readyState === this.DONE) { if (this.status === 200) { resolve(this.response); } else { reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']')); } } }; }); } getJSON('/posts.json').then(function(json) { // on fulfillment }, function(reason) { // on rejection }); ``` Unlike callbacks, promises are great composable primitives. ```js Promise.all([ getJSON('/posts'), getJSON('/comments') ]).then(function(values){ values[0] // => postsJSON values[1] // => commentsJSON return values; }); ``` @class Promise @param {Function} resolver Useful for tooling. @constructor */ var Promise$1 = function () { function Promise(resolver) { this[PROMISE_ID] = nextId(); this._result = this._state = undefined; this._subscribers = []; if (noop !== resolver) { typeof resolver !== 'function' && needsResolver(); this instanceof Promise ? initializePromise(this, resolver) : needsNew(); } } /** The primary way of interacting with a promise is through its `then` method, which registers callbacks to receive either a promise's eventual value or the reason why the promise cannot be fulfilled. ```js findUser().then(function(user){ // user is available }, function(reason){ // user is unavailable, and you are given the reason why }); ``` Chaining -------- The return value of `then` is itself a promise. This second, 'downstream' promise is resolved with the return value of the first promise's fulfillment or rejection handler, or rejected if the handler throws an exception. ```js findUser().then(function (user) { return user.name; }, function (reason) { return 'default name'; }).then(function (userName) { // If `findUser` fulfilled, `userName` will be the user's name, otherwise it // will be `'default name'` }); findUser().then(function (user) { throw new Error('Found user, but still unhappy'); }, function (reason) { throw new Error('`findUser` rejected and we're unhappy'); }).then(function (value) { // never reached }, function (reason) { // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'. // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'. }); ``` If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream. ```js findUser().then(function (user) { throw new PedagogicalException('Upstream error'); }).then(function (value) { // never reached }).then(function (value) { // never reached }, function (reason) { // The `PedgagocialException` is propagated all the way down to here }); ``` Assimilation ------------ Sometimes the value you want to propagate to a downstream promise can only be retrieved asynchronously. This can be achieved by returning a promise in the fulfillment or rejection handler. The downstream promise will then be pending until the returned promise is settled. This is called *assimilation*. ```js findUser().then(function (user) { return findCommentsByAuthor(user); }).then(function (comments) { // The user's comments are now available }); ``` If the assimliated promise rejects, then the downstream promise will also reject. ```js findUser().then(function (user) { return findCommentsByAuthor(user); }).then(function (comments) { // If `findCommentsByAuthor` fulfills, we'll have the value here }, function (reason) { // If `findCommentsByAuthor` rejects, we'll have the reason here }); ``` Simple Example -------------- Synchronous Example ```javascript let result; try { result = findResult(); // success } catch(reason) { // failure } ``` Errback Example ```js findResult(function(result, err){ if (err) { // failure } else { // success } }); ``` Promise Example; ```javascript findResult().then(function(result){ // success }, function(reason){ // failure }); ``` Advanced Example -------------- Synchronous Example ```javascript let author, books; try { author = findAuthor(); books = findBooksByAuthor(author); // success } catch(reason) { // failure } ``` Errback Example ```js function foundBooks(books) { } function failure(reason) { } findAuthor(function(author, err){ if (err) { failure(err); // failure } else { try { findBoooksByAuthor(author, function(books, err) { if (err) { failure(err); } else { try { foundBooks(books); } catch(reason) { failure(reason); } } }); } catch(error) { failure(err); } // success } }); ``` Promise Example; ```javascript findAuthor(). then(findBooksByAuthor). then(function(books){ // found books }).catch(function(reason){ // something went wrong }); ``` @method then @param {Function} onFulfilled @param {Function} onRejected Useful for tooling. @return {Promise} */ /** `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same as the catch block of a try/catch statement. ```js function findAuthor(){ throw new Error('couldn't find that author'); } // synchronous try { findAuthor(); } catch(reason) { // something went wrong } // async with promises findAuthor().catch(function(reason){ // something went wrong }); ``` @method catch @param {Function} onRejection Useful for tooling. @return {Promise} */ Promise.prototype.catch = function _catch(onRejection) { return this.then(null, onRejection); }; /** `finally` will be invoked regardless of the promise's fate just as native try/catch/finally behaves Synchronous example: ```js findAuthor() { if (Math.random() > 0.5) { throw new Error(); } return new Author(); } try { return findAuthor(); // succeed or fail } catch(error) { return findOtherAuther(); } finally { // always runs // doesn't affect the return value } ``` Asynchronous example: ```js findAuthor().catch(function(reason){ return findOtherAuther(); }).finally(function(){ // author was either found, or not }); ``` @method finally @param {Function} callback @return {Promise} */ Promise.prototype.finally = function _finally(callback) { var promise = this; var constructor = promise.constructor; if (isFunction(callback)) { return promise.then(function (value) { return constructor.resolve(callback()).then(function () { return value; }); }, function (reason) { return constructor.resolve(callback()).then(function () { throw reason; }); }); } return promise.then(callback, callback); }; return Promise; }(); Promise$1.prototype.then = then; Promise$1.all = all; Promise$1.race = race; Promise$1.resolve = resolve$1; Promise$1.reject = reject$1; Promise$1._setScheduler = setScheduler; Promise$1._setAsap = setAsap; Promise$1._asap = asap; /*global self*/ function polyfill() { var local = void 0; if (typeof global !== 'undefined') { local = global; } else if (typeof self !== 'undefined') { local = self; } else { try { local = Function('return this')(); } catch (e) { throw new Error('polyfill failed because global object is unavailable in this environment'); } } var P = local.Promise; if (P) { var promiseToString = null; try { promiseToString = Object.prototype.toString.call(P.resolve()); } catch (e) { // silently ignored } if (promiseToString === '[object Promise]' && !P.cast) { return; } } local.Promise = Promise$1; } // Strange compat.. Promise$1.polyfill = polyfill; Promise$1.Promise = Promise$1; return Promise$1; }))); /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../process/browser.js */ "./node_modules/process/browser.js"), __webpack_require__(/*! ./../../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js"))); /***/ }), /***/ "./node_modules/fast-deep-equal/index.js": /*!***********************************************!*\ !*** ./node_modules/fast-deep-equal/index.js ***! \***********************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { var isArray = Array.isArray; var keyList = Object.keys; var hasProp = Object.prototype.hasOwnProperty; module.exports = function equal(a, b) { if (a === b) return true; if (a && b && typeof a == 'object' && typeof b == 'object') { var arrA = isArray(a) , arrB = isArray(b) , i , length , key; if (arrA && arrB) { length = a.length; if (length != b.length) return false; for (i = length; i-- !== 0;) if (!equal(a[i], b[i])) return false; return true; } if (arrA != arrB) return false; var dateA = a instanceof Date , dateB = b instanceof Date; if (dateA != dateB) return false; if (dateA && dateB) return a.getTime() == b.getTime(); var regexpA = a instanceof RegExp , regexpB = b instanceof RegExp; if (regexpA != regexpB) return false; if (regexpA && regexpB) return a.toString() == b.toString(); var keys = keyList(a); length = keys.length; if (length !== keyList(b).length) return false; for (i = length; i-- !== 0;) if (!hasProp.call(b, keys[i])) return false; for (i = length; i-- !== 0;) { key = keys[i]; if (!equal(a[key], b[key])) return false; } return true; } return a!==a && b!==b; }; /***/ }), /***/ "./node_modules/ieee754/index.js": /*!***************************************!*\ !*** ./node_modules/ieee754/index.js ***! \***************************************/ /*! no static exports found */ /***/ (function(module, exports) { exports.read = function (buffer, offset, isLE, mLen, nBytes) { var e, m; var eLen = (nBytes * 8) - mLen - 1; var eMax = (1 << eLen) - 1; var eBias = eMax >> 1; var nBits = -7; var i = isLE ? (nBytes - 1) : 0; var d = isLE ? -1 : 1; var s = buffer[offset + i]; i += d; e = s & ((1 << (-nBits)) - 1); s >>= (-nBits); nBits += eLen; for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {} m = e & ((1 << (-nBits)) - 1); e >>= (-nBits); nBits += mLen; for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {} if (e === 0) { e = 1 - eBias; } else if (e === eMax) { return m ? NaN : ((s ? -1 : 1) * Infinity) } else { m = m + Math.pow(2, mLen); e = e - eBias; } return (s ? -1 : 1) * m * Math.pow(2, e - mLen) }; exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { var e, m, c; var eLen = (nBytes * 8) - mLen - 1; var eMax = (1 << eLen) - 1; var eBias = eMax >> 1; var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0); var i = isLE ? 0 : (nBytes - 1); var d = isLE ? 1 : -1; var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0; value = Math.abs(value); if (isNaN(value) || value === Infinity) { m = isNaN(value) ? 1 : 0; e = eMax; } else { e = Math.floor(Math.log(value) / Math.LN2); if (value * (c = Math.pow(2, -e)) < 1) { e--; c *= 2; } if (e + eBias >= 1) { value += rt / c; } else { value += rt * Math.pow(2, 1 - eBias); } if (value * c >= 2) { e++; c /= 2; } if (e + eBias >= eMax) { m = 0; e = eMax; } else if (e + eBias >= 1) { m = ((value * c) - 1) * Math.pow(2, mLen); e = e + eBias; } else { m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen); e = 0; } } for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} e = (e << mLen) | m; eLen += mLen; for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} buffer[offset + i - d] |= s * 128; }; /***/ }), /***/ "./node_modules/imsc/src/main/js/doc.js": /*!**********************************************!*\ !*** ./node_modules/imsc/src/main/js/doc.js ***! \**********************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { (function (imscDoc, sax, imscNames, imscStyles, imscUtils) { /** * Allows a client to provide callbacks to handle children of the element * @typedef {Object} MetadataHandler * @property {?OpenTagCallBack} onOpenTag * @property {?CloseTagCallBack} onCloseTag * @property {?TextCallBack} onText */ /** * Called when the opening tag of an element node is encountered. * @callback OpenTagCallBack * @param {string} ns Namespace URI of the element * @param {string} name Local name of the element * @param {Object[]} attributes List of attributes, each consisting of a * `uri`, `name` and `value` */ /** * Called when the closing tag of an element node is encountered. * @callback CloseTagCallBack */ /** * Called when a text node is encountered. * @callback TextCallBack * @param {string} contents Contents of the text node */ /** * Parses an IMSC1 document into an opaque in-memory representation that exposes * a single method
getMediaTimeEvents()
that returns a list of time * offsets (in seconds) of the ISD, i.e. the points in time where the visual * representation of the document change. `metadataHandler` allows the caller to * be called back when nodes are present in elements. * * @param {string} xmlstring XML document * @param {?module:imscUtils.ErrorHandler} errorHandler Error callback * @param {?MetadataHandler} metadataHandler Callback for elements * @returns {Object} Opaque in-memory representation of an IMSC1 document */ imscDoc.fromXML = function (xmlstring, errorHandler, metadataHandler) { var p = sax.parser(true, {xmlns: true}); var estack = []; var xmllangstack = []; var xmlspacestack = []; var metadata_depth = 0; var doc = null; p.onclosetag = function (node) { if (estack[0] instanceof Styling) { /* flatten chained referential styling */ for (var sid in estack[0].styles) { mergeChainedStyles(estack[0], estack[0].styles[sid], errorHandler); } } else if (estack[0] instanceof P || estack[0] instanceof Span) { /* merge anonymous spans */ if (estack[0].contents.length > 1) { var cs = [estack[0].contents[0]]; var c; for (c = 1; c < estack[0].contents.length; c++) { if (estack[0].contents[c] instanceof AnonymousSpan && cs[cs.length - 1] instanceof AnonymousSpan) { cs[cs.length - 1].text += estack[0].contents[c].text; } else { cs.push(estack[0].contents[c]); } } estack[0].contents = cs; } // remove redundant nested anonymous spans (9.3.3(1)(c)) if (estack[0] instanceof Span && estack[0].contents.length === 1 && estack[0].contents[0] instanceof AnonymousSpan) { estack[0].text = estack[0].contents[0].text; delete estack[0].contents; } } else if (estack[0] instanceof ForeignElement) { if (estack[0].node.uri === imscNames.ns_tt && estack[0].node.local === 'metadata') { /* leave the metadata element */ metadata_depth--; } else if (metadata_depth > 0 && metadataHandler && 'onCloseTag' in metadataHandler) { /* end of child of metadata element */ metadataHandler.onCloseTag(); } } // TODO: delete stylerefs? // maintain the xml:space stack xmlspacestack.shift(); // maintain the xml:lang stack xmllangstack.shift(); // prepare for the next element estack.shift(); }; p.ontext = function (str) { if (estack[0] === undefined) ; else if (estack[0] instanceof Span || estack[0] instanceof P) { /* create an anonymous span */ var s = new AnonymousSpan(); s.initFromText(doc, estack[0], str, xmlspacestack[0], errorHandler); estack[0].contents.push(s); } else if (estack[0] instanceof ForeignElement && metadata_depth > 0 && metadataHandler && 'onText' in metadataHandler) { /* text node within a child of metadata element */ metadataHandler.onText(str); } }; p.onopentag = function (node) { // maintain the xml:space stack var xmlspace = node.attributes["xml:space"]; if (xmlspace) { xmlspacestack.unshift(xmlspace.value); } else { if (xmlspacestack.length === 0) { xmlspacestack.unshift("default"); } else { xmlspacestack.unshift(xmlspacestack[0]); } } /* maintain the xml:lang stack */ var xmllang = node.attributes["xml:lang"]; if (xmllang) { xmllangstack.unshift(xmllang.value); } else { if (xmllangstack.length === 0) { xmllangstack.unshift(""); } else { xmllangstack.unshift(xmllangstack[0]); } } /* process the element */ if (node.uri === imscNames.ns_tt) { if (node.local === 'tt') { if (doc !== null) { reportFatal(errorHandler, "Two elements at (" + this.line + "," + this.column + ")"); } doc = new TT(); doc.initFromNode(node, errorHandler); estack.unshift(doc); } else if (node.local === 'head') { if (!(estack[0] instanceof TT)) { reportFatal(errorHandler, "Parent of element is not at (" + this.line + "," + this.column + ")"); } if (doc.head !== null) { reportFatal("Second element at (" + this.line + "," + this.column + ")"); } doc.head = new Head(); estack.unshift(doc.head); } else if (node.local === 'styling') { if (!(estack[0] instanceof Head)) { reportFatal(errorHandler, "Parent of element is not at (" + this.line + "," + this.column + ")"); } if (doc.head.styling !== null) { reportFatal("Second element at (" + this.line + "," + this.column + ")"); } doc.head.styling = new Styling(); estack.unshift(doc.head.styling); } else if (node.local === 'style') { var s; if (estack[0] instanceof Styling) { s = new Style(); s.initFromNode(node, errorHandler); /* ignore