videoWorker.worker.js 79 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  1. ! function(t) { var e = {};
  2. function r(a) { if (e[a]) return e[a].exports; var n = e[a] = { i: a, l: !1, exports: {} }; return t[a].call(n.exports, n, n.exports, r), n.l = !0, n.exports }
  3. r.m = t, r.c = e, r.d = function(t, e, a) { r.o(t, e) || Object.defineProperty(t, e, { enumerable: !0, get: a }) }, r.r = function(t) { "undefined" !== typeof Symbol && Symbol.toStringTag && Object.defineProperty(t, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t, "__esModule", { value: !0 }) }, r.t = function(t, e) { if (1 & e && (t = r(t)), 8 & e) return t; if (4 & e && "object" === typeof t && t && t.__esModule) return t; var a = Object.create(null); if (r.r(a), Object.defineProperty(a, "default", { enumerable: !0, value: t }), 2 & e && "string" != typeof t)
  4. for (var n in t) r.d(a, n, function(e) { return t[e] }.bind(null, n)); return a }, r.n = function(t) { var e = t && t.__esModule ? function() { return t.default } : function() { return t }; return r.d(e, "a", e), e }, r.o = function(t, e) { return Object.prototype.hasOwnProperty.call(t, e) }, r.p = "", r(r.s = 0) }([function(t, e, r) { "use strict";
  5. function a(t) { return (a = "function" === typeof Symbol && "symbol" === typeof Symbol.iterator ? function(t) { return typeof t } : function(t) { return t && "function" === typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t })(t) } if (r.r(e), "undefined" == typeof n) var n = {};
  6. n.MD5 = function(t) {
  7. function e(t) { var e = (t >>> 0).toString(16); return "00000000".substr(0, 8 - e.length) + e }
  8. function r(t, e, r) { return t & e | ~t & r }
  9. function n(t, e, r) { return r & t | ~r & e }
  10. function i(t, e, r) { return t ^ e ^ r }
  11. function o(t, e, r) { return e ^ (t | ~r) }
  12. function s(t, e) { return t[e + 3] << 24 | t[e + 2] << 16 | t[e + 1] << 8 | t[e] }
  13. function u(t) { for (var e = [], r = 0; r < t.length; r++)
  14. if (t.charCodeAt(r) <= 127) e.push(t.charCodeAt(r));
  15. else
  16. for (var a = encodeURIComponent(t.charAt(r)).substr(1).split("%"), n = 0; n < a.length; n++) e.push(parseInt(a[n], 16));
  17. return e }
  18. function f(t) { for (var e = new Array(t.length), r = 0; r < t.length; r++) e[r] = t[r]; return e } var l = null,
  19. c = null;
  20. function p(t, e) { return 4294967295 & t + e } return "string" == typeof t ? l = u(t) : t.constructor == Array ? 0 === t.length ? l = t : "string" == typeof t[0] ? l = function(t) { for (var e = [], r = 0; r < t.length; r++) e = e.concat(u(t[r])); return e }(t) : "number" == typeof t[0] ? l = t : c = a(t[0]) : "undefined" != typeof ArrayBuffer ? t instanceof ArrayBuffer ? l = f(new Uint8Array(t)) : t instanceof Uint8Array || t instanceof Int8Array ? l = f(t) : t instanceof Uint32Array || t instanceof Int32Array || t instanceof Uint16Array || t instanceof Int16Array || t instanceof Float32Array || t instanceof Float64Array ? l = f(new Uint8Array(t.buffer)) : c = a(t) : c = a(t), c && alert("MD5 type mismatch, cannot process " + c),
  21. function() {
  22. function t(t, e, r, a) { var n, i, o = y;
  23. y = v, v = g, g = p(g, (n = p(h, p(t, p(e, r)))) << (i = a) & 4294967295 | n >>> 32 - i), h = o } var a = l.length;
  24. l.push(128); var u = l.length % 64; if (u > 56) { for (var f = 0; f < 64 - u; f++) l.push(0);
  25. u = l.length % 64 } for (f = 0; f < 56 - u; f++) l.push(0);
  26. l = l.concat(function(t) { for (var e = [], r = 0; r < 8; r++) e.push(255 & t), t >>>= 8; return e }(8 * a)); var c = 1732584193,
  27. m = 4023233417,
  28. d = 2562383102,
  29. _ = 271733878,
  30. h = 0,
  31. g = 0,
  32. v = 0,
  33. y = 0; for (f = 0; f < l.length / 64; f++) { h = c; var b = 64 * f;
  34. t(r(g = m, v = d, y = _), 3614090360, s(l, b), 7), t(r(g, v, y), 3905402710, s(l, b + 4), 12), t(r(g, v, y), 606105819, s(l, b + 8), 17), t(r(g, v, y), 3250441966, s(l, b + 12), 22), t(r(g, v, y), 4118548399, s(l, b + 16), 7), t(r(g, v, y), 1200080426, s(l, b + 20), 12), t(r(g, v, y), 2821735955, s(l, b + 24), 17), t(r(g, v, y), 4249261313, s(l, b + 28), 22), t(r(g, v, y), 1770035416, s(l, b + 32), 7), t(r(g, v, y), 2336552879, s(l, b + 36), 12), t(r(g, v, y), 4294925233, s(l, b + 40), 17), t(r(g, v, y), 2304563134, s(l, b + 44), 22), t(r(g, v, y), 1804603682, s(l, b + 48), 7), t(r(g, v, y), 4254626195, s(l, b + 52), 12), t(r(g, v, y), 2792965006, s(l, b + 56), 17), t(r(g, v, y), 1236535329, s(l, b + 60), 22), t(n(g, v, y), 4129170786, s(l, b + 4), 5), t(n(g, v, y), 3225465664, s(l, b + 24), 9), t(n(g, v, y), 643717713, s(l, b + 44), 14), t(n(g, v, y), 3921069994, s(l, b), 20), t(n(g, v, y), 3593408605, s(l, b + 20), 5), t(n(g, v, y), 38016083, s(l, b + 40), 9), t(n(g, v, y), 3634488961, s(l, b + 60), 14), t(n(g, v, y), 3889429448, s(l, b + 16), 20), t(n(g, v, y), 568446438, s(l, b + 36), 5), t(n(g, v, y), 3275163606, s(l, b + 56), 9), t(n(g, v, y), 4107603335, s(l, b + 12), 14), t(n(g, v, y), 1163531501, s(l, b + 32), 20), t(n(g, v, y), 2850285829, s(l, b + 52), 5), t(n(g, v, y), 4243563512, s(l, b + 8), 9), t(n(g, v, y), 1735328473, s(l, b + 28), 14), t(n(g, v, y), 2368359562, s(l, b + 48), 20), t(i(g, v, y), 4294588738, s(l, b + 20), 4), t(i(g, v, y), 2272392833, s(l, b + 32), 11), t(i(g, v, y), 1839030562, s(l, b + 44), 16), t(i(g, v, y), 4259657740, s(l, b + 56), 23), t(i(g, v, y), 2763975236, s(l, b + 4), 4), t(i(g, v, y), 1272893353, s(l, b + 16), 11), t(i(g, v, y), 4139469664, s(l, b + 28), 16), t(i(g, v, y), 3200236656, s(l, b + 40), 23), t(i(g, v, y), 681279174, s(l, b + 52), 4), t(i(g, v, y), 3936430074, s(l, b), 11), t(i(g, v, y), 3572445317, s(l, b + 12), 16), t(i(g, v, y), 76029189, s(l, b + 24), 23), t(i(g, v, y), 3654602809, s(l, b + 36), 4), t(i(g, v, y), 3873151461, s(l, b + 48), 11), t(i(g, v, y), 530742520, s(l, b + 60), 16), t(i(g, v, y), 3299628645, s(l, b + 8), 23), t(o(g, v, y), 4096336452, s(l, b), 6), t(o(g, v, y), 1126891415, s(l, b + 28), 10), t(o(g, v, y), 2878612391, s(l, b + 56), 15), t(o(g, v, y), 4237533241, s(l, b + 20), 21), t(o(g, v, y), 1700485571, s(l, b + 48), 6), t(o(g, v, y), 2399980690, s(l, b + 12), 10), t(o(g, v, y), 4293915773, s(l, b + 40), 15), t(o(g, v, y), 2240044497, s(l, b + 4), 21), t(o(g, v, y), 1873313359, s(l, b + 32), 6), t(o(g, v, y), 4264355552, s(l, b + 60), 10), t(o(g, v, y), 2734768916, s(l, b + 24), 15), t(o(g, v, y), 1309151649, s(l, b + 52), 21), t(o(g, v, y), 4149444226, s(l, b + 16), 6), t(o(g, v, y), 3174756917, s(l, b + 44), 10), t(o(g, v, y), 718787259, s(l, b + 8), 15), t(o(g, v, y), 3951481745, s(l, b + 36), 21), c = p(c, h), m = p(m, g), d = p(d, v), _ = p(_, y) } return function(t, r, a, n) { for (var i = "", o = 0, s = 0, u = 3; u >= 0; u--) o = 255 & (s = arguments[u]), o <<= 8, o |= 255 & (s >>>= 8), o <<= 8, o |= 255 & (s >>>= 8), o <<= 8, i += e(o |= s >>>= 8); return i }(_, d, m, c).toUpperCase() }() }; var i = { log: function() {}, error: function() {}, count: function() {}, info: function() {} };
  35. (function() {
  36. function t() {}
  37. t.createFromElementId = function(e) { for (var r = document.getElementById(e), a = "", n = r.firstChild; n;) 3 === n.nodeType && (a += n.textContent), n = n.nextSibling; var i = new t; return i.type = r.type, i.source = a, i }, t.createFromSource = function(e, r) { var a = new t; return a.type = e, a.source = r, a } })(),
  38. function() {
  39. function t(t) { this.gl = t, this.program = this.gl.createProgram() }
  40. t.prototype = { attach: function(t) { this.gl.attachShader(this.program, t.shader) }, link: function() { this.gl.linkProgram(this.program) }, use: function() { this.gl.useProgram(this.program) }, getAttributeLocation: function(t) { return this.gl.getAttribLocation(this.program, t) }, setMatrixUniform: function(t, e) { var r = this.gl.getUniformLocation(this.program, t);
  41. this.gl.uniformMatrix4fv(r, !1, e) } } }(),
  42. function() { var t = null;
  43. function e(t, e, r) { this.gl = t, this.size = e, this.texture = t.createTexture(), t.bindTexture(t.TEXTURE_2D, this.texture), this.format = r || t.LUMINANCE, t.texImage2D(t.TEXTURE_2D, 0, this.format, e.w, e.h, 0, this.format, t.UNSIGNED_BYTE, null), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, t.NEAREST), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, t.NEAREST), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE) }
  44. e.prototype = { fill: function(t, e) { var r = this.gl;
  45. r.bindTexture(r.TEXTURE_2D, this.texture), e ? r.texSubImage2D(r.TEXTURE_2D, 0, 0, 0, this.size.w, this.size.h, this.format, r.UNSIGNED_BYTE, t) : r.texImage2D(r.TEXTURE_2D, 0, this.format, this.size.w, this.size.h, 0, this.format, r.UNSIGNED_BYTE, t) }, bind: function(e, r, a) { var n = this.gl;
  46. t || (t = [n.TEXTURE0, n.TEXTURE1, n.TEXTURE2]), n.activeTexture(t[e]), n.bindTexture(n.TEXTURE_2D, this.texture), n.uniform1i(n.getUniformLocation(r.program, a), e) } } }();
  47. function o() { var t = 0,
  48. e = 0,
  49. r = null;
  50. function a() { t = 360, e = 240, r = null, this._length = 0, this.head = null, this.tail = null, this.curIdx = 0 } return a.prototype = { push: function(t, a, n, i, o, s) { var u = new VideoBufferNode(t, a, n, i, o, s); return this._length > 0 ? (this.tail.next = u, u.previous = this.tail, this.tail = u) : (this.head = u, this.tail = u), this._length += 1, null !== r && this._length >= e && r(), u }, pop: function() { var t = null; return this._length > 1 && (t = this.head, this.head = this.head.next, null !== this.head ? this.head.previous = null : this.tail = null, this._length -= 1), t }, setMaxLength: function(e) {
  51. (t = e) > 360 ? t = 360 : t < 30 && (t = 30) }, setBUFFERING: function(t) {
  52. (e = t) > 240 ? e = 240 : e < 6 && (e = 6) }, setBufferFullCallback: function(t) { r = t }, searchTimestamp: function(t) { var e = this.head,
  53. r = this._length,
  54. a = 1; if (0 === r || t <= 0 || null === e) throw new Error("Failure: non-existent node in this list."); for (; null !== e && (e.timeStamp.timestamp !== t.timestamp || e.timeStamp.timestamp_usec !== t.timestamp_usec);) e = e.next, a++; return r < a ? e = null : this.curIdx = a, e }, findIFrame: function(t) { var e = this.head,
  55. r = this._length,
  56. a = 1; if (0 === r) throw new Error("Failure: non-existent node in this list."); for (; a < this.curIdx;) e = e.next, a++; if (!0 === t)
  57. for (;
  58. "I" !== e.frameType;) e = e.next, a++;
  59. else
  60. for (;
  61. "I" !== e.frameType;) e = e.previous, a--; return r < a ? e = null : this.curIdx = a, e } }, new a } var s = function() { var t, e, r, a, n, o, s, u, f, l = null,
  62. c = new Uint8Array,
  63. p = !1;
  64. function m() { l = Module._OpenDecoder(0, 0, 0), m.prototype.setIsFirstFrame(!1) } return m.prototype = { init: function() { i.log("H264 Decoder init") }, setOutputSize: function(t) { u != 1.5 * t && (u = 1.5 * t, f = Module._malloc(u), c = new Uint8Array(Module.HEAPU8.buffer, f, u)) }, decode: function(i, f) { if (t = Date.now(), e = new Uint8Array(i), c.set(e), r = Module._FrameAlloc(), Module._DecodeFrame(l, c.byteOffset, i.byteLength, u, r), a = Date.now() - t, o = Module._getYLength(r), n = Module._getHeight(r), !m.prototype.isFirstFrame()) return m.prototype.setIsFirstFrame(!0), { firstFrame: !0 }; if (o > 0 && n > 0) { t = Date.now(); var p = new Uint8Array(c); return s = { data: p, option: { yaddr: Module._getY(r), uaddr: Module._getU(r), vaddr: Module._getV(r), ylen: o, height: n, beforeDecoding: t }, width: o, height: n, codecType: "h264", decodingTime: a, frameType: f }, Module._FrameFree(r), s } }, setIsFirstFrame: function(t) { p = t }, isFirstFrame: function() { return p }, free: function() { Module._free(f), f = null } }, new m },
  65. u = new function() { var t = [],
  66. e = {};
  67. function r() { for (var r in t) t[r] = [r.charCodeAt(0), r.charCodeAt(1), r.charCodeAt(2), r.charCodeAt(3)];
  68. e.FTYP = new Uint8Array([105, 115, 111, 109, 0, 0, 0, 1, 105, 115, 111, 109, 97, 118, 99, 49]), e.STSD_PREFIX = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 1]), e.STTS = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0]), e.STSC = e.STCO = e.STTS, e.STSZ = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), e.HDLR_VIDEO = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 118, 105, 100, 101, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 86, 105, 100, 101, 111, 72, 97, 110, 100, 108, 101, 114, 0]), e.HDLR_AUDIO = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 115, 111, 117, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 83, 111, 117, 110, 100, 72, 97, 110, 100, 108, 101, 114, 0]), e.DREF = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 12, 117, 114, 108, 32, 0, 0, 0, 1]), e.SMHD = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0]), e.VMHD = new Uint8Array([0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]) }
  69. t = { avc1: [], avcC: [], btrt: [], dinf: [], dref: [], esds: [], ftyp: [], hdlr: [], mdat: [], mdhd: [], mdia: [], mfhd: [], minf: [], moof: [], moov: [], mp4a: [], mvex: [], mvhd: [], sdtp: [], stbl: [], stco: [], stsc: [], stsd: [], stsz: [], stts: [], tfdt: [], tfhd: [], traf: [], trak: [], trun: [], trex: [], tkhd: [], vmhd: [], smhd: [] }; var a = function(t) { for (var e = 8, r = Array.prototype.slice.call(arguments, 1), a = 0; a < r.length; a++) e += r[a].byteLength; var n = new Uint8Array(e),
  70. i = 0; for (n[i++] = e >>> 24 & 255, n[i++] = e >>> 16 & 255, n[i++] = e >>> 8 & 255, n[i++] = 255 & e, n.set(t, i), i += 4, a = 0; a < r.length; a++) n.set(r[a], i), i += r[a].byteLength; return n },
  71. n = function(e) { return a(t.mp4a, new Uint8Array([0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, (65280 & e.channelcount) >> 8, 255 & e.channelcount, (65280 & e.samplesize) >> 8, 255 & e.samplesize, 0, 0, 0, 0, (65280 & e.samplerate) >> 8, 255 & e.samplerate, 0, 0]), function(e) { var r = e.config,
  72. n = r.length,
  73. i = new Uint8Array([0, 0, 0, 0, 3, 23 + n, 0, 1, 0, 4, 15 + n, 64, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5].concat([n]).concat(r).concat([6, 1, 2])); return a(t.esds, i) }(e)) },
  74. o = function(r) { return "audio" === r.type ? a(t.stsd, e.STSD_PREFIX, n(r)) : a(t.stsd, e.STSD_PREFIX, function(e) { var r = e.sps || [],
  75. n = e.pps || [],
  76. i = [],
  77. o = [],
  78. s = 0; for (s = 0; s < r.length; s++) i.push((65280 & r[s].byteLength) >>> 8), i.push(255 & r[s].byteLength), i = i.concat(Array.prototype.slice.call(r[s])); for (s = 0; s < n.length; s++) o.push((65280 & n[s].byteLength) >>> 8), o.push(255 & n[s].byteLength), o = o.concat(Array.prototype.slice.call(n[s])); return a(t.avc1, new Uint8Array([0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (65280 & e.width) >> 8, 255 & e.width, (65280 & e.height) >> 8, 255 & e.height, 0, 72, 0, 0, 0, 72, 0, 0, 0, 0, 0, 0, 0, 1, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 17, 17]), a(t.avcC, new Uint8Array([1, e.profileIdc, e.profileCompatibility, e.levelIdc, 255].concat([r.length]).concat(i).concat([n.length]).concat(o)))) }(r)) },
  79. s = function(r) { var n = null; return n = "audio" === r.type ? a(t.smhd, e.SMHD) : a(t.vmhd, e.VMHD), a(t.minf, n, a(t.dinf, a(t.dref, e.DREF)), function(r) { return a(t.stbl, o(r), a(t.stts, e.STTS), a(t.stsc, e.STSC), a(t.stsz, e.STSZ), a(t.stco, e.STCO)) }(r)) },
  80. u = function(r) { return a(t.mdia, function(e) { var r = e.timescale,
  81. n = e.duration; return a(t.mdhd, new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, r >>> 24 & 255, r >>> 16 & 255, r >>> 8 & 255, 255 & r, n >>> 24 & 255, n >>> 16 & 255, n >>> 8 & 255, 255 & n, 85, 196, 0, 0])) }(r), function(r) { var n = null; return n = "audio" === r.type ? e.HDLR_AUDIO : e.HDLR_VIDEO, a(t.hdlr, n) }(r), s(r)) },
  82. f = function(e) { return a(t.trak, function(e) { var r = e.id,
  83. n = e.duration,
  84. i = e.width,
  85. o = e.height; return a(t.tkhd, new Uint8Array([0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, r >>> 24 & 255, r >>> 16 & 255, r >>> 8 & 255, 255 & r, 0, 0, 0, 0, n >>> 24 & 255, n >>> 16 & 255, n >>> 8 & 255, 255 & n, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, i >>> 8 & 255, 255 & i, 0, 0, o >>> 8 & 255, 255 & o, 0, 0])) }(e), u(e)) },
  86. l = function(e) { return a(t.mvex, function(e) { var r = e.id,
  87. n = new Uint8Array([0, 0, 0, 0, r >>> 24 & 255, r >>> 16 & 255, r >>> 8 & 255, 255 & r, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1]); return a(t.trex, n) }(e)) },
  88. c = function(e) { var r, n, o = (r = e.timescale, n = e.duration, i.log("mvhd: timescale: " + r + " duration: " + n), a(t.mvhd, new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, r >>> 24 & 255, r >>> 16 & 255, r >>> 8 & 255, 255 & r, n >>> 24 & 255, n >>> 16 & 255, n >>> 8 & 255, 255 & n, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255]))),
  89. s = f(e),
  90. u = l(e); return a(t.moov, o, s, u) },
  91. p = function(e, r) { return "audio" === e.type ? audioTrun(e, r) : function(e, r) { var n, i = null,
  92. o = null,
  93. s = 0,
  94. u = r; if (null === (n = e.samples || [])[0].frameDuration)
  95. for (u += 24 + 4 * n.length, i = trunHeader(n, u), s = 0; s < n.length; s++) o = n[s], i = i.concat([(4278190080 & o.size) >>> 24, (16711680 & o.size) >>> 16, (65280 & o.size) >>> 8, 255 & o.size]);
  96. else
  97. for (i = function(t, e) { return [0, 0, 3, 5, (4278190080 & t.length) >>> 24, (16711680 & t.length) >>> 16, (65280 & t.length) >>> 8, 255 & t.length, (4278190080 & e) >>> 24, (16711680 & e) >>> 16, (65280 & e) >>> 8, 255 & e, 0, 0, 0, 0] }(n, u += 24 + 4 * n.length + 4 * n.length), s = 0; s < n.length; s++) o = n[s], i = i.concat([(4278190080 & o.frameDuration) >>> 24, (16711680 & o.frameDuration) >>> 16, (65280 & o.frameDuration) >>> 8, 255 & o.frameDuration, (4278190080 & o.size) >>> 24, (16711680 & o.size) >>> 16, (65280 & o.size) >>> 8, 255 & o.size]); return a(t.trun, new Uint8Array(i)) }(e, r) },
  98. m = function(e, r) { return a(t.moof, function(e) { var r = new Uint8Array([0, 0, 0, 0, e >>> 24 & 255, e >>> 16 & 255, e >>> 8 & 255, 255 & e]); return a(t.mfhd, r) }(e), function(e) { var r, n, i; return r = a(t.tfhd, new Uint8Array([0, 2, 0, 0, 0, 0, 0, 1])), n = a(t.tfdt, new Uint8Array([0, 0, 0, 0, e.baseMediaDecodeTime >>> 24 & 255, e.baseMediaDecodeTime >>> 16 & 255, e.baseMediaDecodeTime >>> 8 & 255, 255 & e.baseMediaDecodeTime])), i = p(e, 72), a(t.traf, r, n, i) }(r)) }; return r.prototype = { initSegment: function(r) { var n = a(t.ftyp, e.FTYP);
  99. i.log(r); var o = c(r),
  100. s = new Uint8Array(n.byteLength + o.byteLength); return s.set(n, 0), s.set(o, n.byteLength), s }, mediaSegment: function(e, r, n, i) { var o = m(e, r),
  101. s = function(e) { return a(t.mdat, e) }(n),
  102. u = null; return (u = new Uint8Array(o.byteLength + s.byteLength)).set(o), u.set(s, o.byteLength), u } }, new r },
  103. f = function() { this.map = {} };
  104. f.prototype = { put: function(t, e) { this.map[t] = e }, get: function(t) { return this.map[t] }, containsKey: function(t) { return t in this.map }, containsValue: function(t) { for (var e in this.map)
  105. if (this.map[e] === t) return !0;
  106. return !1 }, isEmpty: function(t) { return 0 === this.size() }, clear: function() { for (var t in this.map) delete this.map[t] }, remove: function(t) { delete this.map[t] }, keys: function() { var t = new Array; for (var e in this.map) t.push(e); return t }, values: function() { var t = new Array; for (var e in this.map) t.push(this.map[e]); return t }, size: function() { var t = 0; for (var e in this.map) t++; return t } }; var l = f;
  107. function c() { var t = 7,
  108. e = 7,
  109. r = 2,
  110. a = 3,
  111. n = 4,
  112. i = 5,
  113. o = 8,
  114. s = 16,
  115. u = 32,
  116. f = 255,
  117. c = 0,
  118. p = null;
  119. function m() { c = 0, p = new l }
  120. function d(r, n) { var i = n,
  121. o = c + i >> a; return i = c + n & t, r[o] >> e - (i & e) & 1 }
  122. function _(t, e) { var r = c >> a,
  123. n = 8 * (r + 1) - c; if (n < 8)
  124. for (var i = 0; i < 3; i++) { var o = t[r + i];
  125. o = 0 == i ? o >> n << n : 2 == i ? o & 255 >> 8 - n | 1 << n : 0, t.set([o], r + i) } else t.set([0], r), t.set([1], r + 1) }
  126. function h(t, e) { var r = 0; if (1 === e) r = d(t, 0);
  127. else
  128. for (var a = 0; a < e; a++) r = (r << 1) + d(t, a); return c += e, r }
  129. function g(t, e) { for (var a = 0, n = 0, i = e; c + i < 8 * t.length && !d(t, i++);) a++; if (0 === a) return c += 1, 0;
  130. n = 1 << a; for (var o = a - 1; o >= 0; o--, i++) n |= d(t, i) << o; return c += a * r + 1, n - 1 }
  131. function v(t, e) { var a = g(t, e); return 1 & a ? (a + 1) / r : -a / r }
  132. function y(t) { p.put("cpb_cnt_minus1", g(t, 0)), p.put("bit_rate_scale", h(t, n)), p.put("cpb_size_scale", h(t, n)); for (var e = p.get("cpb_cnt_minus1"), r = new Array(e), a = new Array(e), o = new Array(e), s = 0; s <= e; s++) r[s] = g(t, 0), a[s] = g(t, 0), o[s] = h(t, 1);
  133. p.put("bit_rate_value_minus1", r), p.put("cpb_size_value_minus1", a), p.put("cbr_flag", o), p.put("initial_cpb_removal_delay_length_minus1", h(t, i)), p.put("cpb_removal_delay_length_minus1", h(t, i)), p.put("dpb_output_delay_length_minus1", h(t, i)), p.put("time_offset_length", h(t, i)) } return m.prototype = { parse: function(t) { c = 0, p.clear(), p.put("forbidden_zero_bit", h(t, 1)), p.put("nal_ref_idc", h(t, r)), p.put("nal_unit_type", h(t, i)), p.put("profile_idc", h(t, o)), p.put("profile_compatibility", h(t, o)), p.put("level_idc", h(t, o)), p.put("seq_parameter_set_id", g(t, 0)); var e = p.get("profile_idc"); if ((100 === e || 110 === e || 122 === e || 244 === e || 44 === e || 83 === e || 86 === e || 118 === e || 128 === e || 138 === e || 139 === e || 134 === e) && (p.put("chroma_format_idc", g(t, 0)), p.get("chroma_format_idc") === a && p.put("separate_colour_plane_flag", h(t, 1)), p.put("bit_depth_luma_minus8", g(t, 0)), p.put("bit_depth_chroma_minus8", g(t, 0)), p.put("qpprime_y_zero_transform_bypass_flag", h(t, 1)), p.put("seq_scaling_matrix_present_flag", h(t, 1)), p.get("seq_scaling_matrix_present_flag"))) { for (var n = p.get("chroma_format_idc") !== a ? o : 12, l = new Array(n), m = 0; m < n; m++)
  134. if (l[m] = h(t, 1), l[m])
  135. for (var d = m < 6 ? s : 64, b = 8, D = 8, T = 0; T < d; T++) D && (D = (b + v(t, 0) + 256) % 256), b = 0 === D ? b : D;
  136. p.put("seq_scaling_list_present_flag", l) } if (p.put("log2_max_frame_num_minus4", g(t, 0)), p.put("pic_order_cnt_type", g(t, 0)), 0 === p.get("pic_order_cnt_type")) p.put("log2_max_pic_order_cnt_lsb_minus4", g(t, 0));
  137. else if (1 === p.get("pic_order_cnt_type")) { p.put("delta_pic_order_always_zero_flag", h(t, 1)), p.put("offset_for_non_ref_pic", v(t, 0)), p.put("offset_for_top_to_bottom_field", v(t, 0)), p.put("num_ref_frames_in_pic_order_cnt_cycle", g(t, 0)); for (var S = 0; S < p.get("num_ref_frames_in_pic_order_cnt_cycle"); S++) p.put("num_ref_frames_in_pic_order_cnt_cycle", v(t, 0)) } return p.put("num_ref_frames", g(t, 0)), p.put("gaps_in_frame_num_value_allowed_flag", h(t, 1)), p.put("pic_width_in_mbs_minus1", g(t, 0)), p.put("pic_height_in_map_units_minus1", g(t, 0)), p.put("frame_mbs_only_flag", h(t, 1)), 0 === p.get("frame_mbs_only_flag") && p.put("mb_adaptive_frame_field_flag", h(t, 1)), p.put("direct_8x8_interence_flag", h(t, 1)), p.put("frame_cropping_flag", h(t, 1)), 1 === p.get("frame_cropping_flag") && (p.put("frame_cropping_rect_left_offset", g(t, 0)), p.put("frame_cropping_rect_right_offset", g(t, 0)), p.put("frame_cropping_rect_top_offset", g(t, 0)), p.put("frame_cropping_rect_bottom_offset", g(t, 0))), p.put("vui_parameters_present_flag", h(t, 1)), p.get("vui_parameters_present_flag") && function(t) { p.put("aspect_ratio_info_present_flag", h(t, 1)), p.get("aspect_ratio_info_present_flag") && (p.put("aspect_ratio_idc", h(t, o)), p.get("aspect_ratio_idc") === f && (_(t), p.put("sar_width", h(t, s)), _(t), p.put("sar_height", h(t, s)))), p.put("overscan_info_present_flag", h(t, 1)), p.get("overscan_info_present_flag") && p.put("overscan_appropriate_flag", h(t, 1)), p.put("video_signal_type_present_flag", h(t, 1)), p.get("video_signal_type_present_flag") && (p.put("video_format", h(t, a)), p.put("video_full_range_flag", h(t, 1)), p.put("colour_description_present_flag", h(t, 1)), p.get("colour_description_present_flag") && (p.put("colour_primaries", h(t, o)), p.put("transfer_characteristics", h(t, o)), p.put("matrix_coefficients", h(t, o)))), p.put("chroma_loc_info_present_flag", h(t, 1)), p.get("chroma_loc_info_present_flag") && (p.put("chroma_sample_loc_type_top_field", g(t, 0)), p.put("chroma_sample_loc_type_bottom_field", g(t, 0))), p.put("timing_info_present_flag", h(t, 1)), p.get("timing_info_present_flag") && (p.put("num_units_in_tick", h(t, u)), p.put("time_scale", h(t, u)), p.put("fixed_frame_rate_flag", h(t, 1))), p.put("nal_hrd_parameters_present_flag", h(t, 1)), p.get("nal_hrd_parameters_present_flag") && y(t), p.put("vcl_hrd_parameters_present_flag", h(t, 1)), p.get("vcl_hrd_parameters_present_flag") && y(t), (p.get("nal_hrd_parameters_present_flag") || p.get("vcl_hrd_parameters_present_flag")) && p.put("low_delay_hrd_flag", h(t, 1)), p.put("pic_struct_present_flag", h(t, 1)), p.put("bitstream_restriction_flag", h(t, 1)), p.get("bitstream_restriction_flag") && (p.put("motion_vectors_over_pic_boundaries_flag", h(t, 1)), p.put("max_bytes_per_pic_denom", g(t, 0)), p.put("max_bits_per_mb_denom", g(t, 0))) }(t), !0 }, getSizeInfo: function() { var t = 0,
  138. e = 0;
  139. 0 === p.get("chroma_format_idc") ? t = e = 0 : 1 === p.get("chroma_format_idc") ? t = e = r : p.get("chroma_format_idc") === r ? (t = r, e = 1) : p.get("chroma_format_idc") === a && (0 === p.get("separate_colour_plane_flag") ? t = e = 1 : 1 === p.get("separate_colour_plane_flag") && (t = e = 0)); var n = p.get("pic_width_in_mbs_minus1") + 1,
  140. i = p.get("pic_height_in_map_units_minus1") + 1,
  141. o = (r - p.get("frame_mbs_only_flag")) * i,
  142. u = 0,
  143. f = 0,
  144. l = 0,
  145. c = 0;
  146. 1 === p.get("frame_cropping_flag") && (u = p.get("frame_cropping_rect_left_offset"), f = p.get("frame_cropping_rect_right_offset"), l = p.get("frame_cropping_rect_top_offset"), c = p.get("frame_cropping_rect_bottom_offset")); var m = n * s * (o * s); return { width: n * s - t * (u + f), height: o * s - e * (r - p.get("frame_mbs_only_flag")) * (l + c), decodeSize: m } }, getSpsValue: function(t) { return p.get(t) }, getCodecInfo: function() { return p.get("profile_idc").toString(s) + (p.get("profile_compatibility") < 15 ? "0" + p.get("profile_compatibility").toString(s) : p.get("profile_compatibility").toString(s)) + p.get("level_idc").toString(s) } }, new m } var p = function() { var t = 0,
  147. e = 0,
  148. r = !1,
  149. a = (new Uint8Array(1048576), new Uint8Array(["0x00", "0x00", "0x00", "0x01"]), new c),
  150. n = 0,
  151. f = null,
  152. l = null,
  153. p = 0,
  154. m = !1,
  155. d = 0,
  156. _ = { frameData: null, timeStamp: null, initSegmentData: null, mediaSample: null, dropPercent: 0, dropCount: 0, codecInfo: "", playback: !1 },
  157. h = { timestamp: null, timezone: null },
  158. g = {},
  159. v = null,
  160. y = null,
  161. b = !1,
  162. D = !1,
  163. T = 0,
  164. S = 0,
  165. w = 0,
  166. C = 0,
  167. I = !1,
  168. F = 0,
  169. A = null,
  170. M = null,
  171. k = "",
  172. x = null,
  173. L = 0,
  174. R = 0,
  175. U = { width: 0, height: 0 },
  176. B = null,
  177. E = !1;
  178. function P(t) { t !== k && ("video" === t ? k = "video" : (k = "canvas", m = !0, d = 0, _.frameData.firstFrame = !0)) }
  179. function O(t, e, r) { var a = ""; return t * e > 921600 && !1 === r ? (a = "video", E && L > 0 && L <= 3 && (a = "canvas")) : a = "canvas", a }
  180. function z() { this.decoder = new s, this.firstDiffTime = 0, this.firstTime = 0, this.lastMSW = 0 } return z.prototype = { setReturnCallback: function(t) { this.rtpReturnCallback = t }, setBufferfullCallback: function(t) { null !== this.videoBufferList && this.videoBufferList.setBufferFullCallback(t) }, getVideoBuffer: function(t) { if (null !== this.videoBufferList) return this.videoBufferList.searchNodeAt(t) }, clearBuffer: function() { null !== this.videoBufferList && this.videoBufferList.clear() }, findCurrent: function() { null !== this.videoBufferList && this.videoBufferList.searchTimestamp(this.getTimeStamp()) }, setTimeStamp: function(t) { this.timeData = t }, getTimeStamp: function() { return this.timeData }, ntohl: function(t) { return (t[0] << 24) + (t[1] << 16) + (t[2] << 8) + t[3] >>> 0 }, appendBuffer: function(t, e, r) { if (r + e.length >= t.length) { var a = new Uint8Array(t.length + 1048576);
  181. a.set(t, 0), t = a } return t.set(e, r), t }, getFramerate: function() { return L }, setGovLength: function(t) { x = t }, getGovLength: function() { return x }, setDecodingTime: function(t) { this.decodingTime = t }, getDropPercent: function() { return 0 }, getDropCount: function() { return 0 }, initStartTime: function() { this.firstDiffTime = 0, this.calcGov = 0 }, setCheckDelay: function(t) { this.checkDelay = t }, init: function(t) { b = !1, r = !1, k = t, this.decoder.setIsFirstFrame(!1), this.videoBufferList = new o, this.firstDiffTime = 0, this.checkDelay = !0, this.timeData = null }, setFramerate: function(t) { 0 < t && "undefined" !== typeof t && (L = t, null !== this.videoBufferList && (this.videoBufferList.setMaxLength(6 * L), this.videoBufferList.setBUFFERING(4 * L))) }, parseRTPData: function(o, s, c, x, L) { var E = null,
  182. z = {},
  183. j = (s[19] << 24) + (s[18] << 16) + (s[17] << 8) + s[16] >>> 0,
  184. N = Date.UTC("20" + (j >>> 26), (j >>> 22 & 15) - 1, j >>> 17 & 31, j >>> 12 & 31, j >>> 6 & 63, 63 & j) / 1e3; if (L.timeStampmsw, N += (new Date).getTimezoneOffset() / 60 * 3600, k || 253 !== s[4] || (B = 0 !== s[5], k = O(L.width, L.height, B)), "" !== k) { if (0 == this.firstTime) this.firstTime = N, this.lastMSW = 0, M = (s[21] << 8) + s[20], h = { timestamp: this.firstTime, timestamp_usec: 0 };
  185. else { var G, W = (s[21] << 8) + s[20];
  186. G = W > M ? W - M : W + 65535 - M, this.lastMSW += G, N > this.firstTime && (this.lastMSW -= 1e3), this.firstTime = N, h = { timestamp: N, timestamp_usec: this.lastMSW }, M = W }
  187. 0 !== this.getFramerate() && "undefined" !== typeof this.getFramerate() || "undefined" === typeof this.getTimeStamp() || (this.setFramerate(Math.round(1e3 / ((h.timestamp - this.getTimeStamp().timestamp === 0 ? 0 : 1e3) + (h.timestamp_usec - this.getTimeStamp().timestamp_usec)))), i.log("setFramerate" + Math.round(1e3 / ((h.timestamp - this.getTimeStamp().timestamp === 0 ? 0 : 1e3) + (h.timestamp_usec - this.getTimeStamp().timestamp_usec))))), this.setTimeStamp(h); for (var V = s[22], H = s.subarray(24 + V, s.length - 8), X = s.subarray(s.length - 8, s.length), Y = (X[7], X[6], X[5], X[4], []), q = 0; q <= H.length;)
  188. if (0 == H[q])
  189. if (0 == H[q + 1])
  190. if (1 == H[q + 2]) { if (Y.push(q), 5 == (31 & H[q += 3]) || 1 == (31 & H[q])) break } else 0 == H[q + 2] ? q++ : q += 3;
  191. else q += 2;
  192. else q += 1; var J = "P";
  193. t = (s[21] << 8) + s[20]; var Z = 0; for (q = 0; q < Y.length; q++) switch (E = H.subarray(Y[q] + 3, Y[q + 1]), 31 & H[Y[q] + 3]) { default: break;
  194. case 1:
  195. J = "P", Z = Y[q] - 1; break;
  196. case 5:
  197. J = "I", Z = Y[q] - 1; break;
  198. case 28:
  199. break;
  200. case 7:
  201. a.parse(E); var K = L;n = a.getSizeInfo().decodeSize, null !== f && null !== l && f.width === K.width && f.height === K.height && l === a.getCodecInfo() || (b = !1, f = K, l = a.getCodecInfo(), this.decoder.setIsFirstFrame(!1)), w = T = K.width, C = S = K.height, v = E, U.width == K.width && U.height == K.height || (0 != U.width ? (U.width = K.width, U.height = K.height, z.resolution = U, z.resolution.decodeMode = O(U.width, U.height, B), z.resolution.encodeMode = "h264") : (U.width = K.width, U.height = K.height, z.decodeStart = U, z.decodeStart.decodeMode = k, z.decodeStart.encodeMode = "h264")); break;
  202. case 8:
  203. y = E; break;
  204. case 6:
  205. case 9:
  206. }
  207. if (c && !1 === m && (z.backupData = { stream: new Uint8Array(H), frameType: J, width: w, height: C, codecType: "h264" }, null !== h.timestamp && "undefined" !== typeof h.timestamp ? z.backupData.timestamp_usec = h.timestamp_usec : z.backupData.timestamp = (t / 90).toFixed(0)), "canvas" === k) { var Q = 1e3 * h.timestamp + h.timestamp_usec; if (0 == this.firstDiffTime ? (p = 0, this.firstDiffTime = Date.now() - Q, i.log("firstDiff: " + R)) : (Q - A < 0 && (this.firstDiffTime = p + (Date.now() - Q).toFixed(0)), (p = Date.now() - Q - this.firstDiffTime) < 0 && (this.firstDiffTime = 0, p = 0), p > 8e3 && (z.error = { errorCode: 101 }, this.rtpReturnCallback(z))), A = Q, e !== n && (this.decoder.free(), e = n, this.decoder.setOutputSize(e)), !0 === m && "P" === J) return;!0 === m && (m = !1), "I" === J && d < 2 && d++, _.frameData = null, !0 === c && !0 === r || (_.frameData = this.decoder.decode(H)), _.timeStamp = null, h = null === h.timestamp ? this.getTimeStamp() : h, _.timeStamp = h } else { var $ = null; if (b ? _.initSegmentData = null : (b = !0, L = { id: 1, width: T, height: S, type: "video", profileIdc: a.getSpsValue("profile_idc"), profileCompatibility: 0, levelIdc: a.getSpsValue("level_idc"), sps: [v], pps: [y], timescale: 1e3, fps: this.getFramerate() }, i.log(JSON.stringify(L)), _.initSegmentData = u.initSegment(L), _.codecInfo = a.getCodecInfo()), Z || i.log("11111111111111111111111111111111111111111"), "I" === J) { var tt = Z;
  208. $ = H.subarray(tt, H.length) } else $ = H.subarray(Z, H.length); var et = $.length - 4;
  209. $[0] = (4278190080 & et) >>> 24, $[1] = (16711680 & et) >>> 16, $[2] = (65280 & et) >>> 8, $[3] = 255 & et; var rt = this.getFramerate(),
  210. at = { duration: Math.round(1 / rt * 1e3), size: $.length, frame_time_stamp: null, frameDuration: null }; if (r) at.frame_time_stamp = t, _.frameData = new Uint8Array($), _.mediaSample = at;
  211. else { if (!1 === c) { if (at.frame_time_stamp = 1e3 * h.timestamp + h.timestamp_usec - R, !1 === D) at.frame_time_stamp = 0, R = 1e3 * h.timestamp + h.timestamp_usec, at.frameDuration = 0, g = at, D = !0;
  212. else { var nt = g.frame_time_stamp,
  213. it = at.frame_time_stamp;
  214. at.frameDuration = Math.abs(it - nt), at.frameDuration > 3e3 && (at.frameDuration = 0), g = at }
  215. _.frameData = new Uint8Array($), _.mediaSample = at }
  216. h = null === h.timestamp ? this.getTimeStamp() : h, _.timeStamp = h } } var ot = w * C; if (!0 === r && (NaN.toFixed(0), ot > 786432 ? (P("video"), z.decodeMode = "video") : (P("canvas"), z.decodeMode = "canvas")), _.playback = r, _.frameData.frameIndex = L.frameIndex, z.decodedData = _, !0 === I) return "I" === J && F++, 2 === F && (F = 0, I = !1), void i.info("H264Session::stop");
  217. this.rtpReturnCallback(z) } }, findIFrame: function() { if (null !== this.videoBufferList) { var t = this.videoBufferList.findIFrame(); if (null === t || "undefined" === typeof t) return !1; var e = {}; return this.setTimeStamp(t.timeStamp), e.frameData = this.decoder.decode(t.buffer), e.timeStamp = t.timeStamp, e } }, setInitSegment: function() { b = !1, f = null, l = null }, setLessRate: function(t) { E = t } }, new z }; var m = function() { var t, e, r, a, n, o, s, u, f, l = null,
  218. c = new Uint8Array,
  219. p = !1;
  220. function m() { l = Module._OpenDecoder(1, 0, 0), m.prototype.setIsFirstFrame(!1) } return m.prototype = { init: function() { i.log("H265 Decoder init") }, setOutputSize: function(t) { u != 1.5 * t && (u = 1.5 * t, f = Module._malloc(u), c = new Uint8Array(Module.HEAPU8.buffer, f, u)) }, decode: function(i, f) { if (t = Date.now(), e = new Uint8Array(i), c.set(e), r = Module._FrameAlloc(), Module._DecodeFrame(l, c.byteOffset, i.byteLength, u, r), a = Date.now() - t, o = Module._getYLength(r), n = Module._getHeight(r), !m.prototype.isFirstFrame()) return m.prototype.setIsFirstFrame(!0), { firstFrame: !0 }; if (o > 0 && n > 0) { t = Date.now(); var p = new Uint8Array(c); return s = { data: p, option: { yaddr: Module._getY(r), uaddr: Module._getU(r), vaddr: Module._getV(r), ylen: o, height: n, beforeDecoding: t }, width: o, height: n, codecType: "h265", decodingTime: a, frameType: f }, Module._FrameFree(r), s } }, setIsFirstFrame: function(t) { p = t }, isFirstFrame: function() { return p }, free: function() { Module._free(f), f = null } }, new m };
  221. function d() { var t = null,
  222. e = null,
  223. r = 0,
  224. a = 0,
  225. n = 0,
  226. i = 0,
  227. o = 0;
  228. function s() { 0, t = new l }
  229. function u() { return 0 == n && (i = function() { if (a >= r) return 0; var t = e[a++]; return 0 == t ? (o++, a < r && 2 == o && 3 == e[a] && (a++, o = 0)) : o = 0, t }(), n = 8), i >> --n & 1 }
  230. function f(t, e) { for (var r = 0; e > 0;) r <<= 1, r |= u(), e--; return r }
  231. function c(t, e) { for (var n = 0; a < r && 0 == u();) n++; return f(0, n) + ((1 << n) - 1) } return s.prototype = { parse: function(e) { e, 0, t.clear(), t.put("forbidden_zero_bit", f(0, 1)), t.put("nal_unit_type", f(0, 6)), t.put("nuh_layer_id", f(0, 6)), t.put("nuh_temporal_id_plus1", f(0, 3)), t.put("sps_video_parameter_set_id", f(0, 4)), 0 === t.get("nuh_layer_id") ? t.put("sps_max_sub_layers_minus1", f(0, 3)) : t.put("sps_ext_or_max_sub_layers_minus1", f(0, 3)); var r = 0 !== t.get("nuh_layer_id") && 7 === t.get("sps_ext_or_max_sub_layers_minus1"); return r || (t.put("sps_max_sub_layers_minus1", f(0, 1)), function(e, r) { if (e) { t.put("general_profile_space", f(0, 2)), t.put("general_tier_flag", f(0, 1)), t.put("general_profile_idc", f(0, 5)); for (var a = new Array(32), n = 0; n < 32; n++) a[n] = f(0, 1);
  232. t.put("general_progressive_source_flag", f(0, 1)), t.put("general_interlaced_source_flag", f(0, 1)), t.put("general_non_packed_constraint_flag", f(0, 1)), t.put("general_frame_only_constraint_flag", f(0, 1)); var i = t.get("general_profile_idc");
  233. 4 === i || a[4] || 5 === i || a[5] || 6 === i || a[6] || 7 === i || a[7] || 8 === i || a[8] || 9 === i || a[9] || 10 === i || a[10] ? (t.put("general_max_12bit_constraint_flag", f(0, 1)), t.put("general_max_10bit_constraint_flag", f(0, 1)), t.put("general_max_8bit_constraint_flag", f(0, 1)), t.put("general_max_422chroma_constraint_flag", f(0, 1)), t.put("general_max_420chroma_constraint_flag", f(0, 1)), t.put("general_max_monochrome_constraint_flag", f(0, 1)), t.put("general_intra_constraint_flag", f(0, 1)), t.put("general_one_picture_only_constraint_flag", f(0, 1)), t.put("general_lower_bit_rate_constraint_flag", f(0, 1)), 5 === i || a[5] || 9 === i || a[9] || 10 === i || a[10] ? (t.put("general_max_14bit_constraint_flag", f(0, 1)), t.put("general_reserved_zero_33bits", f(0, 33))) : t.put("general_reserved_zero_34bits", f(0, 34))) : t.put("general_reserved_zero_43bits", f(0, 43)), i >= 1 && i <= 5 || a[1] || a[2] || a[3] || a[4] || a[5] || a[9] ? t.put("general_inbld_flag", f(0, 1)) : t.put("general_reserved_zero_bit", f(0, 1)) }
  234. t.put("general_level_idc", f(0, 8)); var o = new Array(r),
  235. s = new Array(r); for (_ = 0; _ < r; _++) o[_] = f(0, 1), s[_] = f(0, 1); var u = new Array(8),
  236. l = new Array(r),
  237. c = new Array(r),
  238. p = new Array(r),
  239. m = [],
  240. d = new Array(r); if (r > 0)
  241. for (var _ = r; _ < 8; _++) u[_] = f(0, 2); for (_ = 0; _ < r; _++) { if (o[_]) { for (c[_] = f(0, 2), p[_] = f(0, 1), l[_] = f(0, 5), n = 0; n < 32; n++) m[_][n] = f(0, 1);
  242. t.put("sub_layer_progressive_source_flag", f(0, 1)), t.put("sub_layer_interlaced_source_flag", f(0, 1)), t.put("sub_layer_non_packed_constraint_flag", f(0, 1)), t.put("sub_layer_frame_only_constraint_flag", f(0, 1)), 4 === l[_] || m[_][4] || 5 === l[_] || m[_][5] || 6 === l[_] || m[_][6] || 7 === l[_] || m[_][7] || 8 === l[_] || m[_][8] || 9 === l[_] || m[_][9] || 10 === l[_] || m[_][10] ? (t.put("sub_layer_max_12bit_constraint_flag", f(0, 1)), t.put("sub_layer_max_10bit_constraint_flag", f(0, 1)), t.put("sub_layer_max_8bit_constraint_flag", f(0, 1)), t.put("sub_layer_max_422chroma_constraint_flag", f(0, 1)), t.put("sub_layer_max_420chroma_constraint_flag", f(0, 1)), t.put("sub_layer_max_monochrome_constraint_flag", f(0, 1)), t.put("sub_layer_intra_constraint_flag", f(0, 1)), t.put("sub_layer_one_picture_only_constraint_flag", f(0, 1)), t.put("sub_layer_lower_bit_rate_constraint_flag", f(0, 1)), 5 === l[_] || m[_][5] ? (t.put("sub_layer_max_14bit_constraint_flag", f(0, 1)), t.put("sub_layer_lower_bit_rate_constraint_flag", f(0, 1)), d[_] = f(0, 33)) : d[_] = f(0, 34)) : t.put("sub_layer_reserved_zero_43bits", f(0, 43)), l[_] >= 1 && l[_] <= 5 || 9 == l[_] || m[1] || m[2] || m[3] || m[4] || m[5] || m[9] ? t.put("sub_layer_inbld_flag", f(0, 1)) : t.put("sub_layer_reserved_zero_bit", f(0, 1)) }
  243. s[_] && t.put("sub_layer_level_idc", f(0, 8)) } }(1, t.get("sps_max_sub_layers_minus1"))), f(0, 84), t.put("sps_seq_parameter_set_id", c()), r ? (t.put("update_rep_format_flag", f(0, 1)), t.get("update_rep_format_flag") && t.put("sps_rep_format_idx", f(0, 8))) : (t.put("chroma_format_idc", c()), 3 === t.get("chroma_format_idc") && t.put("separate_colour_plane_flag", f(0, 1)), t.put("pic_width_in_luma_samples", c()), t.put("pic_height_in_luma_samples", c()), t.put("conformance_window_flag", f(0, 1)), t.get("conformance_window_flag") && (t.put("conf_win_left_offset", c()), t.put("conf_win_right_offset", c()), t.put("conf_win_top_offset", c()), t.put("conf_win_bottom_offset", c()))), !0 }, parse2: function(s) { var u = s.length; if (s, e = s, r = s.length, a = 0, n = 0, i = 0, o = 0, 0, t.clear(), u < 20) return !1;
  244. f(0, 16), f(0, 4); var l = f(0, 3); if (t.put("sps_max_sub_layers_minus1", l), l > 6) return !1;
  245. f(0, 1), f(0, 2), f(0, 1);
  246. f(0, 5);
  247. f(0, 32), f(0, 1), f(0, 1), f(0, 1), f(0, 1), f(0, 43), f(0, 1), t.put("general_level_idc", f(0, 8)); for (var p = [], m = [], d = 0; d < l; d++) p[d] = f(0, 1), m[d] = f(0, 1); if (l > 0)
  248. for (d = l; d < 8; d++) f(0, 2); for (d = 0; d < l; d++) p[d] && (f(0, 2), f(0, 1), f(0, 5), f(0, 32), f(0, 1), f(0, 1), f(0, 1), f(0, 1), f(0, 44)), m[d] && f(0, 8); var _ = c(); if (t.put("sps_seq_parameter_set_id", _), _ > 15) return !1; var h = c(); return t.put("chroma_format_idc", h), !(_ > 3) && (3 == h && f(0, 1), t.put("pic_width_in_luma_samples", c()), t.put("pic_height_in_luma_samples", c()), f(0, 1) && (c(), c(), c(), c()), c() == c()) }, getSizeInfo: function() { var e = t.get("pic_width_in_luma_samples"),
  249. r = t.get("pic_height_in_luma_samples"); if (t.get("conformance_window_flag")) { var a = t.get("chroma_format_idc"),
  250. n = t.get("separate_colour_plane_flag"); "undefined" === typeof n && (n = 0); var i = 1 !== a && 2 !== a || 0 !== n ? 1 : 2,
  251. o = 1 === a && 0 === n ? 2 : 1;
  252. e -= i * t.get("conf_win_right_offset") + i * t.get("conf_win_left_offset"), r -= o * t.get("conf_win_bottom_offset") + o * t.get("conf_win_top_offset") } return { width: e, height: r, decodeSize: e * r } }, getSpsValue: function(e) { return t.get(e) } }, new s } var _ = function() { var t, e = 0,
  253. r = 0,
  254. a = 0,
  255. n = 0,
  256. s = new d,
  257. u = { frameData: null, timeStamp: null },
  258. f = { timestamp: null, timezone: null },
  259. l = 0,
  260. c = 0,
  261. p = null,
  262. _ = 0,
  263. h = { width: 0, height: 0 },
  264. g = 0,
  265. v = 0;
  266. function y() { this.decoder = m(), this.firstTime = 0, this.lastMSW = 0 } return y.prototype = { setReturnCallback: function(t) { this.rtpReturnCallback = t }, setBufferfullCallback: function(t) { null !== this.videoBufferList && this.videoBufferList.setBufferFullCallback(t) }, getVideoBuffer: function(t) { if (null !== this.videoBufferList) return this.videoBufferList.searchNodeAt(t) }, clearBuffer: function() { null !== this.videoBufferList && this.videoBufferList.clear() }, findCurrent: function() { null !== this.videoBufferList && this.videoBufferList.searchTimestamp(this.getTimeStamp()) }, ntohl: function(t) { return (t[0] << 24) + (t[1] << 16) + (t[2] << 8) + t[3] >>> 0 }, appendBuffer: function(t, e, r) { if (r + e.length >= t.length) { var a = new Uint8Array(t.length + 1048576);
  267. a.set(t, 0), t = a } return t.set(e, r), t }, setGovLength: function(t) { p = t }, getGovLength: function() { return p }, setDecodingTime: function(t) { this.decodingTime = t }, getDropPercent: function() { return 0 }, getDropCount: function() { return 0 }, initStartTime: function() { this.firstDiffTime = 0, this.calcGov = 0 }, setCheckDelay: function(t) { this.checkDelay = t }, init: function() { this.decoder.setIsFirstFrame(!1), this.videoBufferList = new o, this.firstDiffTime = 0, this.checkDelay = !0, this.timeData = null }, parseRTPData: function(o, p, m, d, _) { var y = null,
  268. b = {},
  269. D = (p[19] << 24) + (p[18] << 16) + (p[17] << 8) + p[16] >>> 0,
  270. T = Date.UTC("20" + (D >>> 26), (D >>> 22 & 15) - 1, D >>> 17 & 31, D >>> 12 & 31, D >>> 6 & 63, 63 & D) / 1e3; if (T += (new Date).getTimezoneOffset() / 60 * 3600, 0 == this.firstTime) this.firstTime = T, this.lastMSW = 0, r = (p[21] << 8) + p[20], f = { timestamp: this.firstTime, timestamp_usec: 0 };
  271. else { var S, w = (p[21] << 8) + p[20];
  272. S = w > r ? w - r : w + 65535 - r, this.lastMSW += S, T > this.firstTime && (this.lastMSW -= 1e3), this.firstTime = T, f = { timestamp: T, timestamp_usec: this.lastMSW }, r = w }
  273. 0 !== this.getFramerate() && "undefined" !== typeof this.getFramerate() || "undefined" === typeof this.getTimeStamp() || (this.setFramerate(Math.round(1e3 / ((f.timestamp - this.getTimeStamp().timestamp === 0 ? 0 : 1e3) + (f.timestamp_usec - this.getTimeStamp().timestamp_usec)))), i.log("setFramerate" + Math.round(1e3 / ((f.timestamp - this.getTimeStamp().timestamp === 0 ? 0 : 1e3) + (f.timestamp_usec - this.getTimeStamp().timestamp_usec))))), this.setTimeStamp(f); var C = p[22];
  274. t = p.subarray(24 + C, p.length - 8), e = (p[21] << 8) + p[20]; for (var I = [], F = 0; F <= t.length;)
  275. if (0 == t[F])
  276. if (0 == t[F + 1])
  277. if (1 == t[F + 2]) { if (I.push(F), 5 == (31 & t[F += 3]) || 1 == (31 & t[F])) break } else 0 == t[F + 2] ? F++ : F += 3;
  278. else F += 2;
  279. else F += 1; var A = "P"; for (F = 0; F < I.length; F++) switch (y = t.subarray(I[F] + 3, I[F + 1]), t[I[F] + 3] >> 1 & 63) { default: break;
  280. case 33:
  281. A = "I", s.parse2(y); var M = _;n = s.getSizeInfo().decodeSize, l = M.width, c = M.height, h.width == M.width && h.height == M.height || (0 != h.width ? (h.width = M.width, h.height = M.height, b.resolution = h, b.resolution.decodeMode = "canvas", b.resolution.encodeMode = "h265") : (h.width = M.width, h.height = M.height, b.decodeStart = h, b.decodeStart.decodeMode = "canvas", b.decodeStart.encodeMode = "h265")) }
  282. var k = 1e3 * f.timestamp + f.timestamp_usec;
  283. 0 == this.firstDiffTime ? (g = 0, this.firstDiffTime = Date.now() - k, i.log("firstDiff: 0")) : (k - v < 0 && (this.firstDiffTime = g + (Date.now() - k).toFixed(0)), (g = Date.now() - k - this.firstDiffTime) < 0 && (this.firstDiffTime = 0, g = 0), g > 8e3 && (b.error = { errorCode: 101 }, this.rtpReturnCallback(b))), v = k, u.frameData = null, a !== n && (this.decoder.free(), a = n, this.decoder.setOutputSize(a)), u.frameData = this.decoder.decode(t), u.frameData.frameType = A, u.frameData.frameIndex = _.frameIndex, u.timeStamp = null, f = null === f.timestamp ? this.getTimeStamp() : f, u.timeStamp = f, m && (b.backupData = { stream: t, frameType: A, width: l, height: c, codecType: "h265" }, null !== f.timestamp && "undefined" !== typeof f.timestamp ? b.backupData.timestamp_usec = f.timestamp_usec : b.backupData.timestamp = (e / 90).toFixed(0)), b.decodedData = u, this.rtpReturnCallback(b) }, findIFrame: function() { if (null !== this.videoBufferList) { var t = this.videoBufferList.findIFrame(); if (null === t || "undefined" === typeof t) return !1; var e = {}; return this.setTimeStamp(t.timeStamp), e.frameData = this.decoder.decode(t.buffer), e.timeStamp = t.timeStamp, e } }, getFramerate: function() { return _ }, setFramerate: function(t) { 0 < t && "undefined" !== typeof t && (_ = t, null !== this.videoBufferList && (this.videoBufferList.setMaxLength(6 * _), this.videoBufferList.setBUFFERING(4 * _))) }, getTimeStamp: function() { return this.timeData }, setTimeStamp: function(t) { this.timeData = t } }, new y }; var h = function() { var t, e, r = !1;
  284. function a() { i.log("MJPEG Decoder") } return a.prototype = { setIsFirstFrame: function(t) { r = t }, isFirstFrame: function() { return r }, setResolution: function(r, a) { t = r, e = a }, decode: function(r, n) { return a.prototype.isFirstFrame() ? { data: r, width: t, height: e, codecType: "mjpeg" } : (a.prototype.setIsFirstFrame(!0), { firstFrame: !0 }) } }, new a },
  285. g = function() { var t = 0,
  286. e = 0,
  287. r = { frameData: null, timeStamp: null },
  288. a = { timestamp: null, timezone: null }; var n = 0,
  289. s = 0,
  290. u = 0,
  291. f = 0,
  292. l = null,
  293. c = null,
  294. p = null,
  295. m = 0,
  296. d = 0,
  297. _ = 0,
  298. g = { width: 0, height: 0 };
  299. function v() { this.decoder = new h, this.firstTime = 0, this.lastMSW = 0 } return v.prototype = { init: function() { this.decoder.setIsFirstFrame(!1), this.videoBufferList = new o, this.timeData = null }, parseRTPData: function(o, p, m, h, v) { var y = new Uint8Array(1048576);
  300. t = v.width, e = v.height, l = {}; var b = p[22],
  301. D = p.subarray(24 + b, p.length - 8);
  302. c = D.length; var T = (p[19] << 24) + (p[18] << 16) + (p[17] << 8) + p[16] >>> 0,
  303. S = Date.UTC("20" + (T >>> 26), (T >>> 22 & 15) - 1, T >>> 17 & 31, T >>> 12 & 31, T >>> 6 & 63, 63 & T) / 1e3; if (S -= 28800, 0 == this.firstTime) this.firstTime = S, this.lastMSW = 0, f = (p[21] << 8) + p[20], a = { timestamp: this.firstTime, timestamp_usec: 0 };
  304. else { var w, C = (p[21] << 8) + p[20];
  305. w = C > f ? C - f : C + 65535 - f, this.lastMSW += w, S > this.firstTime && (this.lastMSW -= 1e3), this.firstTime = S, a = { timestamp: S, timestamp_usec: this.lastMSW }, f = C }
  306. 0 !== this.getFramerate() && "undefined" !== typeof this.getFramerate() || "undefined" === typeof this.getTimeStamp() || this.setFramerate(Math.round(1e3 / ((a.timestamp - this.getTimeStamp().timestamp === 0 ? 0 : 1e3) + (a.timestamp_usec - this.getTimeStamp().timestamp_usec)))), this.setTimeStamp(a), u = (p[21] << 8) + p[20], s = c, (y = this.appendBuffer(y, D, n))[(n += c) + s - 2] = 255, y[n + s - 1] = 217, g.width == t && g.height == e || (0 != g.width ? (g.width = t, g.height = e, l.resolution = g, l.resolution.decodeMode = "canvas", l.resolution.encodeMode = "mjpeg") : (g.width = t, g.height = e, l.decodeStart = g, l.decodeStart.decodeMode = "canvas", l.decodeStart.encodeMode = "mjpeg")); var I = 1e3 * a.timestamp + a.timestamp_usec;
  307. 0 == this.firstDiffTime ? (d = 0, this.firstDiffTime = Date.now() - I, i.log("firstDiff: " + this.firstTime)) : (I - _ < 0 && (this.firstDiffTime = d + (Date.now() - I).toFixed(0)), (d = Date.now() - I - this.firstDiffTime) < 0 && (this.firstDiffTime = 0, d = 0), d > 8e3 && (l.error = { errorCode: 101 }, this.rtpReturnCallback(l))), _ = I, r.frameData = null, this.decoder.setResolution(t, e), r.frameData = this.decoder.decode(y.subarray(0, n)), r.timeStamp = null, a = null === a.timestamp ? this.getTimeStamp() : a, r.timeStamp = a, !0 === m && (l.backupData = { stream: y.subarray(0, n), width: t, height: e, codecType: "mjpeg" }, null !== a.timestamp && "undefined" !== typeof a.timestamp ? l.backupData.timestamp_usec = a.timestamp_usec : l.backupData.timestamp = (u / 90).toFixed(0)), n = 0, r.playback = !1, l.decodedData = r, this.rtpReturnCallback(l) }, getVideoBuffer: function(t) { if (null !== this.videoBufferList) return this.videoBufferList.searchNodeAt(t) }, clearBuffer: function() { null !== this.videoBufferList && this.videoBufferList.clear() }, findCurrent: function() { null !== this.videoBufferList && this.videoBufferList.searchTimestamp(this.getTimeStamp()) }, findIFrame: function() { null !== this.videoBufferList && this.videoBufferList.findIFrame() }, SetRtpInterlevedID: function(t) { this.interleavedID = t }, setTimeStamp: function(t) { this.timeData = t }, getTimeStamp: function() { return this.timeData }, getRTPPacket: function(t, e) {}, calculatePacketTime: function(t) {}, ntohl: function(t) { return (t[0] << 24) + (t[1] << 16) + (t[2] << 8) + t[3] >>> 0 }, appendBuffer: function(t, e, r) { if (r + e.length >= t.length) { var a = new Uint8Array(t.length + 1048576);
  308. a.set(t, 0), t = a } return t.set(e, r), t }, setFramerate: function(t) { 0 < t && "undefined" !== typeof t && (m = t, null !== this.videoBufferList && (this.videoBufferList.setMaxLength(6 * m), this.videoBufferList.setBUFFERING(4 * m))) }, getFramerate: function() { return m }, setReturnCallback: function(t) { this.rtpReturnCallback = t }, setBufferfullCallback: function(t) { null !== this.videoBufferList && this.videoBufferList.setBufferFullCallback(t) }, setGovLength: function(t) { p = t }, getGovLength: function() { return p }, setDecodingTime: function(t) { this.decodingTime = t }, getDropPercent: function() { return 0 }, getDropCount: function() { return 0 }, initStartTime: function() { this.firstDiffTime = 0, this.calcGov = 0 }, setCheckDelay: function(t) { this.checkDelay = t } }, new v },
  309. v = function() { var t, e = null,
  310. r = { 1: "VideoSynopsis", 2: "TrafficGate", 3: "ElectronicPolice", 4: "SinglePtzParking", 5: "PtzParking", 6: "Traffic", 7: "Normal", 8: "Prison", 9: "ATM", 10: "MetroIVS", 11: "FaceDetection", 12: "FaceRecognition", 13: "NumberStat", 14: "HeatMap", 15: "VideoDiagnosis", 16: "VideoEnhance", 17: "SmokeFireDetect", 18: "VehicleAnalyse", 19: "PersonFeature", 20: "SDFaceDetect", 21: "HeatMapPlan", 22: "ATMFD", 23: "SCR", 24: "NumberStatPlan", 25: "CourseRecord", 26: "Highway", 27: "City", 28: "LeTrack", 29: "ObjectStruct", 30: "Stereo", 31: "StereoPc", 32: "HumanDetect", 33: "SDPedestrain", 34: "FaceAnalysis", 35: "FaceAttribute", 36: "FacePicAnalyse", 37: "SDEP", 38: "XRayDetect", 39: "ObjectDetect", 40: "CrowdDistriMap", 41: "StereoBehavior" };
  311. function a() { this.firstTime = 0, this.lastMSW = 0 }
  312. function n(t) { for (var e = [].slice.call(t), r = "", a = 0; a < e.length; a++) r += String.fromCharCode(e[a]); return decodeURIComponent(escape(r)) }
  313. function o(t) { var e = { result: !0, type: 0 }; return e.params = JSON.parse(n(t)), e }
  314. function s(t) { var e = { result: !1 },
  315. a = 0,
  316. n = (t[a + 1] << 8) + t[a]; if (1 !== n && 2 !== n) return e;
  317. e.result = !0, e.type = 5, e.params = null; var i = t[a += 2]; if (0 === i) return e; var o = t[a += 1];
  318. a += 1, e.params = {}, e.params.coordinate = 128 & o ? 8192 : 1024, e.params.isTrack = !!(127 & o), e.params.object = []; for (var s = 0; s < i; s++) { var u = {};
  319. u.objectId = (t[a + 3] << 24) + (t[a + 2] << 16) + (t[a + 1] << 8) + t[a], a += 4, u.operateType = t[a]; var f = t[a += 1];
  320. a += 1, u.objectType = t[a]; var l = t[a += 1];
  321. a += 1, a += 1, a += 1, u.classID = r[t[a]], a += 1, u.subType = t[a], a += 1, l > 0 && (u.fatherId = []); for (var c = 0; c < l; c++) u.fatherId.push((t[a + 3] << 24) + (t[a + 2] << 16) + (t[a + 1] << 8) + t[a]), a += 4;
  322. f > 0 && (u.track = []); for (var p = 0; p < f; p++) { var m = (t[a + 1] << 8) + t[a],
  323. d = (t[(a += 2) + 1] << 8) + t[a],
  324. _ = (t[(a += 2) + 1] << 8) + t[a],
  325. h = (t[(a += 2) + 1] << 8) + t[a];
  326. a += 2, u.track.push([m - _, d - h, m + _, d + h]) }
  327. e.params.object.push(u) } return e }
  328. function u(t) { for (var e = { result: !1, type: 20, params: [] }, r = (t[0], t.length), a = 0, i = t.slice(4), o = function() { var t = {};
  329. t.objectId = (i[a + 3] << 24) + (i[a + 2] << 16) + (i[a + 1] << 8) + (i[a + 0] << 0), a += 4, t.result = !0, t.params = {}, t.custom = (i[a + 1] << 8) + i[a], a += 2, t.objectStatus = i[a]; var e = i[a += 1];
  330. a += 1, t.params.object = []; for (var r = null, o = 0; o < e; o++) { switch (i[a]) {
  331. case 1:
  332. r = c(i.slice(a)); break;
  333. case 2:
  334. r = l(i.slice(a)); break;
  335. case 3:
  336. r = f(i.slice(a)); break;
  337. case 4:
  338. r = p(i.slice(a)) }
  339. t.params.object.push(r.info), a += r.offset }
  340. 1 != t.objectStatus && 3 != t.objectStatus || (t.params = null), 0 == e && (t.params = null); var s = (i[a + 1] << 8) + i[a];
  341. a += 2; var u = n(i.slice(a, a + s)); return t.appendInfo = String.fromCharCode.apply(null, i.slice(a, a + s)), a += s, t.appendInfo = u, t }; a < r - 4;) e.params.push(o()); return e }
  342. function f(t) { var e = 0,
  343. r = { type: t[0] };
  344. e += 1, r.pointCount = t[e], e += 1, r.lineWidth = t[e], e += 1, r.strokeStyle = t[e], e += 1, r.borderColor = [t[e + 1], t[e + 2], t[e + 3], t[e]], r.borderColorType = "RGBA", e += 4, r.fillColor = [t[e + 1], t[e + 2], t[e + 3], t[e]], r.fillColorType = "RGBA", e += 4, r.coordinate = []; for (var a = 0; a < r.pointCount; a++) { var n = (t[e + 1] << 8) + t[e],
  345. i = (t[(e += 2) + 1] << 8) + t[e];
  346. e += 2, r.coordinate.push([n, i]) } return { info: r, offset: e } }
  347. function l(t) { var e = 0,
  348. r = { type: t[0] };
  349. e += 1, r.pointCount = t[e], e += 1, r.lineWidth = t[e], e += 1, r.strokeStyle = t[e], e += 1, r.lineColor = [t[e + 1], t[e + 2], t[e + 3], t[e]], r.lineColorType = "RGBA", e += 4, r.coordinate = []; for (var a = 0; a < r.pointCount; a++) { var n = (t[e + 1] << 8) + t[e],
  350. i = (t[(e += 2) + 1] << 8) + t[e];
  351. e += 2, r.coordinate.push([n, i]) } return { info: r, offset: e } }
  352. function c(t) { var e = 0,
  353. r = { type: t[0] };
  354. e += 1, r.lineWidth = t[e], e += 1, r.strokeStyle = t[e], e += 1, e += 1, r.radius = (t[e + 1] << 8) + t[e], e += 2; var a = (t[(e += 2) + 1] << 8) + t[e],
  355. n = (t[(e += 2) + 1] << 8) + t[e]; return e += 2, r.coordinate = [a, n], r.borderColor = [t[e + 1], t[e + 2], t[e + 3], t[e]], r.borderColorType = "RGBA", e += 4, r.fillColor = [t[e + 1], t[e + 2], t[e + 3], t[e]], r.fillColorType = "RGBA", { info: r, offset: e += 4 } }
  356. function p(t) { var e = 0,
  357. r = { type: t[0] };
  358. e += 1, r.encodeType = t[e], e += 1; var a = (t[(e += 2) + 1] << 8) + t[e],
  359. n = (t[(e += 2) + 1] << 8) + t[e]; return e += 2, r.coordinate = [a, n], r.fontColor = [t[e + 1], t[e + 2], t[e + 3], t[e]], e += 4, r.colorType = "RGBA", r.fontSize = t[e], e += 1, r.textAlign = t[e], e += 1, r.textLength = (t[e + 1] << 8) + t[e], e += 2, r.content = String.fromCharCode.apply(null, t.slice(e, e + r.textLength)), { info: r, offset: e += r.textLength } }
  360. function m(t, e) { e.hasOwnProperty("attribute80") || (e.attribute80 = []); var r = 1,
  361. a = t[r];
  362. r += 1; var n = { color: {} };
  363. n.color.valid = t[r], r += 1, n.carModel = t[r], r += 1, n.color.red = t[r], r += 1, n.color.green = t[r], r += 1, n.color.blue = t[r], r += 1, n.color.alpha = t[r], r += 1, n.brand = (t[r + 1] << 8) + t[r], r += 2, n.subBrand = (t[r + 1] << 8) + t[r], r += 2, n.year = (t[r + 1] << 8) + t[r], r += 2, n.reliability = t[r], r += 1; var i = (t[(r += 1) + 1] << 8) + t[r],
  364. o = (t[(r += 2) + 1] << 8) + t[r],
  365. s = (t[(r += 2) + 1] << 8) + t[r],
  366. u = (t[(r += 2) + 1] << 8) + t[r]; return r += 2, n.windowPosition = [i - s, o - u, i + s, o + u], e.attribute80.push(n), a }
  367. function d(t, e) { e.hasOwnProperty("attribute81") || (e.attribute81 = []); var r = {},
  368. a = 1,
  369. n = t[a],
  370. i = (t[(a += 1) + 1] << 8) + t[a],
  371. o = (t[(a += 2) + 1] << 8) + t[a],
  372. s = (t[(a += 2) + 1] << 8) + t[a],
  373. u = (t[(a += 2) + 1] << 8) + t[a]; return a += 2, r.mainPosition = [i - s, o - u, i + s, o + u], i = (t[a + 1] << 8) + t[a], o = (t[(a += 2) + 1] << 8) + t[a], s = (t[(a += 2) + 1] << 8) + t[a], u = (t[(a += 2) + 1] << 8) + t[a], a += 2, r.coPosition = [i - s, o - u, i + s, o + u], r.mainSafetyBelt = t[a] >> 2 & 3, r.coSafetyBelt = 3 & t[a], a += 1, r.mainSunvisor = t[a] >> 2 & 3, r.coSunvisor = 3 & t[a], a += 1, e.attribute81.push(r), n }
  374. function _(t, e) { e.hasOwnProperty("attribute82") || (e.attribute82 = []); var r = {},
  375. a = 1,
  376. n = t[a]; return a += 1, r.plateEncode = t[a], a += 1, r.plateInfoLen = t[a], a += 1, r.plateInfo = t.subarray(a, a + r.plateInfoLen), e.attribute82.push(r), n }
  377. function h(t, e) { e.hasOwnProperty("attribute83") || (e.attribute83 = []); var r = {},
  378. a = 1,
  379. n = t[a]; return a += 1, r.color = {}, r.color.valid = t[a], a += 1, r.color.red = t[a], a += 1, r.color.green = t[a], a += 1, r.color.blue = t[a], a += 1, r.color.alpha = t[a], a += 1, r.country = String.fromCharCode.apply(null, t.subarray(a, a + 4)), a += 4, r.plateType = (t[a + 1] << 8) + t[a], a += 2, a += 1, r.plateWidth = (t[a + 1] << 8) + t[a], e.attribute83.push(r), n }
  380. function g(t, e) { e.hasOwnProperty("attribute84") || (e.attribute84 = []); var r = {},
  381. a = 1,
  382. n = t[a];
  383. a += 1, r.fatherCount = t[a], a += 1, r.trackCount = t[a], a += 1, r.trackType = t[a], a += 1, a += 3, r.fatherCount > 0 && (r.fatherID = []); for (var i = 0; i < r.fatherCount; i++) r.fatherID.push((t[a + 3] << 24) + (t[a + 2] << 16) + (t[a + 1] << 8) + t[a]), a += 4;
  384. r.trackCount > 0 && (r.track = []); for (var o = 0; o < r.trackCount; o++) { var s = (t[a + 1] << 8) + t[a],
  385. u = (t[(a += 2) + 1] << 8) + t[a],
  386. f = (t[(a += 2) + 1] << 8) + t[a],
  387. l = (t[(a += 2) + 1] << 8) + t[a];
  388. a += 2, r.track.push([s - f, u - l, s + f, u + l]) } return e.attribute84.push(r), n }
  389. function v(t, e) { e.hasOwnProperty("attribute85") || (e.attribute85 = []); var r = {},
  390. a = 1,
  391. n = t[a];
  392. a += 1, r.colorSpace = t[a], a += 1, r.mainColorCount = t[a], a += 1, r.mainColorCount > 0 && (r.mainColorInfo = []); for (var i = 0; i < r.mainColorCount; i++) { var o = {},
  393. s = (t[a + 1] << 8) + t[a],
  394. u = (t[(a += 2) + 1] << 8) + t[a],
  395. f = (t[(a += 2) + 1] << 8) + t[a],
  396. l = (t[(a += 2) + 1] << 8) + t[a];
  397. a += 2, o.rect = [s - f, u - l, s + f, u + l], o.color = (t[a + 3] << 24) + (t[a + 2] << 16) + (t[a + 1] << 8) + t[a], a += 4, r.mainColorInfo.push(o) } return e.attribute85.push(r), n }
  398. function y(t, e) { e.hasOwnProperty("attribute86") || (e.attribute86 = []); var r = {},
  399. a = 1,
  400. n = t[a]; return a += 1, a += 1, r.speedType = t[a], a += 1, r.speed = t[a + 1] << 8 + t[a], a += 2, r.speedX = t[a + 1] << 8 + t[a], a += 2, r.speedY = (t[a + 1] << 8) + t[a], e.attribute86.push(r), n }
  401. function b(t, e) { e.hasOwnProperty("attribute87") || (e.attribute87 = []); var r = {},
  402. a = 1,
  403. n = t[a];
  404. a += 1; var i = (t[(a += 2) + 1] << 8) + t[a],
  405. o = (t[(a += 2) + 1] << 8) + t[a],
  406. s = (t[(a += 2) + 1] << 8) + t[a],
  407. u = (t[(a += 2) + 1] << 8) + t[a]; return r.track = [
  408. [i - s, o - u, i + s, o + u]
  409. ], e.attribute87.push(r), n }
  410. function D(t, e) { e.hasOwnProperty("attribute88") || (e.attribute88 = []); var r = {},
  411. a = 1; return a += 1, r.age = t[a], a += 1, r.sex = t[a], a += 1, r.face = t[a], a += 1, r.glass = t[a], a += 1, r.hat = t[a], a += 1, r.call = t[a], a += 1, r.backpack = t[a], a += 1, r.umbrella = t[a], a += 1, r.height = t[a], a += 1, r.mask = t[a] >> 2 & 3, r.beard = 3 & t[a], e.attribute88.push(r), len }
  412. function T(t, e) { e.hasOwnProperty("attribute89") || (e.attribute89 = []); var r = {},
  413. a = 1,
  414. n = t[a];
  415. a += 1, r.yawAngle = parseInt((t[a + 1] << 8) + t[a]), a += 2, r.rollAngle = parseInt((t[a + 1] << 8) + t[a]), a += 2, r.pitchAngle = parseInt((t[a + 1] << 8) + t[a]); var i = (t[(a += 2) + 1] << 8) + t[a],
  416. o = (t[(a += 2) + 1] << 8) + t[a];
  417. a += 2, r.lEyePos = [i, o], i = (t[a + 1] << 8) + t[a], o = (t[(a += 2) + 1] << 8) + t[a], a += 2, r.rEyePos = [i, o], i = (t[a + 1] << 8) + t[a], o = (t[(a += 2) + 1] << 8) + t[a], a += 2, r.nosePos = [i, o], i = (t[a + 1] << 8) + t[a], o = (t[(a += 2) + 1] << 8) + t[a], a += 2, r.lMouthPos = [i, o], i = (t[a + 1] << 8) + t[a], o = (t[(a += 2) + 1] << 8) + t[a], a += 2, r.rMouthPos = [i, o]; var s = t[a];
  418. a += 3, s > 0 && (r.featurePos = []); for (var u = 0; u < s; u++) i = (t[a + 1] << 8) + t[a], o = (t[(a += 2) + 1] << 8) + t[a], a += 2, r.featurePos.push([i, o]); return e.attribute89.push(r), n }
  419. function S(t, e) { e.hasOwnProperty("attribute8C") || (e.attribute8C = []); var r = {},
  420. a = 1,
  421. n = t[a];
  422. a += 1, r.hangingCount = t[a], a += 1, r.tissueCount = t[a], a += 1, r.sunVisorCount = t[a], a += 1, r.annualInspectionCount = t[a], a += 1, a += 6, r.hangingCount > 0 && (r.hangingCount = []); for (var i = 0; i < r.hangingCount; i++) { var o = (t[a + 1] << 8) + t[a],
  423. s = (t[(a += 2) + 1] << 8) + t[a],
  424. u = (t[(a += 2) + 1] << 8) + t[a],
  425. f = (t[(a += 2) + 1] << 8) + t[a];
  426. a += 2, r.hangingPos.push([o - u, s - f, o + u, s + f]) } for (r.tissueCount > 0 && (r.tissueCount = []), i = 0; i < r.tissueCount; i++) o = (t[a + 1] << 8) + t[a], s = (t[(a += 2) + 1] << 8) + t[a], u = (t[(a += 2) + 1] << 8) + t[a], f = (t[(a += 2) + 1] << 8) + t[a], a += 2, r.tissueCount.push([o - u, s - f, o + u, s + f]); for (r.sunVisorCount > 0 && (r.sunVisorCount = []), i = 0; i < r.tissueCount; i++) o = (t[a + 1] << 8) + t[a], s = (t[(a += 2) + 1] << 8) + t[a], u = (t[(a += 2) + 1] << 8) + t[a], f = (t[(a += 2) + 1] << 8) + t[a], a += 2, r.sunVisorCount.push([o - u, s - f, o + u, s + f]); for (r.annualInspectionCount > 0 && (r.annualInspectionCount = []), i = 0; i < r.tissueCount; i++) o = (t[a + 1] << 8) + t[a], s = (t[(a += 2) + 1] << 8) + t[a], u = (t[(a += 2) + 1] << 8) + t[a], f = (t[(a += 2) + 1] << 8) + t[a], a += 2, r.annualInspectionCount.push([o - u, s - f, o + u, s + f]); return e.attribute8C.push(r), n }
  427. function w(t, e) { e.hasOwnProperty("attribute8E") || (e.attribute8E = []); var r = {},
  428. a = 1,
  429. n = t[a];
  430. a += 1, r.nameCodecFormat = t[a]; var i = t[a += 1]; return a += 1, r.name = String.fromCharCode.apply(null, t.subarray(a, i)), e.attribute8E.push(r), n }
  431. function C(t, e) { for (var r = { 128: m, 129: d, 130: _, 131: h, 132: g, 133: v, 134: y, 135: b, 136: D, 137: T, 140: S, 142: w }, a = 0, n = t[a]; a < t.length;) { var i = t.subarray(a, t.length);
  432. a += r[n].call(null, i, e) } }
  433. function I(t, e) { e.hasOwnProperty("vehicleObject") || (e.vehicleObject = []); var r = {},
  434. a = 0;
  435. r.type = t[a], a += 1; var n = (t[(a += 1) + 1] << 8) + t[a];
  436. a += 2, r.objectId = (t[a + 3] << 24) + (t[a + 2] << 16) + (t[a + 1] << 8) + t[a]; var i = (t[(a += 4) + 1] << 8) + t[a],
  437. o = (t[(a += 2) + 1] << 8) + t[a],
  438. s = (t[(a += 2) + 1] << 8) + t[a],
  439. u = (t[(a += 2) + 1] << 8) + t[a]; return a += 2, r.track = [
  440. [i - s, o - u, i + s, o + u]
  441. ], r.valid = t[a], a += 1, r.operateType = t[a], a += 1, a += 2, C(t.subarray(a, n), r), e.vehicleObject.push(r), n }
  442. function F(t, e) { e.hasOwnProperty("faceObject") || (e.faceObject = []); var r = {},
  443. a = 0;
  444. r.type = t[a], a += 1; var n = (t[(a += 1) + 1] << 8) + t[a]; return n < 12 ? 0 : (a += 2, r.objectId = (t[a + 3] << 24) + (t[a + 2] << 16) + (t[a + 1] << 8) + t[a], a += 4, r.version = t[a], a += 1, a += 3, r.faceData = t.subarray(a, n), e.faceObject.push(r), n) }
  445. function A(t, e) { e.hasOwnProperty("commonObject") || (e.commonObject = []); var r = {},
  446. a = 0;
  447. r.type = t[a], a += 1; var n = (t[(a += 1) + 1] << 8) + t[a]; return a += 2, r.objectId = (t[a + 3] << 24) + (t[a + 2] << 16) + (t[a + 1] << 8) + t[a], a += 4, r.operateType = t[a], a += 1, a += 3, C(t.subarray(a, n), r), e.commonObject.push(r), n }
  448. function M(t, e, r) { var a = 0,
  449. n = (t[a + 3] << 24) + (t[a + 2] << 16) + (t[a + 1] << 8) + t[a],
  450. i = t[a += 4]; if (a += 1, a += 3, 0 == i) return a;
  451. e.groupId = n, e.object = {}; for (var o = 0; o < i; o++) { var s = t[a],
  452. u = t.subarray(a, t.length),
  453. f = 0; switch (s) {
  454. case 2:
  455. case 5:
  456. f = I(u, e.object); break;
  457. case 15:
  458. f = F(u, e.object); break;
  459. default:
  460. f = A(u, e.object) } if (0 == f) return 0;
  461. a += f } return r(e), a }
  462. function k(t, e, r) { var a = { coordinate: 8192 }; if (e.length < 32) return !1; var n = 4;
  463. a.classID = t; var i = e[n]; if (0 == i) return !0;
  464. a.groupCount = i, n += 1, n += 7, a.cameral = []; for (var o = 0; o < 20; o++) a.cameral.push(e[n + o]);
  465. n += 20; for (var s = 0; s < a.groupCount; s++) { var u = M(e.subarray(n, e.length), JSON.parse(JSON.stringify(a)), r); if (u <= 0) break;
  466. n += u } } return a.prototype = { init: function() { i.log("init") }, parseRTPData: function(a, n, i, f, l, c) { var p = (n[19] << 24) + (n[18] << 16) + (n[17] << 8) + n[16] >>> 0,
  467. m = Date.UTC("20" + (p >> 26), (p >> 22 & 15) - 1, p >> 17 & 31, p >> 12 & 31, p >> 6 & 63, 63 & p) / 1e3; if (m -= 28800, 0 == this.firstTime) this.firstTime = m, this.lastMSW = 0, e = (n[21] << 8) + n[20], t = { timestamp: this.firstTime, timestamp_usec: 0 };
  468. else { var d, _ = (n[21] << 8) + n[20];
  469. d = _ >= e ? _ - e : _ + 65535 - e, this.lastMSW += d, m > this.firstTime && (this.lastMSW -= 1e3), this.firstTime = m, t = { timestamp: m, timestamp_usec: this.lastMSW }, e = _ }! function(e, a, n, i) { var f = a[22],
  470. l = a.subarray(24 + f, a.length - 8); switch (e) {
  471. case 0:
  472. n({ ivsDraw: o(l), timeStamp: t, channel: i }); break;
  473. case 5:
  474. n({ ivsDraw: s(l), timeStamp: t, channel: i }); break;
  475. case 6:
  476. break;
  477. case 14:
  478. var c = []; if (function(t, e) { for (var a = t.length, n = 0; n + 4 < a;) { var i = t[n],
  479. o = (t[n + 1], (t[n + 3] << 8) + t[n + 2]),
  480. s = t.subarray(n, o); if (n += o, 161 !== i && !k(r[i - 64], s, e)) break } }(l, function(t) { c.push(t) }), c.length) { var p = { result: !1, type: 14, params: c };
  481. n({ ivsDraw: p, timeStamp: t, channel: i }) } break;
  482. case 20:
  483. n({ ivsDraw: u(l), timeStamp: t, channel: i }) } }(n[5], n, this.rtpReturnCallback, c) }, setBufferfullCallback: function() {}, setReturnCallback: function(t) { this.rtpReturnCallback = t } }, new a };
  484. importScripts("./../module/ffmpegasm.js"), addEventListener("message", function(t) { var e = t.data; switch (k = t.data.channelId, e.type) {
  485. case "sdpInfo":
  486. b = e.data, 0,
  487. function(t) { y = [], w = !1; for (var e = 0; e < t.sdpInfo.length; e++) D = null, T = t.decodeMode, "H264" === t.sdpInfo[e].codecName || "RAW" === t.sdpInfo[e].codecName && t.mp4Codec && "H264" === t.mp4Codec.VideoCodec ? (null === I && (I = p()), (D = I).init(t.decodeMode), D.setFramerate(t.sdpInfo[e].Framerate), D.setGovLength(t.govLength), D.setCheckDelay(t.checkDelay), D.setLessRate(t.lessRateCanvas)) : "H265" === t.sdpInfo[e].codecName || "RAW" === t.sdpInfo[e].codecName && t.mp4Codec && "H265" === t.mp4Codec.VideoCodec ? (null === F && (F = _()), (D = F).init(), D.setFramerate(t.sdpInfo[e].Framerate), D.setGovLength(t.govLength), D.setCheckDelay(t.checkDelay)) : "JPEG" === t.sdpInfo[e].codecName ? (null === A && (A = g()), (D = A).init(), D.setFramerate(t.sdpInfo[e].Framerate)) : "stream-assist-frame" === t.sdpInfo[e].codecName && (i.log(t.sdpInfo[e]), null === M && (M = v()), (D = M).init()), "undefined" !== typeof t.sdpInfo[e].Framerate && t.sdpInfo[e].Framerate, null !== D && (D.setBufferfullCallback(L), D.setReturnCallback(R), C = t.sdpInfo[e].RtpInterlevedID, y[C] = D) }(b); break;
  488. case "MediaData":
  489. if (!0 === w) {! function(t) { C = t.data.rtspInterleave[1], "undefined" !== typeof y[C] && y[C].bufferingRtpData(t.data.rtspInterleave, t.data.header, t.data.payload) }(e); break }
  490. C = e.data.rtspInterleave[1], "undefined" !== typeof y[C] && y[C].parseRTPData(e.data.rtspInterleave, e.data.payload, S, x, e.info, e.channel); break;
  491. case "initStartTime":
  492. y[C].initStartTime(); break;
  493. case "end":
  494. U("end") } }, !1), Module.onRuntimeInitialized = function() { Module._RegisterAll(), U("WorkerReady") }; var y = [],
  495. b = null,
  496. D = null,
  497. T = "",
  498. S = !1,
  499. w = !1,
  500. C = -1,
  501. I = null,
  502. F = null,
  503. A = null,
  504. M = null,
  505. k = null,
  506. x = 1;
  507. function L() { y[C].findCurrent(), U("stepPlay", "BufferFull") }
  508. function R(t) { var e = null; if (null === t || "undefined" === typeof t) return e = null, void null; if ("undefined" !== typeof t.error ? (U("error", t.error), e = t.decodedData) : (e = t.decodedData, null !== t.decodeMode && "undefined" !== typeof t.decodeMode && (T = t.decodeMode, U("setVideoTagMode", t.decodeMode))), null != t.decodeStart && (U("DecodeStart", t.decodeStart), T = t.decodeStart.decodeMode), null !== e && "undefined" !== typeof e)
  509. if (void 0 !== e.frameData && null !== e.frameData && "canvas" === T) {!0 === e.frameData.firstFrame && U("firstFrame", e.frameData.firstFrame); var r = { bufferIdx: e.frameData.bufferIdx, width: e.frameData.width, height: e.frameData.height, codecType: e.frameData.codecType, frameType: e.frameData.frameType, timeStamp: null, frameIndex: e.frameData.frameIndex };
  510. null !== e.timeStamp && "undefined" !== typeof e.timeStamp && (r.timeStamp = e.timeStamp), U("videoInfo", r), "undefined" !== typeof e.frameData.data && null !== e.frameData.data && U("canvasRender", e.frameData.data, e.frameData.option) } else if (null !== e.frameData && "video" === T) { null !== e.initSegmentData && (U("codecInfo", e.codecInfo), U("initSegment", e.initSegmentData));
  511. r = { codecType: e.frameData.codecType, frameIndex: e.frameData.frameIndex }; "undefined" !== typeof e.frameData.width && (r.width = e.frameData.width, r.height = e.frameData.height), U("videoInfo", r), U("videoTimeStamp", e.timeStamp), e.frameData.length > 0 && (U("mediaSample", e.mediaSample), U("videoRender", e.frameData)) } else U("drop", t.decodedData);
  512. null != t.resolution && U("MSEResolutionChanged", t.resolution), null != t.ivsDraw && U("ivsDraw", t) }
  513. function U(t, e, r) { var a = { type: t, data: e, channelId: k, option: r }; "canvasRender" === t ? postMessage(a, [e.buffer]) : postMessage(a) } }]);