ezuikit-js 7.7.1 → 7.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +115 -109
- package/README.md +490 -474
- package/ezuikit.js +57998 -54638
- package/ezuikit_static/v65/v1/js/jsPluginV1-1.0.0.min.js +4 -18
- package/ezuikit_static/v65/v3/js/jsPluginV3-1.0.0.min.js +434 -6
- package/package.json +6 -1
- package/demos/EZUIKitHD/EZUIKitHD.html +0 -171
- package/demos/EZUIKitHD/js/jsWebControl-1.0.0.min.js +0 -80
- package/demos/base-demo/base.html +0 -117
- package/demos/base-demo/ezuikit.js +0 -33480
- package/demos/base-demo/ezuikit_static/v65/v1/css/theme.css +0 -121
- package/demos/base-demo/ezuikit_static/v65/v1/js/AudioRenderer.js +0 -225
- package/demos/base-demo/ezuikit_static/v65/v1/js/SuperRender_10.js +0 -395
- package/demos/base-demo/ezuikit_static/v65/v1/js/SystemTransform.js +0 -22
- package/demos/base-demo/ezuikit_static/v65/v1/js/SystemTransform.js.mem +0 -0
- package/demos/base-demo/ezuikit_static/v65/v1/js/jsPluginV1-1.0.0.min.js +0 -26
- package/demos/base-demo/ezuikit_static/v65/v1/js/playctrl/AudioRenderer.js +0 -225
- package/demos/base-demo/ezuikit_static/v65/v1/js/playctrl/DecodeWorker.js +0 -618
- package/demos/base-demo/ezuikit_static/v65/v1/js/playctrl/Decoder.js +0 -1
- package/demos/base-demo/ezuikit_static/v65/v1/js/playctrl/JSPlaySDKInterface.js +0 -2052
- package/demos/base-demo/ezuikit_static/v65/v1/js/playctrl/SuperRender_10.js +0 -396
- package/demos/base-demo/ezuikit_static/v65/v1/js/playctrl/SuperRender_20.js +0 -1
- package/demos/base-demo/ezuikit_static/v65/v1/js/transform/SystemTransform.js +0 -22
- package/demos/base-demo/ezuikit_static/v65/v1/js/transform/SystemTransform.js.mem +0 -0
- package/demos/base-demo/ezuikit_static/v65/v1/js/transform/systemTransform-worker.min.js +0 -1
- package/demos/base-demo/ezuikit_static/v65/v1/js/tts-v4.js +0 -346
- package/demos/base-demo/ezuikit_static/v65/v1/rec/datepicker.js +0 -1522
- package/demos/base-demo/ezuikit_static/v65/v1/rec/datepicker.min.css +0 -36
- package/demos/base-demo/ezuikit_static/v65/v1/rec/datepicker.zh-CN.js +0 -19
- package/demos/base-demo/ezuikit_static/v65/v1/rec/jquery.min.js +0 -2
- package/demos/base-demo/ezuikit_static/v65/v1/speed/speed.css +0 -145
- package/demos/base-demo/ezuikit_static/v65/v1/talk/adapeter.js +0 -5497
- package/demos/base-demo/ezuikit_static/v65/v1/talk/janus.js +0 -3507
- package/demos/base-demo/ezuikit_static/v65/v1/talk/tts-v4.js +0 -346
- package/demos/base-demo/ezuikit_static/v65/v2/css/theme.css +0 -121
- package/demos/base-demo/ezuikit_static/v65/v2/js/Decoder.js +0 -9198
- package/demos/base-demo/ezuikit_static/v65/v2/js/Decoder.wasm +0 -0
- package/demos/base-demo/ezuikit_static/v65/v2/js/jsPluginV2-2.0.1.min.js +0 -4595
- package/demos/base-demo/ezuikit_static/v65/v2/rec/datepicker.js +0 -1522
- package/demos/base-demo/ezuikit_static/v65/v2/rec/datepicker.min.css +0 -36
- package/demos/base-demo/ezuikit_static/v65/v2/rec/datepicker.zh-CN.js +0 -19
- package/demos/base-demo/ezuikit_static/v65/v2/rec/jquery.min.js +0 -2
- package/demos/base-demo/ezuikit_static/v65/v2/speed/speed.css +0 -145
- package/demos/base-demo/ezuikit_static/v65/v2/talk/adapeter.js +0 -5497
- package/demos/base-demo/ezuikit_static/v65/v2/talk/janus.js +0 -3507
- package/demos/base-demo/ezuikit_static/v65/v2/talk/tts-v4.js +0 -343
- package/demos/base-demo/hls.html +0 -24
- package/demos/base-demo/index.html +0 -117
- package/demos/base-demo/localDecoder.html +0 -118
- package/demos/base-demo/mobileLive.html +0 -117
- package/demos/base-demo/mobileRec.html +0 -116
- package/demos/base-demo/multi.html +0 -129
- package/demos/base-demo/pcLive.html +0 -117
- package/demos/base-demo/pcRec.html +0 -116
- package/demos/base-demo/template.html +0 -124
- package/demos/base-demo/themeData.html +0 -232
- package/demos/nginx-demo/conf/fastcgi.conf +0 -26
- package/demos/nginx-demo/conf/fastcgi_params +0 -25
- package/demos/nginx-demo/conf/koi-utf +0 -109
- package/demos/nginx-demo/conf/koi-win +0 -103
- package/demos/nginx-demo/conf/mime.types +0 -95
- package/demos/nginx-demo/conf/nginx.conf +0 -121
- package/demos/nginx-demo/conf/scgi_params +0 -17
- package/demos/nginx-demo/conf/uwsgi_params +0 -17
- package/demos/nginx-demo/conf/win-utf +0 -126
- package/demos/nginx-demo/contrib/README +0 -21
- package/demos/nginx-demo/contrib/geo2nginx.pl +0 -58
- package/demos/nginx-demo/contrib/unicode2nginx/koi-utf +0 -131
- package/demos/nginx-demo/contrib/unicode2nginx/unicode-to-nginx.pl +0 -48
- package/demos/nginx-demo/contrib/unicode2nginx/win-utf +0 -130
- package/demos/nginx-demo/contrib/vim/ftdetect/nginx.vim +0 -4
- package/demos/nginx-demo/contrib/vim/ftplugin/nginx.vim +0 -1
- package/demos/nginx-demo/contrib/vim/indent/nginx.vim +0 -11
- package/demos/nginx-demo/contrib/vim/syntax/nginx.vim +0 -2268
- package/demos/nginx-demo/docs/CHANGES +0 -8115
- package/demos/nginx-demo/docs/CHANGES.ru +0 -8252
- package/demos/nginx-demo/docs/LICENSE +0 -26
- package/demos/nginx-demo/docs/OpenSSL.LICENSE +0 -127
- package/demos/nginx-demo/docs/PCRE.LICENCE +0 -93
- package/demos/nginx-demo/docs/README +0 -3
- package/demos/nginx-demo/docs/zlib.LICENSE +0 -20
- package/demos/nginx-demo/html/50x.html +0 -21
- package/demos/nginx-demo/html/ezuikit5/ezuikit.js +0 -36107
- package/demos/nginx-demo/html/ezuikit5/index.html +0 -117
- package/demos/nginx-demo/html/ezuikit5/server.js +0 -67
- package/demos/nginx-demo/html/index.html +0 -16
- package/demos/nginx-demo/html/js/adapeter.js +0 -5497
- package/demos/nginx-demo/html/js/janus.js +0 -3507
- package/demos/nginx-demo/html/js/jquery.min.js +0 -2
- package/demos/nginx-demo/html/js/sts.js +0 -340
- package/demos/nginx-demo/logs/access.log +0 -109
- package/demos/nginx-demo/logs/error.log +0 -15
- package/demos/nginx-demo/logs/nginx.pid +0 -1
- package/demos/nginx-demo/nginx.exe +0 -0
- package/demos/react-demo/README.md +0 -68
- package/demos/react-demo/package.json +0 -36
- package/demos/react-demo/public/favicon.ico +0 -0
- package/demos/react-demo/public/index.html +0 -43
- package/demos/react-demo/public/logo192.png +0 -0
- package/demos/react-demo/public/logo512.png +0 -0
- package/demos/react-demo/public/manifest.json +0 -25
- package/demos/react-demo/public/robots.txt +0 -3
- package/demos/react-demo/src/App.css +0 -38
- package/demos/react-demo/src/App.js +0 -114
- package/demos/react-demo/src/App.test.js +0 -9
- package/demos/react-demo/src/index.css +0 -13
- package/demos/react-demo/src/index.js +0 -17
- package/demos/react-demo/src/logo.svg +0 -7
- package/demos/react-demo/src/serviceWorker.js +0 -141
- package/demos/react-demo/src/setupTests.js +0 -5
- package/demos/vue-demo/README.md +0 -24
- package/demos/vue-demo/babel.config.js +0 -5
- package/demos/vue-demo/package.json +0 -43
- package/demos/vue-demo/public/favicon.ico +0 -0
- package/demos/vue-demo/public/index.html +0 -17
- package/demos/vue-demo/src/App.vue +0 -27
- package/demos/vue-demo/src/assets/logo.png +0 -0
- package/demos/vue-demo/src/components/EZUIKitJs.vue +0 -115
- package/demos/vue-demo/src/main.js +0 -8
|
@@ -1,4595 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
// eslint-disable-next-line no-extend-native
|
|
4
|
-
Date.prototype.Format = function (fmt) {
|
|
5
|
-
var o = {
|
|
6
|
-
"M+": this.getMonth() + 1,
|
|
7
|
-
"d+": this.getDate(),
|
|
8
|
-
"h+": this.getHours(),
|
|
9
|
-
"m+": this.getMinutes(),
|
|
10
|
-
"s+": this.getSeconds(),
|
|
11
|
-
"q+": Math.floor((this.getMonth() + 3) / 3),
|
|
12
|
-
"S": this.getMilliseconds()
|
|
13
|
-
};
|
|
14
|
-
if (/(y+)/.test(fmt)) {
|
|
15
|
-
fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
|
|
16
|
-
}
|
|
17
|
-
for (var k in o) {
|
|
18
|
-
if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
|
|
19
|
-
}
|
|
20
|
-
return fmt;
|
|
21
|
-
};
|
|
22
|
-
const loadJSByBlobToHeader = (url, callback, isReady) => {
|
|
23
|
-
if (isReady) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
fetch(url).then(response => response.text()).then(res => {
|
|
27
|
-
var workBlob = new Blob([res]);
|
|
28
|
-
const url = URL.createObjectURL(workBlob);
|
|
29
|
-
var oJs = document.createElement("script");
|
|
30
|
-
oJs.setAttribute("src", url);
|
|
31
|
-
oJs.onload = () => callback();
|
|
32
|
-
document.getElementsByTagName("head")[0].appendChild(oJs);
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
(function webpackUniversalModuleDefinition(root, factory) {
|
|
37
|
-
if (typeof exports === 'object' && typeof module === 'object') module.exports = factory();else if (typeof define === 'function' && define.amd) define([], factory);else {
|
|
38
|
-
var a = factory();
|
|
39
|
-
for (var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
|
|
40
|
-
}
|
|
41
|
-
})(window, function () {
|
|
42
|
-
return (/******/function (modules) {
|
|
43
|
-
// webpackBootstrap
|
|
44
|
-
/******/ // The module cache
|
|
45
|
-
/******/
|
|
46
|
-
var installedModules = {};
|
|
47
|
-
/******/
|
|
48
|
-
/******/ // The require function
|
|
49
|
-
/******/
|
|
50
|
-
function __webpack_require__(moduleId) {
|
|
51
|
-
/******/
|
|
52
|
-
/******/ // Check if module is in cache
|
|
53
|
-
/******/if (installedModules[moduleId]) {
|
|
54
|
-
/******/return installedModules[moduleId].exports;
|
|
55
|
-
/******/
|
|
56
|
-
}
|
|
57
|
-
/******/ // Create a new module (and put it into the cache)
|
|
58
|
-
/******/
|
|
59
|
-
var module = installedModules[moduleId] = {
|
|
60
|
-
/******/i: moduleId,
|
|
61
|
-
/******/l: false,
|
|
62
|
-
/******/exports: {}
|
|
63
|
-
/******/
|
|
64
|
-
};
|
|
65
|
-
/******/
|
|
66
|
-
/******/ // Execute the module function
|
|
67
|
-
/******/
|
|
68
|
-
modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
69
|
-
/******/
|
|
70
|
-
/******/ // Flag the module as loaded
|
|
71
|
-
/******/
|
|
72
|
-
module.l = true;
|
|
73
|
-
/******/
|
|
74
|
-
/******/ // Return the exports of the module
|
|
75
|
-
/******/
|
|
76
|
-
return module.exports;
|
|
77
|
-
/******/
|
|
78
|
-
}
|
|
79
|
-
/******/
|
|
80
|
-
/******/
|
|
81
|
-
/******/ // expose the modules object (__webpack_modules__)
|
|
82
|
-
/******/
|
|
83
|
-
__webpack_require__.m = modules;
|
|
84
|
-
/******/
|
|
85
|
-
/******/ // expose the module cache
|
|
86
|
-
/******/
|
|
87
|
-
__webpack_require__.c = installedModules;
|
|
88
|
-
/******/
|
|
89
|
-
/******/ // define getter function for harmony exports
|
|
90
|
-
/******/
|
|
91
|
-
__webpack_require__.d = function (exports, name, getter) {
|
|
92
|
-
/******/if (!__webpack_require__.o(exports, name)) {
|
|
93
|
-
/******/Object.defineProperty(exports, name, {
|
|
94
|
-
enumerable: true,
|
|
95
|
-
get: getter
|
|
96
|
-
});
|
|
97
|
-
/******/
|
|
98
|
-
}
|
|
99
|
-
/******/
|
|
100
|
-
};
|
|
101
|
-
/******/
|
|
102
|
-
/******/ // define __esModule on exports
|
|
103
|
-
/******/
|
|
104
|
-
__webpack_require__.r = function (exports) {
|
|
105
|
-
/******/if (typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
106
|
-
/******/Object.defineProperty(exports, Symbol.toStringTag, {
|
|
107
|
-
value: 'Module'
|
|
108
|
-
});
|
|
109
|
-
/******/
|
|
110
|
-
}
|
|
111
|
-
/******/
|
|
112
|
-
Object.defineProperty(exports, '__esModule', {
|
|
113
|
-
value: true
|
|
114
|
-
});
|
|
115
|
-
/******/
|
|
116
|
-
};
|
|
117
|
-
/******/
|
|
118
|
-
/******/ // create a fake namespace object
|
|
119
|
-
/******/ // mode & 1: value is a module id, require it
|
|
120
|
-
/******/ // mode & 2: merge all properties of value into the ns
|
|
121
|
-
/******/ // mode & 4: return value when already ns object
|
|
122
|
-
/******/ // mode & 8|1: behave like require
|
|
123
|
-
/******/
|
|
124
|
-
__webpack_require__.t = function (value, mode) {
|
|
125
|
-
/******/if (mode & 1) value = __webpack_require__(value);
|
|
126
|
-
/******/
|
|
127
|
-
if (mode & 8) return value;
|
|
128
|
-
/******/
|
|
129
|
-
if (mode & 4 && typeof value === 'object' && value && value.__esModule) return value;
|
|
130
|
-
/******/
|
|
131
|
-
var ns = Object.create(null);
|
|
132
|
-
/******/
|
|
133
|
-
__webpack_require__.r(ns);
|
|
134
|
-
/******/
|
|
135
|
-
Object.defineProperty(ns, 'default', {
|
|
136
|
-
enumerable: true,
|
|
137
|
-
value: value
|
|
138
|
-
});
|
|
139
|
-
/******/
|
|
140
|
-
if (mode & 2 && typeof value != 'string') for (var key in value) __webpack_require__.d(ns, key, function (key) {
|
|
141
|
-
return value[key];
|
|
142
|
-
}.bind(null, key));
|
|
143
|
-
/******/
|
|
144
|
-
return ns;
|
|
145
|
-
/******/
|
|
146
|
-
};
|
|
147
|
-
/******/
|
|
148
|
-
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
149
|
-
/******/
|
|
150
|
-
__webpack_require__.n = function (module) {
|
|
151
|
-
/******/var getter = module && module.__esModule ? /******/function getDefault() {
|
|
152
|
-
return module['default'];
|
|
153
|
-
} : /******/function getModuleExports() {
|
|
154
|
-
return module;
|
|
155
|
-
};
|
|
156
|
-
/******/
|
|
157
|
-
__webpack_require__.d(getter, 'a', getter);
|
|
158
|
-
/******/
|
|
159
|
-
return getter;
|
|
160
|
-
/******/
|
|
161
|
-
};
|
|
162
|
-
/******/
|
|
163
|
-
/******/ // Object.prototype.hasOwnProperty.call
|
|
164
|
-
/******/
|
|
165
|
-
__webpack_require__.o = function (object, property) {
|
|
166
|
-
return Object.prototype.hasOwnProperty.call(object, property);
|
|
167
|
-
};
|
|
168
|
-
/******/
|
|
169
|
-
/******/ // __webpack_public_path__
|
|
170
|
-
/******/
|
|
171
|
-
__webpack_require__.p = "";
|
|
172
|
-
/******/
|
|
173
|
-
/******/
|
|
174
|
-
/******/ // Load entry module and return exports
|
|
175
|
-
/******/
|
|
176
|
-
return __webpack_require__(__webpack_require__.s = 1);
|
|
177
|
-
/******/
|
|
178
|
-
}
|
|
179
|
-
/************************************************************************/
|
|
180
|
-
/******/([/* 0 */
|
|
181
|
-
/***/function (module, exports) {
|
|
182
|
-
var dbits;
|
|
183
|
-
function BigInteger(a, b, c) {
|
|
184
|
-
a != null && ("number" == typeof a ? this.fromNumber(a, b, c) : b == null && "string" != typeof a ? this.fromString(a, 256) : this.fromString(a, b));
|
|
185
|
-
}
|
|
186
|
-
function nbi() {
|
|
187
|
-
return new BigInteger(null);
|
|
188
|
-
}
|
|
189
|
-
function am3(a, b, c, d, e, g) {
|
|
190
|
-
var h = b & 16383;
|
|
191
|
-
for (b >>= 14; --g >= 0;) {
|
|
192
|
-
var f = this[a] & 16383,
|
|
193
|
-
o = this[a++] >> 14,
|
|
194
|
-
p = b * f + o * h,
|
|
195
|
-
f = h * f + ((p & 16383) << 14) + c[d] + e,
|
|
196
|
-
e = (f >> 28) + (p >> 14) + b * o;
|
|
197
|
-
c[d++] = f & 268435455;
|
|
198
|
-
}
|
|
199
|
-
return e;
|
|
200
|
-
}
|
|
201
|
-
(BigInteger.prototype.am = am3, dbits = 28);
|
|
202
|
-
BigInteger.prototype.DB = dbits;
|
|
203
|
-
BigInteger.prototype.DM = (1 << dbits) - 1;
|
|
204
|
-
BigInteger.prototype.DV = 1 << dbits;
|
|
205
|
-
var BI_FP = 52;
|
|
206
|
-
BigInteger.prototype.FV = Math.pow(2, BI_FP);
|
|
207
|
-
BigInteger.prototype.F1 = BI_FP - dbits;
|
|
208
|
-
BigInteger.prototype.F2 = 2 * dbits - BI_FP;
|
|
209
|
-
var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz",
|
|
210
|
-
BI_RC = [],
|
|
211
|
-
rr,
|
|
212
|
-
vv;
|
|
213
|
-
rr = "0".charCodeAt(0);
|
|
214
|
-
for (vv = 0; vv <= 9; ++vv) BI_RC[rr++] = vv;
|
|
215
|
-
rr = "a".charCodeAt(0);
|
|
216
|
-
for (vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
|
|
217
|
-
rr = "A".charCodeAt(0);
|
|
218
|
-
for (vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
|
|
219
|
-
function int2char(a) {
|
|
220
|
-
return BI_RM.charAt(a);
|
|
221
|
-
}
|
|
222
|
-
function intAt(a, b) {
|
|
223
|
-
var c = BI_RC[a.charCodeAt(b)];
|
|
224
|
-
return c == null ? -1 : c;
|
|
225
|
-
}
|
|
226
|
-
function bnpCopyTo(a) {
|
|
227
|
-
for (var b = this.t - 1; b >= 0; --b) a[b] = this[b];
|
|
228
|
-
a.t = this.t;
|
|
229
|
-
a.s = this.s;
|
|
230
|
-
}
|
|
231
|
-
function bnpFromInt(a) {
|
|
232
|
-
this.t = 1;
|
|
233
|
-
this.s = a < 0 ? -1 : 0;
|
|
234
|
-
a > 0 ? this[0] = a : a < -1 ? this[0] = a + DV : this.t = 0;
|
|
235
|
-
}
|
|
236
|
-
function nbv(a) {
|
|
237
|
-
var b = nbi();
|
|
238
|
-
b.fromInt(a);
|
|
239
|
-
return b;
|
|
240
|
-
}
|
|
241
|
-
function bnpFromString(a, b) {
|
|
242
|
-
var c;
|
|
243
|
-
if (b == 16) c = 4;else if (b == 8) c = 3;else if (b == 256) c = 8;else if (b == 2) c = 1;else if (b == 32) c = 5;else if (b == 4) c = 2;else {
|
|
244
|
-
this.fromRadix(a, b);
|
|
245
|
-
return;
|
|
246
|
-
}
|
|
247
|
-
this.s = this.t = 0;
|
|
248
|
-
for (var d = a.length, e = !1, g = 0; --d >= 0;) {
|
|
249
|
-
var h = c == 8 ? a[d] & 255 : intAt(a, d);
|
|
250
|
-
h < 0 ? a.charAt(d) == "-" && (e = !0) : (e = !1, g == 0 ? this[this.t++] = h : g + c > this.DB ? (this[this.t - 1] |= (h & (1 << this.DB - g) - 1) << g, this[this.t++] = h >> this.DB - g) : this[this.t - 1] |= h << g, g += c, g >= this.DB && (g -= this.DB));
|
|
251
|
-
}
|
|
252
|
-
if (c == 8 && (a[0] & 128) != 0) this.s = -1, g > 0 && (this[this.t - 1] |= (1 << this.DB - g) - 1 << g);
|
|
253
|
-
this.clamp();
|
|
254
|
-
e && BigInteger.ZERO.subTo(this, this);
|
|
255
|
-
}
|
|
256
|
-
function bnpClamp() {
|
|
257
|
-
for (var a = this.s & this.DM; this.t > 0 && this[this.t - 1] == a;) --this.t;
|
|
258
|
-
}
|
|
259
|
-
function bnToString(a) {
|
|
260
|
-
if (this.s < 0) return "-" + this.negate().toString(a);
|
|
261
|
-
if (a == 16) a = 4;else if (a == 8) a = 3;else if (a == 2) a = 1;else if (a == 32) a = 5;else if (a == 64) a = 6;else if (a == 4) a = 2;else return this.toRadix(a);
|
|
262
|
-
var b = (1 << a) - 1,
|
|
263
|
-
c,
|
|
264
|
-
d = !1,
|
|
265
|
-
e = "",
|
|
266
|
-
g = this.t,
|
|
267
|
-
h = this.DB - g * this.DB % a;
|
|
268
|
-
if (g-- > 0) {
|
|
269
|
-
if (h < this.DB && (c = this[g] >> h) > 0) d = !0, e = int2char(c);
|
|
270
|
-
for (; g >= 0;) h < a ? (c = (this[g] & (1 << h) - 1) << a - h, c |= this[--g] >> (h += this.DB - a)) : (c = this[g] >> (h -= a) & b, h <= 0 && (h += this.DB, --g)), c > 0 && (d = !0), d && (e += int2char(c));
|
|
271
|
-
}
|
|
272
|
-
return d ? e : "0";
|
|
273
|
-
}
|
|
274
|
-
function bnNegate() {
|
|
275
|
-
var a = nbi();
|
|
276
|
-
BigInteger.ZERO.subTo(this, a);
|
|
277
|
-
return a;
|
|
278
|
-
}
|
|
279
|
-
function bnAbs() {
|
|
280
|
-
return this.s < 0 ? this.negate() : this;
|
|
281
|
-
}
|
|
282
|
-
function bnCompareTo(a) {
|
|
283
|
-
var b = this.s - a.s;
|
|
284
|
-
if (b != 0) return b;
|
|
285
|
-
var c = this.t,
|
|
286
|
-
b = c - a.t;
|
|
287
|
-
if (b != 0) return b;
|
|
288
|
-
for (; --c >= 0;) if ((b = this[c] - a[c]) != 0) return b;
|
|
289
|
-
return 0;
|
|
290
|
-
}
|
|
291
|
-
function nbits(a) {
|
|
292
|
-
var b = 1,
|
|
293
|
-
c;
|
|
294
|
-
if ((c = a >>> 16) != 0) a = c, b += 16;
|
|
295
|
-
if ((c = a >> 8) != 0) a = c, b += 8;
|
|
296
|
-
if ((c = a >> 4) != 0) a = c, b += 4;
|
|
297
|
-
if ((c = a >> 2) != 0) a = c, b += 2;
|
|
298
|
-
a >> 1 != 0 && (b += 1);
|
|
299
|
-
return b;
|
|
300
|
-
}
|
|
301
|
-
function bnBitLength() {
|
|
302
|
-
return this.t <= 0 ? 0 : this.DB * (this.t - 1) + nbits(this[this.t - 1] ^ this.s & this.DM);
|
|
303
|
-
}
|
|
304
|
-
function bnpDLShiftTo(a, b) {
|
|
305
|
-
var c;
|
|
306
|
-
for (c = this.t - 1; c >= 0; --c) b[c + a] = this[c];
|
|
307
|
-
for (c = a - 1; c >= 0; --c) b[c] = 0;
|
|
308
|
-
b.t = this.t + a;
|
|
309
|
-
b.s = this.s;
|
|
310
|
-
}
|
|
311
|
-
function bnpDRShiftTo(a, b) {
|
|
312
|
-
for (var c = a; c < this.t; ++c) b[c - a] = this[c];
|
|
313
|
-
b.t = Math.max(this.t - a, 0);
|
|
314
|
-
b.s = this.s;
|
|
315
|
-
}
|
|
316
|
-
function bnpLShiftTo(a, b) {
|
|
317
|
-
var c = a % this.DB,
|
|
318
|
-
d = this.DB - c,
|
|
319
|
-
e = (1 << d) - 1,
|
|
320
|
-
g = Math.floor(a / this.DB),
|
|
321
|
-
h = this.s << c & this.DM,
|
|
322
|
-
f;
|
|
323
|
-
for (f = this.t - 1; f >= 0; --f) b[f + g + 1] = this[f] >> d | h, h = (this[f] & e) << c;
|
|
324
|
-
for (f = g - 1; f >= 0; --f) b[f] = 0;
|
|
325
|
-
b[g] = h;
|
|
326
|
-
b.t = this.t + g + 1;
|
|
327
|
-
b.s = this.s;
|
|
328
|
-
b.clamp();
|
|
329
|
-
}
|
|
330
|
-
function bnpRShiftTo(a, b) {
|
|
331
|
-
b.s = this.s;
|
|
332
|
-
var c = Math.floor(a / this.DB);
|
|
333
|
-
if (c >= this.t) b.t = 0;else {
|
|
334
|
-
var d = a % this.DB,
|
|
335
|
-
e = this.DB - d,
|
|
336
|
-
g = (1 << d) - 1;
|
|
337
|
-
b[0] = this[c] >> d;
|
|
338
|
-
for (var h = c + 1; h < this.t; ++h) b[h - c - 1] |= (this[h] & g) << e, b[h - c] = this[h] >> d;
|
|
339
|
-
d > 0 && (b[this.t - c - 1] |= (this.s & g) << e);
|
|
340
|
-
b.t = this.t - c;
|
|
341
|
-
b.clamp();
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
function bnpSubTo(a, b) {
|
|
345
|
-
for (var c = 0, d = 0, e = Math.min(a.t, this.t); c < e;) d += this[c] - a[c], b[c++] = d & this.DM, d >>= this.DB;
|
|
346
|
-
if (a.t < this.t) {
|
|
347
|
-
for (d -= a.s; c < this.t;) d += this[c], b[c++] = d & this.DM, d >>= this.DB;
|
|
348
|
-
d += this.s;
|
|
349
|
-
} else {
|
|
350
|
-
for (d += this.s; c < a.t;) d -= a[c], b[c++] = d & this.DM, d >>= this.DB;
|
|
351
|
-
d -= a.s;
|
|
352
|
-
}
|
|
353
|
-
b.s = d < 0 ? -1 : 0;
|
|
354
|
-
d < -1 ? b[c++] = this.DV + d : d > 0 && (b[c++] = d);
|
|
355
|
-
b.t = c;
|
|
356
|
-
b.clamp();
|
|
357
|
-
}
|
|
358
|
-
function bnpMultiplyTo(a, b) {
|
|
359
|
-
var c = this.abs(),
|
|
360
|
-
d = a.abs(),
|
|
361
|
-
e = c.t;
|
|
362
|
-
for (b.t = e + d.t; --e >= 0;) b[e] = 0;
|
|
363
|
-
for (e = 0; e < d.t; ++e) b[e + c.t] = c.am(0, d[e], b, e, 0, c.t);
|
|
364
|
-
b.s = 0;
|
|
365
|
-
b.clamp();
|
|
366
|
-
this.s != a.s && BigInteger.ZERO.subTo(b, b);
|
|
367
|
-
}
|
|
368
|
-
function bnpSquareTo(a) {
|
|
369
|
-
for (var b = this.abs(), c = a.t = 2 * b.t; --c >= 0;) a[c] = 0;
|
|
370
|
-
for (c = 0; c < b.t - 1; ++c) {
|
|
371
|
-
var d = b.am(c, b[c], a, 2 * c, 0, 1);
|
|
372
|
-
if ((a[c + b.t] += b.am(c + 1, 2 * b[c], a, 2 * c + 1, d, b.t - c - 1)) >= b.DV) a[c + b.t] -= b.DV, a[c + b.t + 1] = 1;
|
|
373
|
-
}
|
|
374
|
-
a.t > 0 && (a[a.t - 1] += b.am(c, b[c], a, 2 * c, 0, 1));
|
|
375
|
-
a.s = 0;
|
|
376
|
-
a.clamp();
|
|
377
|
-
}
|
|
378
|
-
function bnpDivRemTo(a, b, c) {
|
|
379
|
-
var d = a.abs();
|
|
380
|
-
if (!(d.t <= 0)) {
|
|
381
|
-
var e = this.abs();
|
|
382
|
-
if (e.t < d.t) b != null && b.fromInt(0), c != null && this.copyTo(c);else {
|
|
383
|
-
c == null && (c = nbi());
|
|
384
|
-
var g = nbi(),
|
|
385
|
-
h = this.s,
|
|
386
|
-
a = a.s,
|
|
387
|
-
f = this.DB - nbits(d[d.t - 1]);
|
|
388
|
-
f > 0 ? (d.lShiftTo(f, g), e.lShiftTo(f, c)) : (d.copyTo(g), e.copyTo(c));
|
|
389
|
-
d = g.t;
|
|
390
|
-
e = g[d - 1];
|
|
391
|
-
if (e != 0) {
|
|
392
|
-
var o = e * (1 << this.F1) + (d > 1 ? g[d - 2] >> this.F2 : 0),
|
|
393
|
-
p = this.FV / o,
|
|
394
|
-
o = (1 << this.F1) / o,
|
|
395
|
-
q = 1 << this.F2,
|
|
396
|
-
n = c.t,
|
|
397
|
-
k = n - d,
|
|
398
|
-
j = b == null ? nbi() : b;
|
|
399
|
-
g.dlShiftTo(k, j);
|
|
400
|
-
c.compareTo(j) >= 0 && (c[c.t++] = 1, c.subTo(j, c));
|
|
401
|
-
BigInteger.ONE.dlShiftTo(d, j);
|
|
402
|
-
for (j.subTo(g, g); g.t < d;) g[g.t++] = 0;
|
|
403
|
-
for (; --k >= 0;) {
|
|
404
|
-
var l = c[--n] == e ? this.DM : Math.floor(c[n] * p + (c[n - 1] + q) * o);
|
|
405
|
-
if ((c[n] += g.am(0, l, c, k, 0, d)) < l) {
|
|
406
|
-
g.dlShiftTo(k, j);
|
|
407
|
-
for (c.subTo(j, c); c[n] < --l;) c.subTo(j, c);
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
b != null && (c.drShiftTo(d, b), h != a && BigInteger.ZERO.subTo(b, b));
|
|
411
|
-
c.t = d;
|
|
412
|
-
c.clamp();
|
|
413
|
-
f > 0 && c.rShiftTo(f, c);
|
|
414
|
-
h < 0 && BigInteger.ZERO.subTo(c, c);
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
function bnMod(a) {
|
|
420
|
-
var b = nbi();
|
|
421
|
-
this.abs().divRemTo(a, null, b);
|
|
422
|
-
this.s < 0 && b.compareTo(BigInteger.ZERO) > 0 && a.subTo(b, b);
|
|
423
|
-
return b;
|
|
424
|
-
}
|
|
425
|
-
function Classic(a) {
|
|
426
|
-
this.m = a;
|
|
427
|
-
}
|
|
428
|
-
function cConvert(a) {
|
|
429
|
-
return a.s < 0 || a.compareTo(this.m) >= 0 ? a.mod(this.m) : a;
|
|
430
|
-
}
|
|
431
|
-
function cRevert(a) {
|
|
432
|
-
return a;
|
|
433
|
-
}
|
|
434
|
-
function cReduce(a) {
|
|
435
|
-
a.divRemTo(this.m, null, a);
|
|
436
|
-
}
|
|
437
|
-
function cMulTo(a, b, c) {
|
|
438
|
-
a.multiplyTo(b, c);
|
|
439
|
-
this.reduce(c);
|
|
440
|
-
}
|
|
441
|
-
function cSqrTo(a, b) {
|
|
442
|
-
a.squareTo(b);
|
|
443
|
-
this.reduce(b);
|
|
444
|
-
}
|
|
445
|
-
Classic.prototype.convert = cConvert;
|
|
446
|
-
Classic.prototype.revert = cRevert;
|
|
447
|
-
Classic.prototype.reduce = cReduce;
|
|
448
|
-
Classic.prototype.mulTo = cMulTo;
|
|
449
|
-
Classic.prototype.sqrTo = cSqrTo;
|
|
450
|
-
function bnpInvDigit() {
|
|
451
|
-
if (this.t < 1) return 0;
|
|
452
|
-
var a = this[0];
|
|
453
|
-
if ((a & 1) == 0) return 0;
|
|
454
|
-
var b = a & 3,
|
|
455
|
-
b = b * (2 - (a & 15) * b) & 15,
|
|
456
|
-
b = b * (2 - (a & 255) * b) & 255,
|
|
457
|
-
b = b * (2 - ((a & 65535) * b & 65535)) & 65535,
|
|
458
|
-
b = b * (2 - a * b % this.DV) % this.DV;
|
|
459
|
-
return b > 0 ? this.DV - b : -b;
|
|
460
|
-
}
|
|
461
|
-
function Montgomery(a) {
|
|
462
|
-
this.m = a;
|
|
463
|
-
this.mp = a.invDigit();
|
|
464
|
-
this.mpl = this.mp & 32767;
|
|
465
|
-
this.mph = this.mp >> 15;
|
|
466
|
-
this.um = (1 << a.DB - 15) - 1;
|
|
467
|
-
this.mt2 = 2 * a.t;
|
|
468
|
-
}
|
|
469
|
-
function montConvert(a) {
|
|
470
|
-
var b = nbi();
|
|
471
|
-
a.abs().dlShiftTo(this.m.t, b);
|
|
472
|
-
b.divRemTo(this.m, null, b);
|
|
473
|
-
a.s < 0 && b.compareTo(BigInteger.ZERO) > 0 && this.m.subTo(b, b);
|
|
474
|
-
return b;
|
|
475
|
-
}
|
|
476
|
-
function montRevert(a) {
|
|
477
|
-
var b = nbi();
|
|
478
|
-
a.copyTo(b);
|
|
479
|
-
this.reduce(b);
|
|
480
|
-
return b;
|
|
481
|
-
}
|
|
482
|
-
function montReduce(a) {
|
|
483
|
-
for (; a.t <= this.mt2;) a[a.t++] = 0;
|
|
484
|
-
for (var b = 0; b < this.m.t; ++b) {
|
|
485
|
-
var c = a[b] & 32767,
|
|
486
|
-
d = c * this.mpl + ((c * this.mph + (a[b] >> 15) * this.mpl & this.um) << 15) & a.DM,
|
|
487
|
-
c = b + this.m.t;
|
|
488
|
-
for (a[c] += this.m.am(0, d, a, b, 0, this.m.t); a[c] >= a.DV;) a[c] -= a.DV, a[++c]++;
|
|
489
|
-
}
|
|
490
|
-
a.clamp();
|
|
491
|
-
a.drShiftTo(this.m.t, a);
|
|
492
|
-
a.compareTo(this.m) >= 0 && a.subTo(this.m, a);
|
|
493
|
-
}
|
|
494
|
-
function montSqrTo(a, b) {
|
|
495
|
-
a.squareTo(b);
|
|
496
|
-
this.reduce(b);
|
|
497
|
-
}
|
|
498
|
-
function montMulTo(a, b, c) {
|
|
499
|
-
a.multiplyTo(b, c);
|
|
500
|
-
this.reduce(c);
|
|
501
|
-
}
|
|
502
|
-
Montgomery.prototype.convert = montConvert;
|
|
503
|
-
Montgomery.prototype.revert = montRevert;
|
|
504
|
-
Montgomery.prototype.reduce = montReduce;
|
|
505
|
-
Montgomery.prototype.mulTo = montMulTo;
|
|
506
|
-
Montgomery.prototype.sqrTo = montSqrTo;
|
|
507
|
-
function bnpIsEven() {
|
|
508
|
-
return (this.t > 0 ? this[0] & 1 : this.s) == 0;
|
|
509
|
-
}
|
|
510
|
-
function bnpExp(a, b) {
|
|
511
|
-
if (a > 4294967295 || a < 1) return BigInteger.ONE;
|
|
512
|
-
var c = nbi(),
|
|
513
|
-
d = nbi(),
|
|
514
|
-
e = b.convert(this),
|
|
515
|
-
g = nbits(a) - 1;
|
|
516
|
-
for (e.copyTo(c); --g >= 0;) if (b.sqrTo(c, d), (a & 1 << g) > 0) b.mulTo(d, e, c);else var h = c,
|
|
517
|
-
c = d,
|
|
518
|
-
d = h;
|
|
519
|
-
return b.revert(c);
|
|
520
|
-
}
|
|
521
|
-
function bnModPowInt(a, b) {
|
|
522
|
-
var c;
|
|
523
|
-
c = a < 256 || b.isEven() ? new Classic(b) : new Montgomery(b);
|
|
524
|
-
return this.exp(a, c);
|
|
525
|
-
}
|
|
526
|
-
BigInteger.prototype.copyTo = bnpCopyTo;
|
|
527
|
-
BigInteger.prototype.fromInt = bnpFromInt;
|
|
528
|
-
BigInteger.prototype.fromString = bnpFromString;
|
|
529
|
-
BigInteger.prototype.clamp = bnpClamp;
|
|
530
|
-
BigInteger.prototype.dlShiftTo = bnpDLShiftTo;
|
|
531
|
-
BigInteger.prototype.drShiftTo = bnpDRShiftTo;
|
|
532
|
-
BigInteger.prototype.lShiftTo = bnpLShiftTo;
|
|
533
|
-
BigInteger.prototype.rShiftTo = bnpRShiftTo;
|
|
534
|
-
BigInteger.prototype.subTo = bnpSubTo;
|
|
535
|
-
BigInteger.prototype.multiplyTo = bnpMultiplyTo;
|
|
536
|
-
BigInteger.prototype.squareTo = bnpSquareTo;
|
|
537
|
-
BigInteger.prototype.divRemTo = bnpDivRemTo;
|
|
538
|
-
BigInteger.prototype.invDigit = bnpInvDigit;
|
|
539
|
-
BigInteger.prototype.isEven = bnpIsEven;
|
|
540
|
-
BigInteger.prototype.exp = bnpExp;
|
|
541
|
-
BigInteger.prototype.toString = bnToString;
|
|
542
|
-
BigInteger.prototype.negate = bnNegate;
|
|
543
|
-
BigInteger.prototype.abs = bnAbs;
|
|
544
|
-
BigInteger.prototype.compareTo = bnCompareTo;
|
|
545
|
-
BigInteger.prototype.bitLength = bnBitLength;
|
|
546
|
-
BigInteger.prototype.mod = bnMod;
|
|
547
|
-
BigInteger.prototype.modPowInt = bnModPowInt;
|
|
548
|
-
BigInteger.ZERO = nbv(0);
|
|
549
|
-
BigInteger.ONE = nbv(1);
|
|
550
|
-
function bnClone() {
|
|
551
|
-
var a = nbi();
|
|
552
|
-
this.copyTo(a);
|
|
553
|
-
return a;
|
|
554
|
-
}
|
|
555
|
-
function bnIntValue() {
|
|
556
|
-
if (this.s < 0) {
|
|
557
|
-
if (this.t == 1) return this[0] - this.DV;else {
|
|
558
|
-
if (this.t == 0) return -1;
|
|
559
|
-
}
|
|
560
|
-
} else if (this.t == 1) return this[0];else if (this.t == 0) return 0;
|
|
561
|
-
return (this[1] & (1 << 32 - this.DB) - 1) << this.DB | this[0];
|
|
562
|
-
}
|
|
563
|
-
function bnByteValue() {
|
|
564
|
-
return this.t == 0 ? this.s : this[0] << 24 >> 24;
|
|
565
|
-
}
|
|
566
|
-
function bnShortValue() {
|
|
567
|
-
return this.t == 0 ? this.s : this[0] << 16 >> 16;
|
|
568
|
-
}
|
|
569
|
-
function bnpChunkSize(a) {
|
|
570
|
-
return Math.floor(Math.LN2 * this.DB / Math.log(a));
|
|
571
|
-
}
|
|
572
|
-
function bnSigNum() {
|
|
573
|
-
return this.s < 0 ? -1 : this.t <= 0 || this.t == 1 && this[0] <= 0 ? 0 : 1;
|
|
574
|
-
}
|
|
575
|
-
function bnpToRadix(a) {
|
|
576
|
-
a == null && (a = 10);
|
|
577
|
-
if (this.signum() == 0 || a < 2 || a > 36) return "0";
|
|
578
|
-
var b = this.chunkSize(a),
|
|
579
|
-
b = Math.pow(a, b),
|
|
580
|
-
c = nbv(b),
|
|
581
|
-
d = nbi(),
|
|
582
|
-
e = nbi(),
|
|
583
|
-
g = "";
|
|
584
|
-
for (this.divRemTo(c, d, e); d.signum() > 0;) g = (b + e.intValue()).toString(a).substr(1) + g, d.divRemTo(c, d, e);
|
|
585
|
-
return e.intValue().toString(a) + g;
|
|
586
|
-
}
|
|
587
|
-
function bnpFromRadix(a, b) {
|
|
588
|
-
this.fromInt(0);
|
|
589
|
-
b == null && (b = 10);
|
|
590
|
-
for (var c = this.chunkSize(b), d = Math.pow(b, c), e = !1, g = 0, h = 0, f = 0; f < a.length; ++f) {
|
|
591
|
-
var o = intAt(a, f);
|
|
592
|
-
o < 0 ? a.charAt(f) == "-" && this.signum() == 0 && (e = !0) : (h = b * h + o, ++g >= c && (this.dMultiply(d), this.dAddOffset(h, 0), h = g = 0));
|
|
593
|
-
}
|
|
594
|
-
g > 0 && (this.dMultiply(Math.pow(b, g)), this.dAddOffset(h, 0));
|
|
595
|
-
e && BigInteger.ZERO.subTo(this, this);
|
|
596
|
-
}
|
|
597
|
-
function bnpFromNumber(a, b, c) {
|
|
598
|
-
if ("number" == typeof b) {
|
|
599
|
-
if (a < 2) this.fromInt(1);else {
|
|
600
|
-
this.fromNumber(a, c);
|
|
601
|
-
this.testBit(a - 1) || this.bitwiseTo(BigInteger.ONE.shiftLeft(a - 1), op_or, this);
|
|
602
|
-
for (this.isEven() && this.dAddOffset(1, 0); !this.isProbablePrime(b);) this.dAddOffset(2, 0), this.bitLength() > a && this.subTo(BigInteger.ONE.shiftLeft(a - 1), this);
|
|
603
|
-
}
|
|
604
|
-
} else {
|
|
605
|
-
var c = [],
|
|
606
|
-
d = a & 7;
|
|
607
|
-
c.length = (a >> 3) + 1;
|
|
608
|
-
b.nextBytes(c);
|
|
609
|
-
d > 0 ? c[0] &= (1 << d) - 1 : c[0] = 0;
|
|
610
|
-
this.fromString(c, 256);
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
function bnToByteArray() {
|
|
614
|
-
var a = this.t,
|
|
615
|
-
b = [];
|
|
616
|
-
b[0] = this.s;
|
|
617
|
-
var c = this.DB - a * this.DB % 8,
|
|
618
|
-
d,
|
|
619
|
-
e = 0;
|
|
620
|
-
if (a-- > 0) {
|
|
621
|
-
if (c < this.DB && (d = this[a] >> c) != (this.s & this.DM) >> c) b[e++] = d | this.s << this.DB - c;
|
|
622
|
-
for (; a >= 0;) if (c < 8 ? (d = (this[a] & (1 << c) - 1) << 8 - c, d |= this[--a] >> (c += this.DB - 8)) : (d = this[a] >> (c -= 8) & 255, c <= 0 && (c += this.DB, --a)), (d & 128) != 0 && (d |= -256), e == 0 && (this.s & 128) != (d & 128) && ++e, e > 0 || d != this.s) b[e++] = d;
|
|
623
|
-
}
|
|
624
|
-
return b;
|
|
625
|
-
}
|
|
626
|
-
function bnEquals(a) {
|
|
627
|
-
return this.compareTo(a) == 0;
|
|
628
|
-
}
|
|
629
|
-
function bnMin(a) {
|
|
630
|
-
return this.compareTo(a) < 0 ? this : a;
|
|
631
|
-
}
|
|
632
|
-
function bnMax(a) {
|
|
633
|
-
return this.compareTo(a) > 0 ? this : a;
|
|
634
|
-
}
|
|
635
|
-
function bnpBitwiseTo(a, b, c) {
|
|
636
|
-
var d,
|
|
637
|
-
e,
|
|
638
|
-
g = Math.min(a.t, this.t);
|
|
639
|
-
for (d = 0; d < g; ++d) c[d] = b(this[d], a[d]);
|
|
640
|
-
if (a.t < this.t) {
|
|
641
|
-
e = a.s & this.DM;
|
|
642
|
-
for (d = g; d < this.t; ++d) c[d] = b(this[d], e);
|
|
643
|
-
c.t = this.t;
|
|
644
|
-
} else {
|
|
645
|
-
e = this.s & this.DM;
|
|
646
|
-
for (d = g; d < a.t; ++d) c[d] = b(e, a[d]);
|
|
647
|
-
c.t = a.t;
|
|
648
|
-
}
|
|
649
|
-
c.s = b(this.s, a.s);
|
|
650
|
-
c.clamp();
|
|
651
|
-
}
|
|
652
|
-
function op_and(a, b) {
|
|
653
|
-
return a & b;
|
|
654
|
-
}
|
|
655
|
-
function bnAnd(a) {
|
|
656
|
-
var b = nbi();
|
|
657
|
-
this.bitwiseTo(a, op_and, b);
|
|
658
|
-
return b;
|
|
659
|
-
}
|
|
660
|
-
function op_or(a, b) {
|
|
661
|
-
return a | b;
|
|
662
|
-
}
|
|
663
|
-
function bnOr(a) {
|
|
664
|
-
var b = nbi();
|
|
665
|
-
this.bitwiseTo(a, op_or, b);
|
|
666
|
-
return b;
|
|
667
|
-
}
|
|
668
|
-
function op_xor(a, b) {
|
|
669
|
-
return a ^ b;
|
|
670
|
-
}
|
|
671
|
-
function bnXor(a) {
|
|
672
|
-
var b = nbi();
|
|
673
|
-
this.bitwiseTo(a, op_xor, b);
|
|
674
|
-
return b;
|
|
675
|
-
}
|
|
676
|
-
function op_andnot(a, b) {
|
|
677
|
-
return a & ~b;
|
|
678
|
-
}
|
|
679
|
-
function bnAndNot(a) {
|
|
680
|
-
var b = nbi();
|
|
681
|
-
this.bitwiseTo(a, op_andnot, b);
|
|
682
|
-
return b;
|
|
683
|
-
}
|
|
684
|
-
function bnNot() {
|
|
685
|
-
for (var a = nbi(), b = 0; b < this.t; ++b) a[b] = this.DM & ~this[b];
|
|
686
|
-
a.t = this.t;
|
|
687
|
-
a.s = ~this.s;
|
|
688
|
-
return a;
|
|
689
|
-
}
|
|
690
|
-
function bnShiftLeft(a) {
|
|
691
|
-
var b = nbi();
|
|
692
|
-
a < 0 ? this.rShiftTo(-a, b) : this.lShiftTo(a, b);
|
|
693
|
-
return b;
|
|
694
|
-
}
|
|
695
|
-
function bnShiftRight(a) {
|
|
696
|
-
var b = nbi();
|
|
697
|
-
a < 0 ? this.lShiftTo(-a, b) : this.rShiftTo(a, b);
|
|
698
|
-
return b;
|
|
699
|
-
}
|
|
700
|
-
function lbit(a) {
|
|
701
|
-
if (a == 0) return -1;
|
|
702
|
-
var b = 0;
|
|
703
|
-
(a & 65535) == 0 && (a >>= 16, b += 16);
|
|
704
|
-
(a & 255) == 0 && (a >>= 8, b += 8);
|
|
705
|
-
(a & 15) == 0 && (a >>= 4, b += 4);
|
|
706
|
-
(a & 3) == 0 && (a >>= 2, b += 2);
|
|
707
|
-
(a & 1) == 0 && ++b;
|
|
708
|
-
return b;
|
|
709
|
-
}
|
|
710
|
-
function bnGetLowestSetBit() {
|
|
711
|
-
for (var a = 0; a < this.t; ++a) if (this[a] != 0) return a * this.DB + lbit(this[a]);
|
|
712
|
-
return this.s < 0 ? this.t * this.DB : -1;
|
|
713
|
-
}
|
|
714
|
-
function cbit(a) {
|
|
715
|
-
for (var b = 0; a != 0;) a &= a - 1, ++b;
|
|
716
|
-
return b;
|
|
717
|
-
}
|
|
718
|
-
function bnBitCount() {
|
|
719
|
-
for (var a = 0, b = this.s & this.DM, c = 0; c < this.t; ++c) a += cbit(this[c] ^ b);
|
|
720
|
-
return a;
|
|
721
|
-
}
|
|
722
|
-
function bnTestBit(a) {
|
|
723
|
-
var b = Math.floor(a / this.DB);
|
|
724
|
-
return b >= this.t ? this.s != 0 : (this[b] & 1 << a % this.DB) != 0;
|
|
725
|
-
}
|
|
726
|
-
function bnpChangeBit(a, b) {
|
|
727
|
-
var c = BigInteger.ONE.shiftLeft(a);
|
|
728
|
-
this.bitwiseTo(c, b, c);
|
|
729
|
-
return c;
|
|
730
|
-
}
|
|
731
|
-
function bnSetBit(a) {
|
|
732
|
-
return this.changeBit(a, op_or);
|
|
733
|
-
}
|
|
734
|
-
function bnClearBit(a) {
|
|
735
|
-
return this.changeBit(a, op_andnot);
|
|
736
|
-
}
|
|
737
|
-
function bnFlipBit(a) {
|
|
738
|
-
return this.changeBit(a, op_xor);
|
|
739
|
-
}
|
|
740
|
-
function bnpAddTo(a, b) {
|
|
741
|
-
for (var c = 0, d = 0, e = Math.min(a.t, this.t); c < e;) d += this[c] + a[c], b[c++] = d & this.DM, d >>= this.DB;
|
|
742
|
-
if (a.t < this.t) {
|
|
743
|
-
for (d += a.s; c < this.t;) d += this[c], b[c++] = d & this.DM, d >>= this.DB;
|
|
744
|
-
d += this.s;
|
|
745
|
-
} else {
|
|
746
|
-
for (d += this.s; c < a.t;) d += a[c], b[c++] = d & this.DM, d >>= this.DB;
|
|
747
|
-
d += a.s;
|
|
748
|
-
}
|
|
749
|
-
b.s = d < 0 ? -1 : 0;
|
|
750
|
-
d > 0 ? b[c++] = d : d < -1 && (b[c++] = this.DV + d);
|
|
751
|
-
b.t = c;
|
|
752
|
-
b.clamp();
|
|
753
|
-
}
|
|
754
|
-
function bnAdd(a) {
|
|
755
|
-
var b = nbi();
|
|
756
|
-
this.addTo(a, b);
|
|
757
|
-
return b;
|
|
758
|
-
}
|
|
759
|
-
function bnSubtract(a) {
|
|
760
|
-
var b = nbi();
|
|
761
|
-
this.subTo(a, b);
|
|
762
|
-
return b;
|
|
763
|
-
}
|
|
764
|
-
function bnMultiply(a) {
|
|
765
|
-
var b = nbi();
|
|
766
|
-
this.multiplyTo(a, b);
|
|
767
|
-
return b;
|
|
768
|
-
}
|
|
769
|
-
function bnSquare() {
|
|
770
|
-
var a = nbi();
|
|
771
|
-
this.squareTo(a);
|
|
772
|
-
return a;
|
|
773
|
-
}
|
|
774
|
-
function bnDivide(a) {
|
|
775
|
-
var b = nbi();
|
|
776
|
-
this.divRemTo(a, b, null);
|
|
777
|
-
return b;
|
|
778
|
-
}
|
|
779
|
-
function bnRemainder(a) {
|
|
780
|
-
var b = nbi();
|
|
781
|
-
this.divRemTo(a, null, b);
|
|
782
|
-
return b;
|
|
783
|
-
}
|
|
784
|
-
function bnDivideAndRemainder(a) {
|
|
785
|
-
var b = nbi(),
|
|
786
|
-
c = nbi();
|
|
787
|
-
this.divRemTo(a, b, c);
|
|
788
|
-
return [b, c];
|
|
789
|
-
}
|
|
790
|
-
function bnpDMultiply(a) {
|
|
791
|
-
this[this.t] = this.am(0, a - 1, this, 0, 0, this.t);
|
|
792
|
-
++this.t;
|
|
793
|
-
this.clamp();
|
|
794
|
-
}
|
|
795
|
-
function bnpDAddOffset(a, b) {
|
|
796
|
-
if (a != 0) {
|
|
797
|
-
for (; this.t <= b;) this[this.t++] = 0;
|
|
798
|
-
for (this[b] += a; this[b] >= this.DV;) this[b] -= this.DV, ++b >= this.t && (this[this.t++] = 0), ++this[b];
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
function NullExp() {}
|
|
802
|
-
function nNop(a) {
|
|
803
|
-
return a;
|
|
804
|
-
}
|
|
805
|
-
function nMulTo(a, b, c) {
|
|
806
|
-
a.multiplyTo(b, c);
|
|
807
|
-
}
|
|
808
|
-
function nSqrTo(a, b) {
|
|
809
|
-
a.squareTo(b);
|
|
810
|
-
}
|
|
811
|
-
NullExp.prototype.convert = nNop;
|
|
812
|
-
NullExp.prototype.revert = nNop;
|
|
813
|
-
NullExp.prototype.mulTo = nMulTo;
|
|
814
|
-
NullExp.prototype.sqrTo = nSqrTo;
|
|
815
|
-
function bnPow(a) {
|
|
816
|
-
return this.exp(a, new NullExp());
|
|
817
|
-
}
|
|
818
|
-
function bnpMultiplyLowerTo(a, b, c) {
|
|
819
|
-
var d = Math.min(this.t + a.t, b);
|
|
820
|
-
c.s = 0;
|
|
821
|
-
for (c.t = d; d > 0;) c[--d] = 0;
|
|
822
|
-
var e;
|
|
823
|
-
for (e = c.t - this.t; d < e; ++d) c[d + this.t] = this.am(0, a[d], c, d, 0, this.t);
|
|
824
|
-
for (e = Math.min(a.t, b); d < e; ++d) this.am(0, a[d], c, d, 0, b - d);
|
|
825
|
-
c.clamp();
|
|
826
|
-
}
|
|
827
|
-
function bnpMultiplyUpperTo(a, b, c) {
|
|
828
|
-
--b;
|
|
829
|
-
var d = c.t = this.t + a.t - b;
|
|
830
|
-
for (c.s = 0; --d >= 0;) c[d] = 0;
|
|
831
|
-
for (d = Math.max(b - this.t, 0); d < a.t; ++d) c[this.t + d - b] = this.am(b - d, a[d], c, 0, 0, this.t + d - b);
|
|
832
|
-
c.clamp();
|
|
833
|
-
c.drShiftTo(1, c);
|
|
834
|
-
}
|
|
835
|
-
function Barrett(a) {
|
|
836
|
-
this.r2 = nbi();
|
|
837
|
-
this.q3 = nbi();
|
|
838
|
-
BigInteger.ONE.dlShiftTo(2 * a.t, this.r2);
|
|
839
|
-
this.mu = this.r2.divide(a);
|
|
840
|
-
this.m = a;
|
|
841
|
-
}
|
|
842
|
-
function barrettConvert(a) {
|
|
843
|
-
if (a.s < 0 || a.t > 2 * this.m.t) return a.mod(this.m);else if (a.compareTo(this.m) < 0) return a;else {
|
|
844
|
-
var b = nbi();
|
|
845
|
-
a.copyTo(b);
|
|
846
|
-
this.reduce(b);
|
|
847
|
-
return b;
|
|
848
|
-
}
|
|
849
|
-
}
|
|
850
|
-
function barrettRevert(a) {
|
|
851
|
-
return a;
|
|
852
|
-
}
|
|
853
|
-
function barrettReduce(a) {
|
|
854
|
-
a.drShiftTo(this.m.t - 1, this.r2);
|
|
855
|
-
if (a.t > this.m.t + 1) a.t = this.m.t + 1, a.clamp();
|
|
856
|
-
this.mu.multiplyUpperTo(this.r2, this.m.t + 1, this.q3);
|
|
857
|
-
for (this.m.multiplyLowerTo(this.q3, this.m.t + 1, this.r2); a.compareTo(this.r2) < 0;) a.dAddOffset(1, this.m.t + 1);
|
|
858
|
-
for (a.subTo(this.r2, a); a.compareTo(this.m) >= 0;) a.subTo(this.m, a);
|
|
859
|
-
}
|
|
860
|
-
function barrettSqrTo(a, b) {
|
|
861
|
-
a.squareTo(b);
|
|
862
|
-
this.reduce(b);
|
|
863
|
-
}
|
|
864
|
-
function barrettMulTo(a, b, c) {
|
|
865
|
-
a.multiplyTo(b, c);
|
|
866
|
-
this.reduce(c);
|
|
867
|
-
}
|
|
868
|
-
Barrett.prototype.convert = barrettConvert;
|
|
869
|
-
Barrett.prototype.revert = barrettRevert;
|
|
870
|
-
Barrett.prototype.reduce = barrettReduce;
|
|
871
|
-
Barrett.prototype.mulTo = barrettMulTo;
|
|
872
|
-
Barrett.prototype.sqrTo = barrettSqrTo;
|
|
873
|
-
function bnModPow(a, b) {
|
|
874
|
-
var c = a.bitLength(),
|
|
875
|
-
d,
|
|
876
|
-
e = nbv(1),
|
|
877
|
-
g;
|
|
878
|
-
if (c <= 0) return e;else d = c < 18 ? 1 : c < 48 ? 3 : c < 144 ? 4 : c < 768 ? 5 : 6;
|
|
879
|
-
g = c < 8 ? new Classic(b) : b.isEven() ? new Barrett(b) : new Montgomery(b);
|
|
880
|
-
var h = [],
|
|
881
|
-
f = 3,
|
|
882
|
-
o = d - 1,
|
|
883
|
-
p = (1 << d) - 1;
|
|
884
|
-
h[1] = g.convert(this);
|
|
885
|
-
if (d > 1) {
|
|
886
|
-
c = nbi();
|
|
887
|
-
for (g.sqrTo(h[1], c); f <= p;) h[f] = nbi(), g.mulTo(c, h[f - 2], h[f]), f += 2;
|
|
888
|
-
}
|
|
889
|
-
for (var q = a.t - 1, n, k = !0, j = nbi(), c = nbits(a[q]) - 1; q >= 0;) {
|
|
890
|
-
c >= o ? n = a[q] >> c - o & p : (n = (a[q] & (1 << c + 1) - 1) << o - c, q > 0 && (n |= a[q - 1] >> this.DB + c - o));
|
|
891
|
-
for (f = d; (n & 1) == 0;) n >>= 1, --f;
|
|
892
|
-
if ((c -= f) < 0) c += this.DB, --q;
|
|
893
|
-
if (k) h[n].copyTo(e), k = !1;else {
|
|
894
|
-
for (; f > 1;) g.sqrTo(e, j), g.sqrTo(j, e), f -= 2;
|
|
895
|
-
f > 0 ? g.sqrTo(e, j) : (f = e, e = j, j = f);
|
|
896
|
-
g.mulTo(j, h[n], e);
|
|
897
|
-
}
|
|
898
|
-
for (; q >= 0 && (a[q] & 1 << c) == 0;) g.sqrTo(e, j), f = e, e = j, j = f, --c < 0 && (c = this.DB - 1, --q);
|
|
899
|
-
}
|
|
900
|
-
return g.revert(e);
|
|
901
|
-
}
|
|
902
|
-
function bnGCD(a) {
|
|
903
|
-
var b = this.s < 0 ? this.negate() : this.clone(),
|
|
904
|
-
a = a.s < 0 ? a.negate() : a.clone();
|
|
905
|
-
if (b.compareTo(a) < 0) var c = b,
|
|
906
|
-
b = a,
|
|
907
|
-
a = c;
|
|
908
|
-
var c = b.getLowestSetBit(),
|
|
909
|
-
d = a.getLowestSetBit();
|
|
910
|
-
if (d < 0) return b;
|
|
911
|
-
c < d && (d = c);
|
|
912
|
-
d > 0 && (b.rShiftTo(d, b), a.rShiftTo(d, a));
|
|
913
|
-
for (; b.signum() > 0;) (c = b.getLowestSetBit()) > 0 && b.rShiftTo(c, b), (c = a.getLowestSetBit()) > 0 && a.rShiftTo(c, a), b.compareTo(a) >= 0 ? (b.subTo(a, b), b.rShiftTo(1, b)) : (a.subTo(b, a), a.rShiftTo(1, a));
|
|
914
|
-
d > 0 && a.lShiftTo(d, a);
|
|
915
|
-
return a;
|
|
916
|
-
}
|
|
917
|
-
function bnpModInt(a) {
|
|
918
|
-
if (a <= 0) return 0;
|
|
919
|
-
var b = this.DV % a,
|
|
920
|
-
c = this.s < 0 ? a - 1 : 0;
|
|
921
|
-
if (this.t > 0) if (b == 0) c = this[0] % a;else for (var d = this.t - 1; d >= 0; --d) c = (b * c + this[d]) % a;
|
|
922
|
-
return c;
|
|
923
|
-
}
|
|
924
|
-
function bnModInverse(a) {
|
|
925
|
-
var b = a.isEven();
|
|
926
|
-
if (this.isEven() && b || a.signum() == 0) return BigInteger.ZERO;
|
|
927
|
-
for (var c = a.clone(), d = this.clone(), e = nbv(1), g = nbv(0), h = nbv(0), f = nbv(1); c.signum() != 0;) {
|
|
928
|
-
for (; c.isEven();) {
|
|
929
|
-
c.rShiftTo(1, c);
|
|
930
|
-
if (b) {
|
|
931
|
-
if (!e.isEven() || !g.isEven()) e.addTo(this, e), g.subTo(a, g);
|
|
932
|
-
e.rShiftTo(1, e);
|
|
933
|
-
} else g.isEven() || g.subTo(a, g);
|
|
934
|
-
g.rShiftTo(1, g);
|
|
935
|
-
}
|
|
936
|
-
for (; d.isEven();) {
|
|
937
|
-
d.rShiftTo(1, d);
|
|
938
|
-
if (b) {
|
|
939
|
-
if (!h.isEven() || !f.isEven()) h.addTo(this, h), f.subTo(a, f);
|
|
940
|
-
h.rShiftTo(1, h);
|
|
941
|
-
} else f.isEven() || f.subTo(a, f);
|
|
942
|
-
f.rShiftTo(1, f);
|
|
943
|
-
}
|
|
944
|
-
c.compareTo(d) >= 0 ? (c.subTo(d, c), b && e.subTo(h, e), g.subTo(f, g)) : (d.subTo(c, d), b && h.subTo(e, h), f.subTo(g, f));
|
|
945
|
-
}
|
|
946
|
-
if (d.compareTo(BigInteger.ONE) != 0) return BigInteger.ZERO;
|
|
947
|
-
if (f.compareTo(a) >= 0) return f.subtract(a);
|
|
948
|
-
if (f.signum() < 0) f.addTo(a, f);else return f;
|
|
949
|
-
return f.signum() < 0 ? f.add(a) : f;
|
|
950
|
-
}
|
|
951
|
-
var lowprimes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997],
|
|
952
|
-
lplim = 67108864 / lowprimes[lowprimes.length - 1];
|
|
953
|
-
function bnIsProbablePrime(a) {
|
|
954
|
-
var b,
|
|
955
|
-
c = this.abs();
|
|
956
|
-
if (c.t == 1 && c[0] <= lowprimes[lowprimes.length - 1]) {
|
|
957
|
-
for (b = 0; b < lowprimes.length; ++b) if (c[0] == lowprimes[b]) return !0;
|
|
958
|
-
return !1;
|
|
959
|
-
}
|
|
960
|
-
if (c.isEven()) return !1;
|
|
961
|
-
for (b = 1; b < lowprimes.length;) {
|
|
962
|
-
for (var d = lowprimes[b], e = b + 1; e < lowprimes.length && d < lplim;) d *= lowprimes[e++];
|
|
963
|
-
for (d = c.modInt(d); b < e;) if (d % lowprimes[b++] == 0) return !1;
|
|
964
|
-
}
|
|
965
|
-
return c.millerRabin(a);
|
|
966
|
-
}
|
|
967
|
-
function bnpMillerRabin(a) {
|
|
968
|
-
var b = this.subtract(BigInteger.ONE),
|
|
969
|
-
c = b.getLowestSetBit();
|
|
970
|
-
if (c <= 0) return !1;
|
|
971
|
-
var d = b.shiftRight(c),
|
|
972
|
-
a = a + 1 >> 1;
|
|
973
|
-
if (a > lowprimes.length) a = lowprimes.length;
|
|
974
|
-
for (var e = nbi(), g = 0; g < a; ++g) {
|
|
975
|
-
e.fromInt(lowprimes[Math.floor(Math.random() * lowprimes.length)]);
|
|
976
|
-
var h = e.modPow(d, this);
|
|
977
|
-
if (h.compareTo(BigInteger.ONE) != 0 && h.compareTo(b) != 0) {
|
|
978
|
-
for (var f = 1; f++ < c && h.compareTo(b) != 0;) if (h = h.modPowInt(2, this), h.compareTo(BigInteger.ONE) == 0) return !1;
|
|
979
|
-
if (h.compareTo(b) != 0) return !1;
|
|
980
|
-
}
|
|
981
|
-
}
|
|
982
|
-
return !0;
|
|
983
|
-
}
|
|
984
|
-
BigInteger.prototype.chunkSize = bnpChunkSize;
|
|
985
|
-
BigInteger.prototype.toRadix = bnpToRadix;
|
|
986
|
-
BigInteger.prototype.fromRadix = bnpFromRadix;
|
|
987
|
-
BigInteger.prototype.fromNumber = bnpFromNumber;
|
|
988
|
-
BigInteger.prototype.bitwiseTo = bnpBitwiseTo;
|
|
989
|
-
BigInteger.prototype.changeBit = bnpChangeBit;
|
|
990
|
-
BigInteger.prototype.addTo = bnpAddTo;
|
|
991
|
-
BigInteger.prototype.dMultiply = bnpDMultiply;
|
|
992
|
-
BigInteger.prototype.dAddOffset = bnpDAddOffset;
|
|
993
|
-
BigInteger.prototype.multiplyLowerTo = bnpMultiplyLowerTo;
|
|
994
|
-
BigInteger.prototype.multiplyUpperTo = bnpMultiplyUpperTo;
|
|
995
|
-
BigInteger.prototype.modInt = bnpModInt;
|
|
996
|
-
BigInteger.prototype.millerRabin = bnpMillerRabin;
|
|
997
|
-
BigInteger.prototype.clone = bnClone;
|
|
998
|
-
BigInteger.prototype.intValue = bnIntValue;
|
|
999
|
-
BigInteger.prototype.byteValue = bnByteValue;
|
|
1000
|
-
BigInteger.prototype.shortValue = bnShortValue;
|
|
1001
|
-
BigInteger.prototype.signum = bnSigNum;
|
|
1002
|
-
BigInteger.prototype.toByteArray = bnToByteArray;
|
|
1003
|
-
BigInteger.prototype.equals = bnEquals;
|
|
1004
|
-
BigInteger.prototype.min = bnMin;
|
|
1005
|
-
BigInteger.prototype.max = bnMax;
|
|
1006
|
-
BigInteger.prototype.and = bnAnd;
|
|
1007
|
-
BigInteger.prototype.or = bnOr;
|
|
1008
|
-
BigInteger.prototype.xor = bnXor;
|
|
1009
|
-
BigInteger.prototype.andNot = bnAndNot;
|
|
1010
|
-
BigInteger.prototype.not = bnNot;
|
|
1011
|
-
BigInteger.prototype.shiftLeft = bnShiftLeft;
|
|
1012
|
-
BigInteger.prototype.shiftRight = bnShiftRight;
|
|
1013
|
-
BigInteger.prototype.getLowestSetBit = bnGetLowestSetBit;
|
|
1014
|
-
BigInteger.prototype.bitCount = bnBitCount;
|
|
1015
|
-
BigInteger.prototype.testBit = bnTestBit;
|
|
1016
|
-
BigInteger.prototype.setBit = bnSetBit;
|
|
1017
|
-
BigInteger.prototype.clearBit = bnClearBit;
|
|
1018
|
-
BigInteger.prototype.flipBit = bnFlipBit;
|
|
1019
|
-
BigInteger.prototype.add = bnAdd;
|
|
1020
|
-
BigInteger.prototype.subtract = bnSubtract;
|
|
1021
|
-
BigInteger.prototype.multiply = bnMultiply;
|
|
1022
|
-
BigInteger.prototype.divide = bnDivide;
|
|
1023
|
-
BigInteger.prototype.remainder = bnRemainder;
|
|
1024
|
-
BigInteger.prototype.divideAndRemainder = bnDivideAndRemainder;
|
|
1025
|
-
BigInteger.prototype.modPow = bnModPow;
|
|
1026
|
-
BigInteger.prototype.modInverse = bnModInverse;
|
|
1027
|
-
BigInteger.prototype.pow = bnPow;
|
|
1028
|
-
BigInteger.prototype.gcd = bnGCD;
|
|
1029
|
-
BigInteger.prototype.isProbablePrime = bnIsProbablePrime;
|
|
1030
|
-
BigInteger.prototype.square = bnSquare;
|
|
1031
|
-
(function (a, b, c, d, e, g, h) {
|
|
1032
|
-
function f(a) {
|
|
1033
|
-
var b,
|
|
1034
|
-
d,
|
|
1035
|
-
e = this,
|
|
1036
|
-
g = a.length,
|
|
1037
|
-
f = 0,
|
|
1038
|
-
h = e.i = e.j = e.m = 0;
|
|
1039
|
-
e.S = [];
|
|
1040
|
-
e.c = [];
|
|
1041
|
-
for (g || (a = [g++]); f < c;) e.S[f] = f++;
|
|
1042
|
-
for (f = 0; f < c; f++) b = e.S[f], h = h + b + a[f % g] & c - 1, d = e.S[h], e.S[f] = d, e.S[h] = b;
|
|
1043
|
-
e.g = function (a) {
|
|
1044
|
-
var b = e.S,
|
|
1045
|
-
d = e.i + 1 & c - 1,
|
|
1046
|
-
g = b[d],
|
|
1047
|
-
f = e.j + g & c - 1,
|
|
1048
|
-
h = b[f];
|
|
1049
|
-
b[d] = h;
|
|
1050
|
-
b[f] = g;
|
|
1051
|
-
for (var k = b[g + h & c - 1]; --a;) d = d + 1 & c - 1, g = b[d], f = f + g & c - 1, h = b[f], b[d] = h, b[f] = g, k = k * c + b[g + h & c - 1];
|
|
1052
|
-
e.i = d;
|
|
1053
|
-
e.j = f;
|
|
1054
|
-
return k;
|
|
1055
|
-
};
|
|
1056
|
-
e.g(c);
|
|
1057
|
-
}
|
|
1058
|
-
function o(a, b, c, d, e) {
|
|
1059
|
-
c = [];
|
|
1060
|
-
e = typeof a;
|
|
1061
|
-
if (b && e == "object") for (d in a) if (d.indexOf("S") < 5) try {
|
|
1062
|
-
c.push(o(a[d], b - 1));
|
|
1063
|
-
} catch (g) {}
|
|
1064
|
-
return c.length ? c : a + (e != "string" ? "\x00" : "");
|
|
1065
|
-
}
|
|
1066
|
-
function p(a, b, d, e) {
|
|
1067
|
-
a += "";
|
|
1068
|
-
for (e = d = 0; e < a.length; e++) {
|
|
1069
|
-
var g = b,
|
|
1070
|
-
f = e & c - 1,
|
|
1071
|
-
h = (d ^= b[e & c - 1] * 19) + a.charCodeAt(e);
|
|
1072
|
-
g[f] = h & c - 1;
|
|
1073
|
-
}
|
|
1074
|
-
a = "";
|
|
1075
|
-
for (e in b) a += String.fromCharCode(b[e]);
|
|
1076
|
-
return a;
|
|
1077
|
-
}
|
|
1078
|
-
b.seedrandom = function (q, n) {
|
|
1079
|
-
var k = [],
|
|
1080
|
-
j,
|
|
1081
|
-
q = p(o(n ? [q, a] : arguments.length ? q : [new Date().getTime(), a, window], 3), k);
|
|
1082
|
-
j = new f(k);
|
|
1083
|
-
p(j.S, a);
|
|
1084
|
-
b.random = function () {
|
|
1085
|
-
for (var a = j.g(d), b = h, f = 0; a < e;) a = (a + f) * c, b *= c, f = j.g(1);
|
|
1086
|
-
for (; a >= g;) a /= 2, b /= 2, f >>>= 1;
|
|
1087
|
-
return (a + f) / b;
|
|
1088
|
-
};
|
|
1089
|
-
return q;
|
|
1090
|
-
};
|
|
1091
|
-
h = b.pow(c, d);
|
|
1092
|
-
e = b.pow(2, e);
|
|
1093
|
-
g = e * 2;
|
|
1094
|
-
p(b.random(), a);
|
|
1095
|
-
})([], Math, 256, 6, 52);
|
|
1096
|
-
function SeededRandom() {}
|
|
1097
|
-
function SRnextBytes(a) {
|
|
1098
|
-
var b;
|
|
1099
|
-
for (b = 0; b < a.length; b++) a[b] = Math.floor(Math.random() * 256);
|
|
1100
|
-
}
|
|
1101
|
-
SeededRandom.prototype.nextBytes = SRnextBytes;
|
|
1102
|
-
function Arcfour() {
|
|
1103
|
-
this.j = this.i = 0;
|
|
1104
|
-
this.S = [];
|
|
1105
|
-
}
|
|
1106
|
-
function ARC4init(a) {
|
|
1107
|
-
var b, c, d;
|
|
1108
|
-
for (b = 0; b < 256; ++b) this.S[b] = b;
|
|
1109
|
-
for (b = c = 0; b < 256; ++b) c = c + this.S[b] + a[b % a.length] & 255, d = this.S[b], this.S[b] = this.S[c], this.S[c] = d;
|
|
1110
|
-
this.j = this.i = 0;
|
|
1111
|
-
}
|
|
1112
|
-
function ARC4next() {
|
|
1113
|
-
var a;
|
|
1114
|
-
this.i = this.i + 1 & 255;
|
|
1115
|
-
this.j = this.j + this.S[this.i] & 255;
|
|
1116
|
-
a = this.S[this.i];
|
|
1117
|
-
this.S[this.i] = this.S[this.j];
|
|
1118
|
-
this.S[this.j] = a;
|
|
1119
|
-
return this.S[a + this.S[this.i] & 255];
|
|
1120
|
-
}
|
|
1121
|
-
Arcfour.prototype.init = ARC4init;
|
|
1122
|
-
Arcfour.prototype.next = ARC4next;
|
|
1123
|
-
function prng_newstate() {
|
|
1124
|
-
return new Arcfour();
|
|
1125
|
-
}
|
|
1126
|
-
var rng_psize = 256,
|
|
1127
|
-
rng_state,
|
|
1128
|
-
rng_pool,
|
|
1129
|
-
rng_pptr;
|
|
1130
|
-
function rng_seed_int(a) {
|
|
1131
|
-
rng_pool[rng_pptr++] ^= a & 255;
|
|
1132
|
-
rng_pool[rng_pptr++] ^= a >> 8 & 255;
|
|
1133
|
-
rng_pool[rng_pptr++] ^= a >> 16 & 255;
|
|
1134
|
-
rng_pool[rng_pptr++] ^= a >> 24 & 255;
|
|
1135
|
-
rng_pptr >= rng_psize && (rng_pptr -= rng_psize);
|
|
1136
|
-
}
|
|
1137
|
-
function rng_seed_time() {
|
|
1138
|
-
rng_seed_int(new Date().getTime());
|
|
1139
|
-
}
|
|
1140
|
-
if (rng_pool == null) {
|
|
1141
|
-
rng_pool = [];
|
|
1142
|
-
rng_pptr = 0;
|
|
1143
|
-
var t;
|
|
1144
|
-
for (; rng_pptr < rng_psize;) t = Math.floor(65536 * Math.random()), rng_pool[rng_pptr++] = t >>> 8, rng_pool[rng_pptr++] = t & 255;
|
|
1145
|
-
rng_pptr = 0;
|
|
1146
|
-
rng_seed_time();
|
|
1147
|
-
}
|
|
1148
|
-
function rng_get_byte() {
|
|
1149
|
-
if (rng_state == null) {
|
|
1150
|
-
rng_seed_time();
|
|
1151
|
-
rng_state = prng_newstate();
|
|
1152
|
-
rng_state.init(rng_pool);
|
|
1153
|
-
for (rng_pptr = 0; rng_pptr < rng_pool.length; ++rng_pptr) rng_pool[rng_pptr] = 0;
|
|
1154
|
-
rng_pptr = 0;
|
|
1155
|
-
}
|
|
1156
|
-
return rng_state.next();
|
|
1157
|
-
}
|
|
1158
|
-
function rng_get_bytes(a) {
|
|
1159
|
-
var b;
|
|
1160
|
-
for (b = 0; b < a.length; ++b) a[b] = rng_get_byte();
|
|
1161
|
-
}
|
|
1162
|
-
function SecureRandom() {}
|
|
1163
|
-
SecureRandom.prototype.nextBytes = rng_get_bytes;
|
|
1164
|
-
function SHA256(a) {
|
|
1165
|
-
function b(a, b) {
|
|
1166
|
-
var c = (a & 65535) + (b & 65535);
|
|
1167
|
-
return (a >> 16) + (b >> 16) + (c >> 16) << 16 | c & 65535;
|
|
1168
|
-
}
|
|
1169
|
-
function c(a, b) {
|
|
1170
|
-
return a >>> b | a << 32 - b;
|
|
1171
|
-
}
|
|
1172
|
-
a = function (a) {
|
|
1173
|
-
for (var a = a.replace(/\r\n/g, "\n"), b = "", c = 0; c < a.length; c++) {
|
|
1174
|
-
var h = a.charCodeAt(c);
|
|
1175
|
-
h < 128 ? b += String.fromCharCode(h) : (h > 127 && h < 2048 ? b += String.fromCharCode(h >> 6 | 192) : (b += String.fromCharCode(h >> 12 | 224), b += String.fromCharCode(h >> 6 & 63 | 128)), b += String.fromCharCode(h & 63 | 128));
|
|
1176
|
-
}
|
|
1177
|
-
return b;
|
|
1178
|
-
}(a);
|
|
1179
|
-
return function (a) {
|
|
1180
|
-
for (var b = "", c = 0; c < a.length * 4; c++) b += "0123456789abcdef".charAt(a[c >> 2] >> (3 - c % 4) * 8 + 4 & 15) + "0123456789abcdef".charAt(a[c >> 2] >> (3 - c % 4) * 8 & 15);
|
|
1181
|
-
return b;
|
|
1182
|
-
}(function (a, e) {
|
|
1183
|
-
var g = [1116352408, 1899447441, 3049323471, 3921009573, 961987163, 1508970993, 2453635748, 2870763221, 3624381080, 310598401, 607225278, 1426881987, 1925078388, 2162078206, 2614888103, 3248222580, 3835390401, 4022224774, 264347078, 604807628, 770255983, 1249150122, 1555081692, 1996064986, 2554220882, 2821834349, 2952996808, 3210313671, 3336571891, 3584528711, 113926993, 338241895, 666307205, 773529912, 1294757372, 1396182291, 1695183700, 1986661051, 2177026350, 2456956037, 2730485921, 2820302411, 3259730800, 3345764771, 3516065817, 3600352804, 4094571909, 275423344, 430227734, 506948616, 659060556, 883997877, 958139571, 1322822218, 1537002063, 1747873779, 1955562222, 2024104815, 2227730452, 2361852424, 2428436474, 2756734187, 3204031479, 3329325298],
|
|
1184
|
-
h = [1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225],
|
|
1185
|
-
f = Array(64),
|
|
1186
|
-
o,
|
|
1187
|
-
p,
|
|
1188
|
-
q,
|
|
1189
|
-
n,
|
|
1190
|
-
k,
|
|
1191
|
-
j,
|
|
1192
|
-
l,
|
|
1193
|
-
m,
|
|
1194
|
-
s,
|
|
1195
|
-
r,
|
|
1196
|
-
u,
|
|
1197
|
-
w;
|
|
1198
|
-
a[e >> 5] |= 128 << 24 - e % 32;
|
|
1199
|
-
a[(e + 64 >> 9 << 4) + 15] = e;
|
|
1200
|
-
for (s = 0; s < a.length; s += 16) {
|
|
1201
|
-
o = h[0];
|
|
1202
|
-
p = h[1];
|
|
1203
|
-
q = h[2];
|
|
1204
|
-
n = h[3];
|
|
1205
|
-
k = h[4];
|
|
1206
|
-
j = h[5];
|
|
1207
|
-
l = h[6];
|
|
1208
|
-
m = h[7];
|
|
1209
|
-
for (r = 0; r < 64; r++) f[r] = r < 16 ? a[r + s] : b(b(b(c(f[r - 2], 17) ^ c(f[r - 2], 19) ^ f[r - 2] >>> 10, f[r - 7]), c(f[r - 15], 7) ^ c(f[r - 15], 18) ^ f[r - 15] >>> 3), f[r - 16]), u = b(b(b(b(m, c(k, 6) ^ c(k, 11) ^ c(k, 25)), k & j ^ ~k & l), g[r]), f[r]), w = b(c(o, 2) ^ c(o, 13) ^ c(o, 22), o & p ^ o & q ^ p & q), m = l, l = j, j = k, k = b(n, u), n = q, q = p, p = o, o = b(u, w);
|
|
1210
|
-
h[0] = b(o, h[0]);
|
|
1211
|
-
h[1] = b(p, h[1]);
|
|
1212
|
-
h[2] = b(q, h[2]);
|
|
1213
|
-
h[3] = b(n, h[3]);
|
|
1214
|
-
h[4] = b(k, h[4]);
|
|
1215
|
-
h[5] = b(j, h[5]);
|
|
1216
|
-
h[6] = b(l, h[6]);
|
|
1217
|
-
h[7] = b(m, h[7]);
|
|
1218
|
-
}
|
|
1219
|
-
return h;
|
|
1220
|
-
}(function (a) {
|
|
1221
|
-
for (var b = [], c = 0; c < a.length * 8; c += 8) b[c >> 5] |= (a.charCodeAt(c / 8) & 255) << 24 - c % 32;
|
|
1222
|
-
return b;
|
|
1223
|
-
}(a), a.length * 8));
|
|
1224
|
-
}
|
|
1225
|
-
var sha256 = {
|
|
1226
|
-
hex: function (a) {
|
|
1227
|
-
return SHA256(a);
|
|
1228
|
-
}
|
|
1229
|
-
};
|
|
1230
|
-
function SHA1(a) {
|
|
1231
|
-
function b(a, b) {
|
|
1232
|
-
return a << b | a >>> 32 - b;
|
|
1233
|
-
}
|
|
1234
|
-
function c(a) {
|
|
1235
|
-
var b = "",
|
|
1236
|
-
c,
|
|
1237
|
-
d;
|
|
1238
|
-
for (c = 7; c >= 0; c--) d = a >>> c * 4 & 15, b += d.toString(16);
|
|
1239
|
-
return b;
|
|
1240
|
-
}
|
|
1241
|
-
var d,
|
|
1242
|
-
e,
|
|
1243
|
-
g = Array(80),
|
|
1244
|
-
h = 1732584193,
|
|
1245
|
-
f = 4023233417,
|
|
1246
|
-
o = 2562383102,
|
|
1247
|
-
p = 271733878,
|
|
1248
|
-
q = 3285377520,
|
|
1249
|
-
n,
|
|
1250
|
-
k,
|
|
1251
|
-
j,
|
|
1252
|
-
l,
|
|
1253
|
-
m,
|
|
1254
|
-
a = function (a) {
|
|
1255
|
-
for (var a = a.replace(/\r\n/g, "\n"), b = "", c = 0; c < a.length; c++) {
|
|
1256
|
-
var d = a.charCodeAt(c);
|
|
1257
|
-
d < 128 ? b += String.fromCharCode(d) : (d > 127 && d < 2048 ? b += String.fromCharCode(d >> 6 | 192) : (b += String.fromCharCode(d >> 12 | 224), b += String.fromCharCode(d >> 6 & 63 | 128)), b += String.fromCharCode(d & 63 | 128));
|
|
1258
|
-
}
|
|
1259
|
-
return b;
|
|
1260
|
-
}(a);
|
|
1261
|
-
n = a.length;
|
|
1262
|
-
var s = [];
|
|
1263
|
-
for (d = 0; d < n - 3; d += 4) e = a.charCodeAt(d) << 24 | a.charCodeAt(d + 1) << 16 | a.charCodeAt(d + 2) << 8 | a.charCodeAt(d + 3), s.push(e);
|
|
1264
|
-
switch (n % 4) {
|
|
1265
|
-
case 0:
|
|
1266
|
-
d = 2147483648;
|
|
1267
|
-
break;
|
|
1268
|
-
case 1:
|
|
1269
|
-
d = a.charCodeAt(n - 1) << 24 | 8388608;
|
|
1270
|
-
break;
|
|
1271
|
-
case 2:
|
|
1272
|
-
d = a.charCodeAt(n - 2) << 24 | a.charCodeAt(n - 1) << 16 | 32768;
|
|
1273
|
-
break;
|
|
1274
|
-
case 3:
|
|
1275
|
-
d = a.charCodeAt(n - 3) << 24 | a.charCodeAt(n - 2) << 16 | a.charCodeAt(n - 1) << 8 | 128;
|
|
1276
|
-
}
|
|
1277
|
-
for (s.push(d); s.length % 16 != 14;) s.push(0);
|
|
1278
|
-
s.push(n >>> 29);
|
|
1279
|
-
s.push(n << 3 & 4294967295);
|
|
1280
|
-
for (a = 0; a < s.length; a += 16) {
|
|
1281
|
-
for (d = 0; d < 16; d++) g[d] = s[a + d];
|
|
1282
|
-
for (d = 16; d <= 79; d++) g[d] = b(g[d - 3] ^ g[d - 8] ^ g[d - 14] ^ g[d - 16], 1);
|
|
1283
|
-
e = h;
|
|
1284
|
-
n = f;
|
|
1285
|
-
k = o;
|
|
1286
|
-
j = p;
|
|
1287
|
-
l = q;
|
|
1288
|
-
for (d = 0; d <= 19; d++) m = b(e, 5) + (n & k | ~n & j) + l + g[d] + 1518500249 & 4294967295, l = j, j = k, k = b(n, 30), n = e, e = m;
|
|
1289
|
-
for (d = 20; d <= 39; d++) m = b(e, 5) + (n ^ k ^ j) + l + g[d] + 1859775393 & 4294967295, l = j, j = k, k = b(n, 30), n = e, e = m;
|
|
1290
|
-
for (d = 40; d <= 59; d++) m = b(e, 5) + (n & k | n & j | k & j) + l + g[d] + 2400959708 & 4294967295, l = j, j = k, k = b(n, 30), n = e, e = m;
|
|
1291
|
-
for (d = 60; d <= 79; d++) m = b(e, 5) + (n ^ k ^ j) + l + g[d] + 3395469782 & 4294967295, l = j, j = k, k = b(n, 30), n = e, e = m;
|
|
1292
|
-
h = h + e & 4294967295;
|
|
1293
|
-
f = f + n & 4294967295;
|
|
1294
|
-
o = o + k & 4294967295;
|
|
1295
|
-
p = p + j & 4294967295;
|
|
1296
|
-
q = q + l & 4294967295;
|
|
1297
|
-
}
|
|
1298
|
-
m = c(h) + c(f) + c(o) + c(p) + c(q);
|
|
1299
|
-
return m.toLowerCase();
|
|
1300
|
-
}
|
|
1301
|
-
var sha1 = {
|
|
1302
|
-
hex: function (a) {
|
|
1303
|
-
return SHA1(a);
|
|
1304
|
-
}
|
|
1305
|
-
},
|
|
1306
|
-
MD5 = function (a) {
|
|
1307
|
-
function b(a, b) {
|
|
1308
|
-
var c, d, e, f, g;
|
|
1309
|
-
e = a & 2147483648;
|
|
1310
|
-
f = b & 2147483648;
|
|
1311
|
-
c = a & 1073741824;
|
|
1312
|
-
d = b & 1073741824;
|
|
1313
|
-
g = (a & 1073741823) + (b & 1073741823);
|
|
1314
|
-
return c & d ? g ^ 2147483648 ^ e ^ f : c | d ? g & 1073741824 ? g ^ 3221225472 ^ e ^ f : g ^ 1073741824 ^ e ^ f : g ^ e ^ f;
|
|
1315
|
-
}
|
|
1316
|
-
function c(a, c, d, e, f, g, h) {
|
|
1317
|
-
a = b(a, b(b(c & d | ~c & e, f), h));
|
|
1318
|
-
return b(a << g | a >>> 32 - g, c);
|
|
1319
|
-
}
|
|
1320
|
-
function d(a, c, d, e, f, g, h) {
|
|
1321
|
-
a = b(a, b(b(c & e | d & ~e, f), h));
|
|
1322
|
-
return b(a << g | a >>> 32 - g, c);
|
|
1323
|
-
}
|
|
1324
|
-
function e(a, c, d, e, f, g, h) {
|
|
1325
|
-
a = b(a, b(b(c ^ d ^ e, f), h));
|
|
1326
|
-
return b(a << g | a >>> 32 - g, c);
|
|
1327
|
-
}
|
|
1328
|
-
function g(a, c, d, e, f, g, h) {
|
|
1329
|
-
a = b(a, b(b(d ^ (c | ~e), f), h));
|
|
1330
|
-
return b(a << g | a >>> 32 - g, c);
|
|
1331
|
-
}
|
|
1332
|
-
function h(a) {
|
|
1333
|
-
var b = "",
|
|
1334
|
-
c = "",
|
|
1335
|
-
d;
|
|
1336
|
-
for (d = 0; d <= 3; d++) c = a >>> d * 8 & 255, c = "0" + c.toString(16), b += c.substr(c.length - 2, 2);
|
|
1337
|
-
return b;
|
|
1338
|
-
}
|
|
1339
|
-
var f = [],
|
|
1340
|
-
o,
|
|
1341
|
-
p,
|
|
1342
|
-
q,
|
|
1343
|
-
n,
|
|
1344
|
-
k,
|
|
1345
|
-
j,
|
|
1346
|
-
l,
|
|
1347
|
-
m,
|
|
1348
|
-
a = function (a) {
|
|
1349
|
-
for (var a = a.replace(/\r\n/g, "\n"), b = "", c = 0; c < a.length; c++) {
|
|
1350
|
-
var d = a.charCodeAt(c);
|
|
1351
|
-
d < 128 ? b += String.fromCharCode(d) : (d > 127 && d < 2048 ? b += String.fromCharCode(d >> 6 | 192) : (b += String.fromCharCode(d >> 12 | 224), b += String.fromCharCode(d >> 6 & 63 | 128)), b += String.fromCharCode(d & 63 | 128));
|
|
1352
|
-
}
|
|
1353
|
-
return b;
|
|
1354
|
-
}(a),
|
|
1355
|
-
f = function (a) {
|
|
1356
|
-
var b,
|
|
1357
|
-
c = a.length;
|
|
1358
|
-
b = c + 8;
|
|
1359
|
-
for (var d = ((b - b % 64) / 64 + 1) * 16, e = Array(d - 1), f = 0, g = 0; g < c;) b = (g - g % 4) / 4, f = g % 4 * 8, e[b] |= a.charCodeAt(g) << f, g++;
|
|
1360
|
-
e[(g - g % 4) / 4] |= 128 << g % 4 * 8;
|
|
1361
|
-
e[d - 2] = c << 3;
|
|
1362
|
-
e[d - 1] = c >>> 29;
|
|
1363
|
-
return e;
|
|
1364
|
-
}(a);
|
|
1365
|
-
k = 1732584193;
|
|
1366
|
-
j = 4023233417;
|
|
1367
|
-
l = 2562383102;
|
|
1368
|
-
m = 271733878;
|
|
1369
|
-
for (a = 0; a < f.length; a += 16) o = k, p = j, q = l, n = m, k = c(k, j, l, m, f[a + 0], 7, 3614090360), m = c(m, k, j, l, f[a + 1], 12, 3905402710), l = c(l, m, k, j, f[a + 2], 17, 606105819), j = c(j, l, m, k, f[a + 3], 22, 3250441966), k = c(k, j, l, m, f[a + 4], 7, 4118548399), m = c(m, k, j, l, f[a + 5], 12, 1200080426), l = c(l, m, k, j, f[a + 6], 17, 2821735955), j = c(j, l, m, k, f[a + 7], 22, 4249261313), k = c(k, j, l, m, f[a + 8], 7, 1770035416), m = c(m, k, j, l, f[a + 9], 12, 2336552879), l = c(l, m, k, j, f[a + 10], 17, 4294925233), j = c(j, l, m, k, f[a + 11], 22, 2304563134), k = c(k, j, l, m, f[a + 12], 7, 1804603682), m = c(m, k, j, l, f[a + 13], 12, 4254626195), l = c(l, m, k, j, f[a + 14], 17, 2792965006), j = c(j, l, m, k, f[a + 15], 22, 1236535329), k = d(k, j, l, m, f[a + 1], 5, 4129170786), m = d(m, k, j, l, f[a + 6], 9, 3225465664), l = d(l, m, k, j, f[a + 11], 14, 643717713), j = d(j, l, m, k, f[a + 0], 20, 3921069994), k = d(k, j, l, m, f[a + 5], 5, 3593408605), m = d(m, k, j, l, f[a + 10], 9, 38016083), l = d(l, m, k, j, f[a + 15], 14, 3634488961), j = d(j, l, m, k, f[a + 4], 20, 3889429448), k = d(k, j, l, m, f[a + 9], 5, 568446438), m = d(m, k, j, l, f[a + 14], 9, 3275163606), l = d(l, m, k, j, f[a + 3], 14, 4107603335), j = d(j, l, m, k, f[a + 8], 20, 1163531501), k = d(k, j, l, m, f[a + 13], 5, 2850285829), m = d(m, k, j, l, f[a + 2], 9, 4243563512), l = d(l, m, k, j, f[a + 7], 14, 1735328473), j = d(j, l, m, k, f[a + 12], 20, 2368359562), k = e(k, j, l, m, f[a + 5], 4, 4294588738), m = e(m, k, j, l, f[a + 8], 11, 2272392833), l = e(l, m, k, j, f[a + 11], 16, 1839030562), j = e(j, l, m, k, f[a + 14], 23, 4259657740), k = e(k, j, l, m, f[a + 1], 4, 2763975236), m = e(m, k, j, l, f[a + 4], 11, 1272893353), l = e(l, m, k, j, f[a + 7], 16, 4139469664), j = e(j, l, m, k, f[a + 10], 23, 3200236656), k = e(k, j, l, m, f[a + 13], 4, 681279174), m = e(m, k, j, l, f[a + 0], 11, 3936430074), l = e(l, m, k, j, f[a + 3], 16, 3572445317), j = e(j, l, m, k, f[a + 6], 23, 76029189), k = e(k, j, l, m, f[a + 9], 4, 3654602809), m = e(m, k, j, l, f[a + 12], 11, 3873151461), l = e(l, m, k, j, f[a + 15], 16, 530742520), j = e(j, l, m, k, f[a + 2], 23, 3299628645), k = g(k, j, l, m, f[a + 0], 6, 4096336452), m = g(m, k, j, l, f[a + 7], 10, 1126891415), l = g(l, m, k, j, f[a + 14], 15, 2878612391), j = g(j, l, m, k, f[a + 5], 21, 4237533241), k = g(k, j, l, m, f[a + 12], 6, 1700485571), m = g(m, k, j, l, f[a + 3], 10, 2399980690), l = g(l, m, k, j, f[a + 10], 15, 4293915773), j = g(j, l, m, k, f[a + 1], 21, 2240044497), k = g(k, j, l, m, f[a + 8], 6, 1873313359), m = g(m, k, j, l, f[a + 15], 10, 4264355552), l = g(l, m, k, j, f[a + 6], 15, 2734768916), j = g(j, l, m, k, f[a + 13], 21, 1309151649), k = g(k, j, l, m, f[a + 4], 6, 4149444226), m = g(m, k, j, l, f[a + 11], 10, 3174756917), l = g(l, m, k, j, f[a + 2], 15, 718787259), j = g(j, l, m, k, f[a + 9], 21, 3951481745), k = b(k, o), j = b(j, p), l = b(l, q), m = b(m, n);
|
|
1370
|
-
return (h(k) + h(j) + h(l) + h(m)).toLowerCase();
|
|
1371
|
-
};
|
|
1372
|
-
function parseBigInt(a, b) {
|
|
1373
|
-
return new BigInteger(a, b);
|
|
1374
|
-
}
|
|
1375
|
-
function pkcs1pad2(a, b) {
|
|
1376
|
-
if (b < a.length + 11) throw "Message too long for RSA (n=" + b + ", l=" + a.length + ")";
|
|
1377
|
-
for (var c = [], d = a.length - 1; d >= 0 && b > 0;) {
|
|
1378
|
-
var e = a.charCodeAt(d--);
|
|
1379
|
-
e < 128 ? c[--b] = e : e > 127 && e < 2048 ? (c[--b] = e & 63 | 128, c[--b] = e >> 6 | 192) : (c[--b] = e & 63 | 128, c[--b] = e >> 6 & 63 | 128, c[--b] = e >> 12 | 224);
|
|
1380
|
-
}
|
|
1381
|
-
c[--b] = 0;
|
|
1382
|
-
d = new SecureRandom();
|
|
1383
|
-
for (e = []; b > 2;) {
|
|
1384
|
-
for (e[0] = 0; e[0] == 0;) d.nextBytes(e);
|
|
1385
|
-
c[--b] = e[0];
|
|
1386
|
-
}
|
|
1387
|
-
c[--b] = 2;
|
|
1388
|
-
c[--b] = 0;
|
|
1389
|
-
return new BigInteger(c);
|
|
1390
|
-
}
|
|
1391
|
-
function RSAKey() {
|
|
1392
|
-
this.n = null;
|
|
1393
|
-
this.e = 0;
|
|
1394
|
-
this.coeff = this.dmq1 = this.dmp1 = this.q = this.p = this.d = null;
|
|
1395
|
-
}
|
|
1396
|
-
function RSASetPublic(a, b) {
|
|
1397
|
-
a != null && b != null && a.length > 0 && b.length > 0 ? (this.n = parseBigInt(a, 16), this.e = parseInt(b, 16)) : alert("Invalid RSA public key");
|
|
1398
|
-
}
|
|
1399
|
-
function RSADoPublic(a) {
|
|
1400
|
-
return a.modPowInt(this.e, this.n);
|
|
1401
|
-
}
|
|
1402
|
-
function RSAEncrypt(a) {
|
|
1403
|
-
a = pkcs1pad2(a, this.n.bitLength() + 7 >> 3);
|
|
1404
|
-
if (a == null) return null;
|
|
1405
|
-
a = this.doPublic(a);
|
|
1406
|
-
if (a == null) return null;
|
|
1407
|
-
a = a.toString(16);
|
|
1408
|
-
return (a.length & 1) == 0 ? a : "0" + a;
|
|
1409
|
-
}
|
|
1410
|
-
RSAKey.prototype.doPublic = RSADoPublic;
|
|
1411
|
-
RSAKey.prototype.setPublic = RSASetPublic;
|
|
1412
|
-
RSAKey.prototype.encrypt = RSAEncrypt;
|
|
1413
|
-
function pkcs1unpad2(a, b) {
|
|
1414
|
-
for (var c = a.toByteArray(), d = 0; d < c.length && c[d] == 0;) ++d;
|
|
1415
|
-
if (c.length - d != b - 1 || c[d] != 2) return null;
|
|
1416
|
-
for (++d; c[d] != 0;) if (++d >= c.length) return null;
|
|
1417
|
-
for (var e = ""; ++d < c.length;) {
|
|
1418
|
-
var g = c[d] & 255;
|
|
1419
|
-
g < 128 ? e += String.fromCharCode(g) : g > 191 && g < 224 ? (e += String.fromCharCode((g & 31) << 6 | c[d + 1] & 63), ++d) : (e += String.fromCharCode((g & 15) << 12 | (c[d + 1] & 63) << 6 | c[d + 2] & 63), d += 2);
|
|
1420
|
-
}
|
|
1421
|
-
return e;
|
|
1422
|
-
}
|
|
1423
|
-
function RSASetPrivate(a, b, c) {
|
|
1424
|
-
a != null && b != null && a.length > 0 && b.length > 0 ? (this.n = parseBigInt(a, 16), this.e = parseInt(b, 16), this.d = parseBigInt(c, 16)) : alert("Invalid RSA private key");
|
|
1425
|
-
}
|
|
1426
|
-
function RSASetPrivateEx(a, b, c, d, e, g, h, f) {
|
|
1427
|
-
a != null && b != null && a.length > 0 && b.length > 0 ? (this.n = parseBigInt(a, 16), this.e = parseInt(b, 16), this.d = parseBigInt(c, 16), this.p = parseBigInt(d, 16), this.q = parseBigInt(e, 16), this.dmp1 = parseBigInt(g, 16), this.dmq1 = parseBigInt(h, 16), this.coeff = parseBigInt(f, 16)) : alert("Invalid RSA private key");
|
|
1428
|
-
}
|
|
1429
|
-
function RSAGenerate(a, b) {
|
|
1430
|
-
var c = new SeededRandom(),
|
|
1431
|
-
d = a >> 1;
|
|
1432
|
-
this.e = parseInt(b, 16);
|
|
1433
|
-
for (var e = new BigInteger(b, 16);;) {
|
|
1434
|
-
for (;;) if (this.p = new BigInteger(a - d, 1, c), this.p.subtract(BigInteger.ONE).gcd(e).compareTo(BigInteger.ONE) == 0 && this.p.isProbablePrime(10)) break;
|
|
1435
|
-
for (;;) if (this.q = new BigInteger(d, 1, c), this.q.subtract(BigInteger.ONE).gcd(e).compareTo(BigInteger.ONE) == 0 && this.q.isProbablePrime(10)) break;
|
|
1436
|
-
if (this.p.compareTo(this.q) <= 0) {
|
|
1437
|
-
var g = this.p;
|
|
1438
|
-
this.p = this.q;
|
|
1439
|
-
this.q = g;
|
|
1440
|
-
}
|
|
1441
|
-
var g = this.p.subtract(BigInteger.ONE),
|
|
1442
|
-
h = this.q.subtract(BigInteger.ONE),
|
|
1443
|
-
f = g.multiply(h);
|
|
1444
|
-
if (f.gcd(e).compareTo(BigInteger.ONE) == 0) {
|
|
1445
|
-
this.n = this.p.multiply(this.q);
|
|
1446
|
-
this.d = e.modInverse(f);
|
|
1447
|
-
this.dmp1 = this.d.mod(g);
|
|
1448
|
-
this.dmq1 = this.d.mod(h);
|
|
1449
|
-
this.coeff = this.q.modInverse(this.p);
|
|
1450
|
-
break;
|
|
1451
|
-
}
|
|
1452
|
-
}
|
|
1453
|
-
}
|
|
1454
|
-
function RSADoPrivate(a) {
|
|
1455
|
-
if (this.p == null || this.q == null) return a.modPow(this.d, this.n);
|
|
1456
|
-
for (var b = a.mod(this.p).modPow(this.dmp1, this.p), a = a.mod(this.q).modPow(this.dmq1, this.q); b.compareTo(a) < 0;) b = b.add(this.p);
|
|
1457
|
-
return b.subtract(a).multiply(this.coeff).mod(this.p).multiply(this.q).add(a);
|
|
1458
|
-
}
|
|
1459
|
-
function RSADecrypt(a) {
|
|
1460
|
-
a = this.doPrivate(parseBigInt(a, 16));
|
|
1461
|
-
return a == null ? null : pkcs1unpad2(a, this.n.bitLength() + 7 >> 3);
|
|
1462
|
-
}
|
|
1463
|
-
RSAKey.prototype.doPrivate = RSADoPrivate;
|
|
1464
|
-
RSAKey.prototype.setPrivate = RSASetPrivate;
|
|
1465
|
-
RSAKey.prototype.setPrivateEx = RSASetPrivateEx;
|
|
1466
|
-
RSAKey.prototype.generate = RSAGenerate;
|
|
1467
|
-
RSAKey.prototype.decrypt = RSADecrypt;
|
|
1468
|
-
var _RSASIGN_DIHEAD = [];
|
|
1469
|
-
_RSASIGN_DIHEAD.sha1 = "3021300906052b0e03021a05000414";
|
|
1470
|
-
_RSASIGN_DIHEAD.sha256 = "3031300d060960864801650304020105000420";
|
|
1471
|
-
var _RSASIGN_HASHHEXFUNC = [];
|
|
1472
|
-
_RSASIGN_HASHHEXFUNC.sha1 = sha1.hex;
|
|
1473
|
-
_RSASIGN_HASHHEXFUNC.sha256 = sha256.hex;
|
|
1474
|
-
function _rsasign_getHexPaddedDigestInfoForString(a, b, c) {
|
|
1475
|
-
b /= 4;
|
|
1476
|
-
for (var a = (0, _RSASIGN_HASHHEXFUNC[c])(a), c = "00" + _RSASIGN_DIHEAD[c] + a, a = "", b = b - 4 - c.length, d = 0; d < b; d += 2) a += "ff";
|
|
1477
|
-
return sPaddedMessageHex = "0001" + a + c;
|
|
1478
|
-
}
|
|
1479
|
-
function _rsasign_signString(a, b) {
|
|
1480
|
-
var c = _rsasign_getHexPaddedDigestInfoForString(a, this.n.bitLength(), b);
|
|
1481
|
-
return this.doPrivate(parseBigInt(c, 16)).toString(16);
|
|
1482
|
-
}
|
|
1483
|
-
function _rsasign_signStringWithSHA1(a) {
|
|
1484
|
-
a = _rsasign_getHexPaddedDigestInfoForString(a, this.n.bitLength(), "sha1");
|
|
1485
|
-
return this.doPrivate(parseBigInt(a, 16)).toString(16);
|
|
1486
|
-
}
|
|
1487
|
-
function _rsasign_signStringWithSHA256(a) {
|
|
1488
|
-
a = _rsasign_getHexPaddedDigestInfoForString(a, this.n.bitLength(), "sha256");
|
|
1489
|
-
return this.doPrivate(parseBigInt(a, 16)).toString(16);
|
|
1490
|
-
}
|
|
1491
|
-
function _rsasign_getDecryptSignatureBI(a, b, c) {
|
|
1492
|
-
var d = new RSAKey();
|
|
1493
|
-
d.setPublic(b, c);
|
|
1494
|
-
return d.doPublic(a);
|
|
1495
|
-
}
|
|
1496
|
-
function _rsasign_getHexDigestInfoFromSig(a, b, c) {
|
|
1497
|
-
return _rsasign_getDecryptSignatureBI(a, b, c).toString(16).replace(/^1f+00/, "");
|
|
1498
|
-
}
|
|
1499
|
-
function _rsasign_getAlgNameAndHashFromHexDisgestInfo(a) {
|
|
1500
|
-
for (var b in _RSASIGN_DIHEAD) {
|
|
1501
|
-
var c = _RSASIGN_DIHEAD[b],
|
|
1502
|
-
d = c.length;
|
|
1503
|
-
if (a.substring(0, d) == c) return [b, a.substring(d)];
|
|
1504
|
-
}
|
|
1505
|
-
return [];
|
|
1506
|
-
}
|
|
1507
|
-
function _rsasign_verifySignatureWithArgs(a, b, c, d) {
|
|
1508
|
-
b = _rsasign_getHexDigestInfoFromSig(b, c, d);
|
|
1509
|
-
c = _rsasign_getAlgNameAndHashFromHexDisgestInfo(b);
|
|
1510
|
-
if (c.length == 0) return !1;
|
|
1511
|
-
b = c[1];
|
|
1512
|
-
a = (0, _RSASIGN_HASHHEXFUNC[c[0]])(a);
|
|
1513
|
-
return b == a;
|
|
1514
|
-
}
|
|
1515
|
-
function _rsasign_verifyHexSignatureForMessage(a, b) {
|
|
1516
|
-
var c = parseBigInt(a, 16);
|
|
1517
|
-
return _rsasign_verifySignatureWithArgs(b, c, this.n.toString(16), this.e.toString(16));
|
|
1518
|
-
}
|
|
1519
|
-
function _rsasign_verifyString(a, b) {
|
|
1520
|
-
var b = b.replace(/[ \n]+/g, ""),
|
|
1521
|
-
c = this.doPublic(parseBigInt(b, 16)).toString(16).replace(/^1f+00/, ""),
|
|
1522
|
-
d = _rsasign_getAlgNameAndHashFromHexDisgestInfo(c);
|
|
1523
|
-
if (d.length == 0) return !1;
|
|
1524
|
-
c = d[1];
|
|
1525
|
-
d = (0, _RSASIGN_HASHHEXFUNC[d[0]])(a);
|
|
1526
|
-
return c == d;
|
|
1527
|
-
}
|
|
1528
|
-
RSAKey.prototype.signString = _rsasign_signString;
|
|
1529
|
-
RSAKey.prototype.signStringWithSHA1 = _rsasign_signStringWithSHA1;
|
|
1530
|
-
RSAKey.prototype.signStringWithSHA256 = _rsasign_signStringWithSHA256;
|
|
1531
|
-
RSAKey.prototype.verifyString = _rsasign_verifyString;
|
|
1532
|
-
RSAKey.prototype.verifyHexSignatureForMessage = _rsasign_verifyHexSignatureForMessage;
|
|
1533
|
-
var aes = function () {
|
|
1534
|
-
var a = {
|
|
1535
|
-
Sbox: [99, 124, 119, 123, 242, 107, 111, 197, 48, 1, 103, 43, 254, 215, 171, 118, 202, 130, 201, 125, 250, 89, 71, 240, 173, 212, 162, 175, 156, 164, 114, 192, 183, 253, 147, 38, 54, 63, 247, 204, 52, 165, 229, 241, 113, 216, 49, 21, 4, 199, 35, 195, 24, 150, 5, 154, 7, 18, 128, 226, 235, 39, 178, 117, 9, 131, 44, 26, 27, 110, 90, 160, 82, 59, 214, 179, 41, 227, 47, 132, 83, 209, 0, 237, 32, 252, 177, 91, 106, 203, 190, 57, 74, 76, 88, 207, 208, 239, 170, 251, 67, 77, 51, 133, 69, 249, 2, 127, 80, 60, 159, 168, 81, 163, 64, 143, 146, 157, 56, 245, 188, 182, 218, 33, 16, 255, 243, 210, 205, 12, 19, 236, 95, 151, 68, 23, 196, 167, 126, 61, 100, 93, 25, 115, 96, 129, 79, 220, 34, 42, 144, 136, 70, 238, 184, 20, 222, 94, 11, 219, 224, 50, 58, 10, 73, 6, 36, 92, 194, 211, 172, 98, 145, 149, 228, 121, 231, 200, 55, 109, 141, 213, 78, 169, 108, 86, 244, 234, 101, 122, 174, 8, 186, 120, 37, 46, 28, 166, 180, 198, 232, 221, 116, 31, 75, 189, 139, 138, 112, 62, 181, 102, 72, 3, 246, 14, 97, 53, 87, 185, 134, 193, 29, 158, 225, 248, 152, 17, 105, 217, 142, 148, 155, 30, 135, 233, 206, 85, 40, 223, 140, 161, 137, 13, 191, 230, 66, 104, 65, 153, 45, 15, 176, 84, 187, 22],
|
|
1536
|
-
ShiftRowTab: [0, 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12, 1, 6, 11]
|
|
1537
|
-
};
|
|
1538
|
-
a.Init = function () {
|
|
1539
|
-
a.Sbox_Inv = Array(256);
|
|
1540
|
-
for (var b = 0; b < 256; b++) a.Sbox_Inv[a.Sbox[b]] = b;
|
|
1541
|
-
a.ShiftRowTab_Inv = Array(16);
|
|
1542
|
-
for (b = 0; b < 16; b++) a.ShiftRowTab_Inv[a.ShiftRowTab[b]] = b;
|
|
1543
|
-
a.xtime = Array(256);
|
|
1544
|
-
for (b = 0; b < 128; b++) a.xtime[b] = b << 1, a.xtime[128 + b] = b << 1 ^ 27;
|
|
1545
|
-
};
|
|
1546
|
-
a.Done = function () {
|
|
1547
|
-
delete a.Sbox_Inv;
|
|
1548
|
-
delete a.ShiftRowTab_Inv;
|
|
1549
|
-
delete a.xtime;
|
|
1550
|
-
};
|
|
1551
|
-
a.ExpandKey = function (b) {
|
|
1552
|
-
var c = b.length,
|
|
1553
|
-
d,
|
|
1554
|
-
e = 1;
|
|
1555
|
-
switch (c) {
|
|
1556
|
-
case 16:
|
|
1557
|
-
d = 176;
|
|
1558
|
-
break;
|
|
1559
|
-
case 24:
|
|
1560
|
-
d = 208;
|
|
1561
|
-
break;
|
|
1562
|
-
case 32:
|
|
1563
|
-
d = 240;
|
|
1564
|
-
break;
|
|
1565
|
-
default:
|
|
1566
|
-
alert("my.ExpandKey: Only key lengths of 16, 24 or 32 bytes allowed!");
|
|
1567
|
-
}
|
|
1568
|
-
for (var g = c; g < d; g += 4) {
|
|
1569
|
-
var h = b.slice(g - 4, g);
|
|
1570
|
-
if (g % c == 0) {
|
|
1571
|
-
if (h = [a.Sbox[h[1]] ^ e, a.Sbox[h[2]], a.Sbox[h[3]], a.Sbox[h[0]]], (e <<= 1) >= 256) e ^= 283;
|
|
1572
|
-
} else c > 24 && g % c == 16 && (h = [a.Sbox[h[0]], a.Sbox[h[1]], a.Sbox[h[2]], a.Sbox[h[3]]]);
|
|
1573
|
-
for (var f = 0; f < 4; f++) b[g + f] = b[g + f - c] ^ h[f];
|
|
1574
|
-
}
|
|
1575
|
-
};
|
|
1576
|
-
a.Encrypt = function (b, c) {
|
|
1577
|
-
var d = c.length;
|
|
1578
|
-
a.AddRoundKey(b, c.slice(0, 16));
|
|
1579
|
-
for (var e = 16; e < d - 16; e += 16) a.SubBytes(b, a.Sbox), a.ShiftRows(b, a.ShiftRowTab), a.MixColumns(b), a.AddRoundKey(b, c.slice(e, e + 16));
|
|
1580
|
-
a.SubBytes(b, a.Sbox);
|
|
1581
|
-
a.ShiftRows(b, a.ShiftRowTab);
|
|
1582
|
-
a.AddRoundKey(b, c.slice(e, d));
|
|
1583
|
-
};
|
|
1584
|
-
a.Decrypt = function (b, c) {
|
|
1585
|
-
var d = c.length;
|
|
1586
|
-
a.AddRoundKey(b, c.slice(d - 16, d));
|
|
1587
|
-
a.ShiftRows(b, a.ShiftRowTab_Inv);
|
|
1588
|
-
a.SubBytes(b, a.Sbox_Inv);
|
|
1589
|
-
for (d -= 32; d >= 16; d -= 16) a.AddRoundKey(b, c.slice(d, d + 16)), a.MixColumns_Inv(b), a.ShiftRows(b, a.ShiftRowTab_Inv), a.SubBytes(b, a.Sbox_Inv);
|
|
1590
|
-
a.AddRoundKey(b, c.slice(0, 16));
|
|
1591
|
-
};
|
|
1592
|
-
a.SubBytes = function (a, c) {
|
|
1593
|
-
for (var d = 0; d < 16; d++) a[d] = c[a[d]];
|
|
1594
|
-
};
|
|
1595
|
-
a.AddRoundKey = function (a, c) {
|
|
1596
|
-
for (var d = 0; d < 16; d++) a[d] ^= c[d];
|
|
1597
|
-
};
|
|
1598
|
-
a.ShiftRows = function (a, c) {
|
|
1599
|
-
for (var d = [].concat(a), e = 0; e < 16; e++) a[e] = d[c[e]];
|
|
1600
|
-
};
|
|
1601
|
-
a.MixColumns = function (b) {
|
|
1602
|
-
for (var c = 0; c < 16; c += 4) {
|
|
1603
|
-
var d = b[c + 0],
|
|
1604
|
-
e = b[c + 1],
|
|
1605
|
-
g = b[c + 2],
|
|
1606
|
-
h = b[c + 3],
|
|
1607
|
-
f = d ^ e ^ g ^ h;
|
|
1608
|
-
b[c + 0] ^= f ^ a.xtime[d ^ e];
|
|
1609
|
-
b[c + 1] ^= f ^ a.xtime[e ^ g];
|
|
1610
|
-
b[c + 2] ^= f ^ a.xtime[g ^ h];
|
|
1611
|
-
b[c + 3] ^= f ^ a.xtime[h ^ d];
|
|
1612
|
-
}
|
|
1613
|
-
};
|
|
1614
|
-
a.MixColumns_Inv = function (b) {
|
|
1615
|
-
for (var c = 0; c < 16; c += 4) {
|
|
1616
|
-
var d = b[c + 0],
|
|
1617
|
-
e = b[c + 1],
|
|
1618
|
-
g = b[c + 2],
|
|
1619
|
-
h = b[c + 3],
|
|
1620
|
-
f = d ^ e ^ g ^ h,
|
|
1621
|
-
o = a.xtime[f],
|
|
1622
|
-
p = a.xtime[a.xtime[o ^ d ^ g]] ^ f;
|
|
1623
|
-
f ^= a.xtime[a.xtime[o ^ e ^ h]];
|
|
1624
|
-
b[c + 0] ^= p ^ a.xtime[d ^ e];
|
|
1625
|
-
b[c + 1] ^= f ^ a.xtime[e ^ g];
|
|
1626
|
-
b[c + 2] ^= p ^ a.xtime[g ^ h];
|
|
1627
|
-
b[c + 3] ^= f ^ a.xtime[h ^ d];
|
|
1628
|
-
}
|
|
1629
|
-
};
|
|
1630
|
-
return a;
|
|
1631
|
-
}(),
|
|
1632
|
-
cryptico = function () {
|
|
1633
|
-
var a = {};
|
|
1634
|
-
aes.Init();
|
|
1635
|
-
a.b256to64 = function (a) {
|
|
1636
|
-
var c,
|
|
1637
|
-
d,
|
|
1638
|
-
e,
|
|
1639
|
-
g = "",
|
|
1640
|
-
f = 0,
|
|
1641
|
-
o = a.length;
|
|
1642
|
-
for (e = 0; e < o; e++) d = a.charCodeAt(e), f == 0 ? (g += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(d >> 2 & 63), c = (d & 3) << 4) : f == 1 ? (g += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(c | d >> 4 & 15), c = (d & 15) << 2) : f == 2 && (g += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(c | d >> 6 & 3), g += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(d & 63)), f += 1, f == 3 && (f = 0);
|
|
1643
|
-
f > 0 && (g += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(c), g += "=");
|
|
1644
|
-
f == 1 && (g += "=");
|
|
1645
|
-
return g;
|
|
1646
|
-
};
|
|
1647
|
-
a.b64to256 = function (a) {
|
|
1648
|
-
var c,
|
|
1649
|
-
d,
|
|
1650
|
-
e = "",
|
|
1651
|
-
g = 0,
|
|
1652
|
-
h = 0,
|
|
1653
|
-
f = a.length;
|
|
1654
|
-
for (d = 0; d < f; d++) c = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a.charAt(d)), c >= 0 && (g && (e += String.fromCharCode(h | c >> 6 - g & 255)), g = g + 2 & 7, h = c << g & 255);
|
|
1655
|
-
return e;
|
|
1656
|
-
};
|
|
1657
|
-
a.b16to64 = function (a) {
|
|
1658
|
-
var c,
|
|
1659
|
-
d,
|
|
1660
|
-
e = "";
|
|
1661
|
-
a.length % 2 == 1 && (a = "0" + a);
|
|
1662
|
-
for (c = 0; c + 3 <= a.length; c += 3) d = parseInt(a.substring(c, c + 3), 16), e += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(d >> 6) + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(d & 63);
|
|
1663
|
-
c + 1 == a.length ? (d = parseInt(a.substring(c, c + 1), 16), e += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(d << 2)) : c + 2 == a.length && (d = parseInt(a.substring(c, c + 2), 16), e += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(d >> 2) + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt((d & 3) << 4));
|
|
1664
|
-
for (; (e.length & 3) > 0;) e += "=";
|
|
1665
|
-
return e;
|
|
1666
|
-
};
|
|
1667
|
-
a.b64to16 = function (a) {
|
|
1668
|
-
var c = "",
|
|
1669
|
-
d,
|
|
1670
|
-
e = 0,
|
|
1671
|
-
g;
|
|
1672
|
-
for (d = 0; d < a.length; ++d) {
|
|
1673
|
-
if (a.charAt(d) == "=") break;
|
|
1674
|
-
v = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a.charAt(d));
|
|
1675
|
-
v < 0 || (e == 0 ? (c += int2char(v >> 2), g = v & 3, e = 1) : e == 1 ? (c += int2char(g << 2 | v >> 4), g = v & 15, e = 2) : e == 2 ? (c += int2char(g), c += int2char(v >> 2), g = v & 3, e = 3) : (c += int2char(g << 2 | v >> 4), c += int2char(v & 15), e = 0));
|
|
1676
|
-
}
|
|
1677
|
-
e == 1 && (c += int2char(g << 2));
|
|
1678
|
-
return c;
|
|
1679
|
-
};
|
|
1680
|
-
a.string2bytes = function (a) {
|
|
1681
|
-
for (var c = [], d = 0; d < a.length; d++) c.push(a.charCodeAt(d));
|
|
1682
|
-
return c;
|
|
1683
|
-
};
|
|
1684
|
-
a.bytes2string = function (a) {
|
|
1685
|
-
for (var c = "", d = 0; d < a.length; d++) c += String.fromCharCode(a[d]);
|
|
1686
|
-
return c;
|
|
1687
|
-
};
|
|
1688
|
-
a.blockXOR = function (a, c) {
|
|
1689
|
-
for (var d = Array(16), e = 0; e < 16; e++) d[e] = a[e] ^ c[e];
|
|
1690
|
-
return d;
|
|
1691
|
-
};
|
|
1692
|
-
a.blockIV = function () {
|
|
1693
|
-
var a = new SecureRandom(),
|
|
1694
|
-
c = Array(16);
|
|
1695
|
-
a.nextBytes(c);
|
|
1696
|
-
return c;
|
|
1697
|
-
};
|
|
1698
|
-
a.pad16 = function (a) {
|
|
1699
|
-
var c = a.slice(0),
|
|
1700
|
-
d = (16 - a.length % 16) % 16;
|
|
1701
|
-
for (i = a.length; i < a.length + d; i++) c.push(0);
|
|
1702
|
-
return c;
|
|
1703
|
-
};
|
|
1704
|
-
a.depad = function (a) {
|
|
1705
|
-
for (a = a.slice(0); a[a.length - 1] == 0;) a = a.slice(0, a.length - 1);
|
|
1706
|
-
return a;
|
|
1707
|
-
};
|
|
1708
|
-
a.encryptAESCBC = function (b, c) {
|
|
1709
|
-
var d = c.slice(0);
|
|
1710
|
-
aes.ExpandKey(d);
|
|
1711
|
-
for (var e = a.string2bytes(b), e = a.pad16(e), g = a.blockIV(), h = 0; h < e.length / 16; h++) {
|
|
1712
|
-
var f = e.slice(h * 16, h * 16 + 16),
|
|
1713
|
-
o = g.slice(h * 16, h * 16 + 16),
|
|
1714
|
-
f = a.blockXOR(o, f);
|
|
1715
|
-
aes.Encrypt(f, d);
|
|
1716
|
-
g = g.concat(f);
|
|
1717
|
-
}
|
|
1718
|
-
d = a.bytes2string(g);
|
|
1719
|
-
return a.b256to64(d);
|
|
1720
|
-
};
|
|
1721
|
-
a.decryptAESCBC = function (b, c) {
|
|
1722
|
-
var d = c.slice(0);
|
|
1723
|
-
aes.ExpandKey(d);
|
|
1724
|
-
for (var b = a.b64to256(b), e = a.string2bytes(b), g = [], h = 1; h < e.length / 16; h++) {
|
|
1725
|
-
var f = e.slice(h * 16, h * 16 + 16),
|
|
1726
|
-
o = e.slice((h - 1) * 16, (h - 1) * 16 + 16);
|
|
1727
|
-
aes.Decrypt(f, d);
|
|
1728
|
-
f = a.blockXOR(o, f);
|
|
1729
|
-
g = g.concat(f);
|
|
1730
|
-
}
|
|
1731
|
-
g = a.depad(g);
|
|
1732
|
-
return a.bytes2string(g);
|
|
1733
|
-
};
|
|
1734
|
-
a.wrap60 = function (a) {
|
|
1735
|
-
for (var c = "", d = 0; d < a.length; d++) d % 60 == 0 && d != 0 && (c += "\n"), c += a[d];
|
|
1736
|
-
return c;
|
|
1737
|
-
};
|
|
1738
|
-
a.generateAESKey = function () {
|
|
1739
|
-
var a = Array(16);
|
|
1740
|
-
new SecureRandom().nextBytes(a);
|
|
1741
|
-
return a;
|
|
1742
|
-
};
|
|
1743
|
-
a.generateRSAKey = function (a, c) {
|
|
1744
|
-
Math.seedrandom(sha256.hex(a));
|
|
1745
|
-
var d = new RSAKey();
|
|
1746
|
-
d.generate(c, "10001");
|
|
1747
|
-
return d;
|
|
1748
|
-
};
|
|
1749
|
-
a.publicKeyString = function (b) {
|
|
1750
|
-
return pubkey = b.n.toString(16);
|
|
1751
|
-
};
|
|
1752
|
-
a.publicKeyID = function (a) {
|
|
1753
|
-
return MD5(a);
|
|
1754
|
-
};
|
|
1755
|
-
a.publicKeyFromString = function (b) {
|
|
1756
|
-
var b = b.split("|")[0],
|
|
1757
|
-
c = new RSAKey();
|
|
1758
|
-
c.setPublic(b, "10001");
|
|
1759
|
-
return c;
|
|
1760
|
-
};
|
|
1761
|
-
a.encrypt = function (b, c, d) {
|
|
1762
|
-
var e = "";
|
|
1763
|
-
try {
|
|
1764
|
-
var h = a.publicKeyFromString(c);
|
|
1765
|
-
e += h.encrypt(b) + "?";
|
|
1766
|
-
} catch (f) {
|
|
1767
|
-
return {
|
|
1768
|
-
status: "Invalid public key"
|
|
1769
|
-
};
|
|
1770
|
-
}
|
|
1771
|
-
return {
|
|
1772
|
-
status: "success",
|
|
1773
|
-
cipher: e
|
|
1774
|
-
};
|
|
1775
|
-
};
|
|
1776
|
-
a.decrypt = function (b, c) {
|
|
1777
|
-
var d = b.split("?"),
|
|
1778
|
-
e = c.decrypt(d[0]);
|
|
1779
|
-
return {
|
|
1780
|
-
status: "success",
|
|
1781
|
-
plaintext: e,
|
|
1782
|
-
signature: "unsigned"
|
|
1783
|
-
};
|
|
1784
|
-
};
|
|
1785
|
-
return a;
|
|
1786
|
-
}();
|
|
1787
|
-
module.exports = cryptico;
|
|
1788
|
-
|
|
1789
|
-
/***/
|
|
1790
|
-
}, /* 1 */
|
|
1791
|
-
/***/function (module, exports, __webpack_require__) {
|
|
1792
|
-
module.exports = __webpack_require__(2);
|
|
1793
|
-
|
|
1794
|
-
/***/
|
|
1795
|
-
}, /* 2 */
|
|
1796
|
-
/***/function (module, __webpack_exports__, __webpack_require__) {
|
|
1797
|
-
|
|
1798
|
-
// ESM COMPAT FLAG
|
|
1799
|
-
__webpack_require__.r(__webpack_exports__);
|
|
1800
|
-
|
|
1801
|
-
// EXPORTS
|
|
1802
|
-
__webpack_require__.d(__webpack_exports__, "StreamClient", function () {
|
|
1803
|
-
return (/* binding */StreamClient
|
|
1804
|
-
);
|
|
1805
|
-
});
|
|
1806
|
-
|
|
1807
|
-
// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/rng.js
|
|
1808
|
-
// Unique ID creation requires a high quality random # generator. In the browser we therefore
|
|
1809
|
-
// require the crypto API and do not support built-in fallback to lower quality random number
|
|
1810
|
-
// generators (like Math.random()).
|
|
1811
|
-
var getRandomValues;
|
|
1812
|
-
var rnds8 = new Uint8Array(16);
|
|
1813
|
-
function rng() {
|
|
1814
|
-
// lazy load so that environments that need to polyfill have a chance to do so
|
|
1815
|
-
if (!getRandomValues) {
|
|
1816
|
-
// getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also,
|
|
1817
|
-
// find the complete implementation of crypto (msCrypto) on IE11.
|
|
1818
|
-
getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);
|
|
1819
|
-
if (!getRandomValues) {
|
|
1820
|
-
throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
|
|
1821
|
-
}
|
|
1822
|
-
}
|
|
1823
|
-
return getRandomValues(rnds8);
|
|
1824
|
-
}
|
|
1825
|
-
// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/regex.js
|
|
1826
|
-
/* harmony default export */
|
|
1827
|
-
var regex = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
|
|
1828
|
-
// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/validate.js
|
|
1829
|
-
|
|
1830
|
-
function validate(uuid) {
|
|
1831
|
-
return typeof uuid === 'string' && regex.test(uuid);
|
|
1832
|
-
}
|
|
1833
|
-
|
|
1834
|
-
/* harmony default export */
|
|
1835
|
-
var esm_browser_validate = validate;
|
|
1836
|
-
// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/stringify.js
|
|
1837
|
-
|
|
1838
|
-
/**
|
|
1839
|
-
* Convert array of 16 byte values to UUID string format of the form:
|
|
1840
|
-
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
1841
|
-
*/
|
|
1842
|
-
|
|
1843
|
-
var byteToHex = [];
|
|
1844
|
-
for (var stringify_i = 0; stringify_i < 256; ++stringify_i) {
|
|
1845
|
-
byteToHex.push((stringify_i + 0x100).toString(16).substr(1));
|
|
1846
|
-
}
|
|
1847
|
-
function stringify(arr) {
|
|
1848
|
-
var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
1849
|
-
// Note: Be careful editing this code! It's been tuned for performance
|
|
1850
|
-
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
|
|
1851
|
-
var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one
|
|
1852
|
-
// of the following:
|
|
1853
|
-
// - One or more input array values don't map to a hex octet (leading to
|
|
1854
|
-
// "undefined" in the uuid)
|
|
1855
|
-
// - Invalid input values for the RFC `version` or `variant` fields
|
|
1856
|
-
|
|
1857
|
-
if (!esm_browser_validate(uuid)) {
|
|
1858
|
-
throw TypeError('Stringified UUID is invalid');
|
|
1859
|
-
}
|
|
1860
|
-
return uuid;
|
|
1861
|
-
}
|
|
1862
|
-
|
|
1863
|
-
/* harmony default export */
|
|
1864
|
-
var esm_browser_stringify = stringify;
|
|
1865
|
-
// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/v4.js
|
|
1866
|
-
|
|
1867
|
-
function v4(options, buf, offset) {
|
|
1868
|
-
options = options || {};
|
|
1869
|
-
var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
1870
|
-
|
|
1871
|
-
rnds[6] = rnds[6] & 0x0f | 0x40;
|
|
1872
|
-
rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
|
|
1873
|
-
|
|
1874
|
-
if (buf) {
|
|
1875
|
-
offset = offset || 0;
|
|
1876
|
-
for (var i = 0; i < 16; ++i) {
|
|
1877
|
-
buf[offset + i] = rnds[i];
|
|
1878
|
-
}
|
|
1879
|
-
return buf;
|
|
1880
|
-
}
|
|
1881
|
-
return esm_browser_stringify(rnds);
|
|
1882
|
-
}
|
|
1883
|
-
|
|
1884
|
-
/* harmony default export */
|
|
1885
|
-
var esm_browser_v4 = v4;
|
|
1886
|
-
// CONCATENATED MODULE: ./directDeviceCustom.js
|
|
1887
|
-
/**
|
|
1888
|
-
* @synopsis 定制设备取流
|
|
1889
|
-
*
|
|
1890
|
-
* @note [ADD][2017-07-28]新建 by fengzhongjian
|
|
1891
|
-
*
|
|
1892
|
-
*/
|
|
1893
|
-
let DirectDeviceCustom = function () {
|
|
1894
|
-
class DeviceDirect {
|
|
1895
|
-
constructor() {}
|
|
1896
|
-
//to do
|
|
1897
|
-
|
|
1898
|
-
//创建取流客户端对象
|
|
1899
|
-
createClientObject(oWebsocket, szId, iCurChannel, iCurStream) {
|
|
1900
|
-
return {
|
|
1901
|
-
socket: oWebsocket,
|
|
1902
|
-
id: szId,
|
|
1903
|
-
iCurChannel: iCurChannel,
|
|
1904
|
-
iCurStream: iCurStream,
|
|
1905
|
-
resolve: null,
|
|
1906
|
-
reject: null
|
|
1907
|
-
};
|
|
1908
|
-
}
|
|
1909
|
-
//零通道预览
|
|
1910
|
-
zeroPlayCmd(iCurChannel, iCurStream) {
|
|
1911
|
-
let aCmd = [0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, iCurChannel + 1, 0x00, 0x00, 0x00, iCurStream, 0x00, 0x00, 0x04, 0x00];
|
|
1912
|
-
return new Uint8Array(aCmd);
|
|
1913
|
-
}
|
|
1914
|
-
//普通通道预览
|
|
1915
|
-
playCmd(iCurChannel, iCurStream) {
|
|
1916
|
-
let aCmd = [0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, iCurChannel, 0x00, 0x00, 0x00, iCurStream, 0x00, 0x00, 0x04, 0x00];
|
|
1917
|
-
return new Uint8Array(aCmd);
|
|
1918
|
-
}
|
|
1919
|
-
//回放
|
|
1920
|
-
playbackCmd(szStartTime, szStopTime, iCurChannel, iCurStream) {
|
|
1921
|
-
let szStartDayMonthYear = szStartTime.split("T")[0];
|
|
1922
|
-
let szStartHourMinSec = szStartTime.split("T")[1];
|
|
1923
|
-
let szStartYear = "0" + parseInt(szStartDayMonthYear.substring(0, 4), 10).toString(16);
|
|
1924
|
-
let iStartMonth = parseInt(szStartDayMonthYear.substring(4, 6), 10);
|
|
1925
|
-
let iStartDay = parseInt(szStartDayMonthYear.substring(6), 10);
|
|
1926
|
-
let iStartHour = parseInt(szStartHourMinSec.substring(0, 2), 10);
|
|
1927
|
-
let iStartMin = parseInt(szStartHourMinSec.substring(2, 4), 10);
|
|
1928
|
-
let iStartSec = parseInt(szStartHourMinSec.substring(4, 6), 10);
|
|
1929
|
-
let szStopDayMonthYear = szStopTime.split("T")[0];
|
|
1930
|
-
let szStopHourMinSec = szStopTime.split("T")[1];
|
|
1931
|
-
let szStopYear = "0" + parseInt(szStopDayMonthYear.substring(0, 4), 10).toString(16);
|
|
1932
|
-
let iStopMonth = parseInt(szStopDayMonthYear.substring(4, 6), 10);
|
|
1933
|
-
//let iStopDay = parseInt(szStopDayMonthYear.substring(6), 10);
|
|
1934
|
-
let iStopHour = parseInt(szStopHourMinSec.substring(0, 2), 10);
|
|
1935
|
-
let iStopMin = parseInt(szStopHourMinSec.substring(2, 4), 10);
|
|
1936
|
-
let iStopSec = parseInt(szStopHourMinSec.substring(4, 6), 10);
|
|
1937
|
-
let aCmd = [/*header*/0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*channel*/0x00, 0x00, 0x00, iCurChannel, /*start time*/0x00, 0x00, parseInt(szStartYear.substring(0, 2), 16), parseInt(szStartYear.substring(2, 4), 16), 0x00, 0x00, 0x00, iStartMonth, 0x00, 0x00, 0x00, iStartDay, 0x00, 0x00, 0x00, iStartHour, 0x00, 0x00, 0x00, iStartMin, 0x00, 0x00, 0x00, iStartSec, /*end time*/0x00, 0x00, parseInt(szStopYear.substring(0, 2), 16), parseInt(szStopYear.substring(2, 4), 16), 0x00, 0x00, 0x00, iStopMonth, 0x00, 0x00, 0x00, iStartDay, 0x00, 0x00, 0x00, iStopHour, 0x00, 0x00, 0x00, iStopMin, 0x00, 0x00, 0x00, iStopSec, /*是否抽帧*/0x00, /*是否下载*/0x00, /*录像卷类型 0普通卷,1存档卷*/0x00, /*存档卷号*/0x00, /*存档卷上的录像文件索引*/0x00, 0x00, 0x00, 0x00, /*码流类型 0主码流,1子码流,2三码流*/iCurStream, /*保留字*/0x00, 0x00, 0x00];
|
|
1938
|
-
return new Uint8Array(aCmd);
|
|
1939
|
-
}
|
|
1940
|
-
//回放速率
|
|
1941
|
-
playRateCmd(iRate) {
|
|
1942
|
-
let szHex = (parseInt(iRate, 10) >>> 0).toString(16).toLocaleUpperCase().toString(16);
|
|
1943
|
-
for (let j = szHex.length; j < 8; j++) {
|
|
1944
|
-
//对字符串进行补0,筹齐8位
|
|
1945
|
-
szHex = "0" + szHex;
|
|
1946
|
-
}
|
|
1947
|
-
let aRate = [0, 0, 0, 0]; //4字节16机制表示
|
|
1948
|
-
for (let j = 0, iLenRate = szHex.length; j < iLenRate; j = j + 2) {
|
|
1949
|
-
aRate[Math.floor(j / 2)] = parseInt(szHex.substring(j, j + 2), 16);
|
|
1950
|
-
}
|
|
1951
|
-
let aCmd = [/*header*/0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x01, 0x2f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, aRate[0], aRate[1], aRate[2], aRate[3]];
|
|
1952
|
-
return new Uint8Array(aCmd);
|
|
1953
|
-
}
|
|
1954
|
-
//回放暂停
|
|
1955
|
-
pauseCmd() {
|
|
1956
|
-
let aCmd = [/*header*/0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00];
|
|
1957
|
-
return new Uint8Array(aCmd);
|
|
1958
|
-
}
|
|
1959
|
-
//恢复命令
|
|
1960
|
-
resumeCmd() {
|
|
1961
|
-
let aCmd = [/*header*/0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00];
|
|
1962
|
-
return new Uint8Array(aCmd);
|
|
1963
|
-
}
|
|
1964
|
-
}
|
|
1965
|
-
return DeviceDirect;
|
|
1966
|
-
}();
|
|
1967
|
-
|
|
1968
|
-
// CONCATENATED MODULE: ./directDevice.js
|
|
1969
|
-
/**
|
|
1970
|
-
* @synopsis 直连设备取流
|
|
1971
|
-
*
|
|
1972
|
-
* @note [ADD][2017-07-28]新建 by fengzhongjian
|
|
1973
|
-
*
|
|
1974
|
-
*/
|
|
1975
|
-
const ERROR_STREAM_UNKNOWN = 3001; //未知取流错误
|
|
1976
|
-
const ERROR_STREAM_LIMIT = 3002; //资源上限
|
|
1977
|
-
const ERROR_BAD_AUTH = 3003; //认证失败
|
|
1978
|
-
|
|
1979
|
-
let DirectDevice = function () {
|
|
1980
|
-
class DeviceDirect {
|
|
1981
|
-
constructor() {}
|
|
1982
|
-
//to do
|
|
1983
|
-
|
|
1984
|
-
//创建取流客户端对象
|
|
1985
|
-
createClientObject(oWebsocket, szId, szPlayURL) {
|
|
1986
|
-
return {
|
|
1987
|
-
socket: oWebsocket,
|
|
1988
|
-
id: szId,
|
|
1989
|
-
playURL: szPlayURL,
|
|
1990
|
-
resolve: null,
|
|
1991
|
-
reject: null
|
|
1992
|
-
};
|
|
1993
|
-
}
|
|
1994
|
-
//从sdp信息获取媒体头
|
|
1995
|
-
getMediaFromSdp(szSdp) {
|
|
1996
|
-
let iMediaIndex = szSdp.indexOf("MEDIAINFO=") + 10;
|
|
1997
|
-
let szMediaInfo = szSdp.slice(iMediaIndex, iMediaIndex + 80);
|
|
1998
|
-
let aMediaInfo = [];
|
|
1999
|
-
for (let i = 0, iLen = szMediaInfo.length / 2; i < iLen; i++) {
|
|
2000
|
-
aMediaInfo[i] = parseInt(szMediaInfo.slice(i * 2, i * 2 + 2), 16);
|
|
2001
|
-
}
|
|
2002
|
-
return new Uint8Array(aMediaInfo);
|
|
2003
|
-
}
|
|
2004
|
-
//普通通道预览
|
|
2005
|
-
playCmd(szPlayURL) {
|
|
2006
|
-
let oCmd = {
|
|
2007
|
-
sequence: 0,
|
|
2008
|
-
cmd: 'realplay',
|
|
2009
|
-
url: szPlayURL
|
|
2010
|
-
};
|
|
2011
|
-
return JSON.stringify(oCmd);
|
|
2012
|
-
}
|
|
2013
|
-
//回放
|
|
2014
|
-
playbackCmd(szStartTime, szStopTime, szPlayURL) {
|
|
2015
|
-
let oCmd = {
|
|
2016
|
-
sequence: 0,
|
|
2017
|
-
cmd: 'playback',
|
|
2018
|
-
url: szPlayURL,
|
|
2019
|
-
startTime: szStartTime,
|
|
2020
|
-
endTime: szStopTime
|
|
2021
|
-
};
|
|
2022
|
-
return JSON.stringify(oCmd);
|
|
2023
|
-
}
|
|
2024
|
-
//回放速率
|
|
2025
|
-
playRateCmd(iRate) {
|
|
2026
|
-
let oCmd = {
|
|
2027
|
-
sequence: 0,
|
|
2028
|
-
cmd: "changespeed",
|
|
2029
|
-
speed: iRate
|
|
2030
|
-
};
|
|
2031
|
-
return JSON.stringify(oCmd);
|
|
2032
|
-
}
|
|
2033
|
-
//回放暂停
|
|
2034
|
-
pauseCmd() {
|
|
2035
|
-
let oCmd = {
|
|
2036
|
-
sequence: 0,
|
|
2037
|
-
cmd: "pause"
|
|
2038
|
-
};
|
|
2039
|
-
return JSON.stringify(oCmd);
|
|
2040
|
-
}
|
|
2041
|
-
//恢复命令
|
|
2042
|
-
resumeCmd() {
|
|
2043
|
-
let oCmd = {
|
|
2044
|
-
sequence: 0,
|
|
2045
|
-
cmd: "resume"
|
|
2046
|
-
};
|
|
2047
|
-
return JSON.stringify(oCmd);
|
|
2048
|
-
}
|
|
2049
|
-
//获取取流错误
|
|
2050
|
-
getError(oError) {
|
|
2051
|
-
let iErrorNum = ERROR_STREAM_UNKNOWN;
|
|
2052
|
-
if (oError) {
|
|
2053
|
-
if (parseInt(oError.statusCode, 10) === 6 && oError.subStatusCode === "streamLimit") {
|
|
2054
|
-
iErrorNum = ERROR_STREAM_LIMIT;
|
|
2055
|
-
} else if (parseInt(oError.statusCode, 10) === 4 && oError.subStatusCode === "badAuthorization") {
|
|
2056
|
-
iErrorNum = ERROR_BAD_AUTH;
|
|
2057
|
-
}
|
|
2058
|
-
}
|
|
2059
|
-
return {
|
|
2060
|
-
iErrorNum: iErrorNum,
|
|
2061
|
-
oError: oError
|
|
2062
|
-
};
|
|
2063
|
-
}
|
|
2064
|
-
}
|
|
2065
|
-
return DeviceDirect;
|
|
2066
|
-
}();
|
|
2067
|
-
|
|
2068
|
-
// EXTERNAL MODULE: ./tool/cryptico.js
|
|
2069
|
-
var cryptico = __webpack_require__(0);
|
|
2070
|
-
var cryptico_default = /*#__PURE__*/__webpack_require__.n(cryptico);
|
|
2071
|
-
|
|
2072
|
-
// CONCATENATED MODULE: ./tool/aes.js
|
|
2073
|
-
/*
|
|
2074
|
-
CryptoJS v3.1.2
|
|
2075
|
-
code.google.com/p/crypto-js
|
|
2076
|
-
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
|
2077
|
-
code.google.com/p/crypto-js/wiki/License
|
|
2078
|
-
*/
|
|
2079
|
-
var CryptoJS = CryptoJS || function (u, p) {
|
|
2080
|
-
var d = {},
|
|
2081
|
-
l = d.lib = {},
|
|
2082
|
-
s = function () {},
|
|
2083
|
-
t = l.Base = {
|
|
2084
|
-
extend: function (a) {
|
|
2085
|
-
s.prototype = this;
|
|
2086
|
-
var c = new s();
|
|
2087
|
-
a && c.mixIn(a);
|
|
2088
|
-
c.hasOwnProperty("init") || (c.init = function () {
|
|
2089
|
-
c.$super.init.apply(this, arguments);
|
|
2090
|
-
});
|
|
2091
|
-
c.init.prototype = c;
|
|
2092
|
-
c.$super = this;
|
|
2093
|
-
return c;
|
|
2094
|
-
},
|
|
2095
|
-
create: function () {
|
|
2096
|
-
var a = this.extend();
|
|
2097
|
-
a.init.apply(a, arguments);
|
|
2098
|
-
return a;
|
|
2099
|
-
},
|
|
2100
|
-
init: function () {},
|
|
2101
|
-
mixIn: function (a) {
|
|
2102
|
-
for (var c in a) a.hasOwnProperty(c) && (this[c] = a[c]);
|
|
2103
|
-
a.hasOwnProperty("toString") && (this.toString = a.toString);
|
|
2104
|
-
},
|
|
2105
|
-
clone: function () {
|
|
2106
|
-
return this.init.prototype.extend(this);
|
|
2107
|
-
}
|
|
2108
|
-
},
|
|
2109
|
-
r = l.WordArray = t.extend({
|
|
2110
|
-
init: function (a, c) {
|
|
2111
|
-
a = this.words = a || [];
|
|
2112
|
-
this.sigBytes = c != p ? c : 4 * a.length;
|
|
2113
|
-
},
|
|
2114
|
-
toString: function (a) {
|
|
2115
|
-
return (a || v).stringify(this);
|
|
2116
|
-
},
|
|
2117
|
-
concat: function (a) {
|
|
2118
|
-
var c = this.words,
|
|
2119
|
-
e = a.words,
|
|
2120
|
-
j = this.sigBytes;
|
|
2121
|
-
a = a.sigBytes;
|
|
2122
|
-
this.clamp();
|
|
2123
|
-
if (j % 4) for (var k = 0; k < a; k++) c[j + k >>> 2] |= (e[k >>> 2] >>> 24 - 8 * (k % 4) & 255) << 24 - 8 * ((j + k) % 4);else if (65535 < e.length) for (k = 0; k < a; k += 4) c[j + k >>> 2] = e[k >>> 2];else c.push.apply(c, e);
|
|
2124
|
-
this.sigBytes += a;
|
|
2125
|
-
return this;
|
|
2126
|
-
},
|
|
2127
|
-
clamp: function () {
|
|
2128
|
-
var a = this.words,
|
|
2129
|
-
c = this.sigBytes;
|
|
2130
|
-
a[c >>> 2] &= 4294967295 << 32 - 8 * (c % 4);
|
|
2131
|
-
a.length = u.ceil(c / 4);
|
|
2132
|
-
},
|
|
2133
|
-
clone: function () {
|
|
2134
|
-
var a = t.clone.call(this);
|
|
2135
|
-
a.words = this.words.slice(0);
|
|
2136
|
-
return a;
|
|
2137
|
-
},
|
|
2138
|
-
random: function (a) {
|
|
2139
|
-
for (var c = [], e = 0; e < a; e += 4) c.push(4294967296 * u.random() | 0);
|
|
2140
|
-
return new r.init(c, a);
|
|
2141
|
-
}
|
|
2142
|
-
}),
|
|
2143
|
-
w = d.enc = {},
|
|
2144
|
-
v = w.Hex = {
|
|
2145
|
-
stringify: function (a) {
|
|
2146
|
-
var c = a.words;
|
|
2147
|
-
a = a.sigBytes;
|
|
2148
|
-
for (var e = [], j = 0; j < a; j++) {
|
|
2149
|
-
var k = c[j >>> 2] >>> 24 - 8 * (j % 4) & 255;
|
|
2150
|
-
e.push((k >>> 4).toString(16));
|
|
2151
|
-
e.push((k & 15).toString(16));
|
|
2152
|
-
}
|
|
2153
|
-
return e.join("");
|
|
2154
|
-
},
|
|
2155
|
-
parse: function (a) {
|
|
2156
|
-
for (var c = a.length, e = [], j = 0; j < c; j += 2) e[j >>> 3] |= parseInt(a.substr(j, 2), 16) << 24 - 4 * (j % 8);
|
|
2157
|
-
return new r.init(e, c / 2);
|
|
2158
|
-
}
|
|
2159
|
-
},
|
|
2160
|
-
b = w.Latin1 = {
|
|
2161
|
-
stringify: function (a) {
|
|
2162
|
-
var c = a.words;
|
|
2163
|
-
a = a.sigBytes;
|
|
2164
|
-
for (var e = [], j = 0; j < a; j++) e.push(String.fromCharCode(c[j >>> 2] >>> 24 - 8 * (j % 4) & 255));
|
|
2165
|
-
return e.join("");
|
|
2166
|
-
},
|
|
2167
|
-
parse: function (a) {
|
|
2168
|
-
for (var c = a.length, e = [], j = 0; j < c; j++) e[j >>> 2] |= (a.charCodeAt(j) & 255) << 24 - 8 * (j % 4);
|
|
2169
|
-
return new r.init(e, c);
|
|
2170
|
-
}
|
|
2171
|
-
},
|
|
2172
|
-
x = w.Utf8 = {
|
|
2173
|
-
stringify: function (a) {
|
|
2174
|
-
try {
|
|
2175
|
-
return decodeURIComponent(escape(b.stringify(a)));
|
|
2176
|
-
} catch (c) {
|
|
2177
|
-
throw Error("Malformed UTF-8 data");
|
|
2178
|
-
}
|
|
2179
|
-
},
|
|
2180
|
-
parse: function (a) {
|
|
2181
|
-
return b.parse(unescape(encodeURIComponent(a)));
|
|
2182
|
-
}
|
|
2183
|
-
},
|
|
2184
|
-
q = l.BufferedBlockAlgorithm = t.extend({
|
|
2185
|
-
reset: function () {
|
|
2186
|
-
this._data = new r.init();
|
|
2187
|
-
this._nDataBytes = 0;
|
|
2188
|
-
},
|
|
2189
|
-
_append: function (a) {
|
|
2190
|
-
"string" == typeof a && (a = x.parse(a));
|
|
2191
|
-
this._data.concat(a);
|
|
2192
|
-
this._nDataBytes += a.sigBytes;
|
|
2193
|
-
},
|
|
2194
|
-
_process: function (a) {
|
|
2195
|
-
var c = this._data,
|
|
2196
|
-
e = c.words,
|
|
2197
|
-
j = c.sigBytes,
|
|
2198
|
-
k = this.blockSize,
|
|
2199
|
-
b = j / (4 * k),
|
|
2200
|
-
b = a ? u.ceil(b) : u.max((b | 0) - this._minBufferSize, 0);
|
|
2201
|
-
a = b * k;
|
|
2202
|
-
j = u.min(4 * a, j);
|
|
2203
|
-
if (a) {
|
|
2204
|
-
for (var q = 0; q < a; q += k) this._doProcessBlock(e, q);
|
|
2205
|
-
q = e.splice(0, a);
|
|
2206
|
-
c.sigBytes -= j;
|
|
2207
|
-
}
|
|
2208
|
-
return new r.init(q, j);
|
|
2209
|
-
},
|
|
2210
|
-
clone: function () {
|
|
2211
|
-
var a = t.clone.call(this);
|
|
2212
|
-
a._data = this._data.clone();
|
|
2213
|
-
return a;
|
|
2214
|
-
},
|
|
2215
|
-
_minBufferSize: 0
|
|
2216
|
-
});
|
|
2217
|
-
l.Hasher = q.extend({
|
|
2218
|
-
cfg: t.extend(),
|
|
2219
|
-
init: function (a) {
|
|
2220
|
-
this.cfg = this.cfg.extend(a);
|
|
2221
|
-
this.reset();
|
|
2222
|
-
},
|
|
2223
|
-
reset: function () {
|
|
2224
|
-
q.reset.call(this);
|
|
2225
|
-
this._doReset();
|
|
2226
|
-
},
|
|
2227
|
-
update: function (a) {
|
|
2228
|
-
this._append(a);
|
|
2229
|
-
this._process();
|
|
2230
|
-
return this;
|
|
2231
|
-
},
|
|
2232
|
-
finalize: function (a) {
|
|
2233
|
-
a && this._append(a);
|
|
2234
|
-
return this._doFinalize();
|
|
2235
|
-
},
|
|
2236
|
-
blockSize: 16,
|
|
2237
|
-
_createHelper: function (a) {
|
|
2238
|
-
return function (b, e) {
|
|
2239
|
-
return new a.init(e).finalize(b);
|
|
2240
|
-
};
|
|
2241
|
-
},
|
|
2242
|
-
_createHmacHelper: function (a) {
|
|
2243
|
-
return function (b, e) {
|
|
2244
|
-
return new n.HMAC.init(a, e).finalize(b);
|
|
2245
|
-
};
|
|
2246
|
-
}
|
|
2247
|
-
});
|
|
2248
|
-
var n = d.algo = {};
|
|
2249
|
-
return d;
|
|
2250
|
-
}(Math);
|
|
2251
|
-
(function () {
|
|
2252
|
-
var u = CryptoJS,
|
|
2253
|
-
p = u.lib.WordArray;
|
|
2254
|
-
u.enc.Base64 = {
|
|
2255
|
-
stringify: function (d) {
|
|
2256
|
-
var l = d.words,
|
|
2257
|
-
p = d.sigBytes,
|
|
2258
|
-
t = this._map;
|
|
2259
|
-
d.clamp();
|
|
2260
|
-
d = [];
|
|
2261
|
-
for (var r = 0; r < p; r += 3) for (var w = (l[r >>> 2] >>> 24 - 8 * (r % 4) & 255) << 16 | (l[r + 1 >>> 2] >>> 24 - 8 * ((r + 1) % 4) & 255) << 8 | l[r + 2 >>> 2] >>> 24 - 8 * ((r + 2) % 4) & 255, v = 0; 4 > v && r + 0.75 * v < p; v++) d.push(t.charAt(w >>> 6 * (3 - v) & 63));
|
|
2262
|
-
if (l = t.charAt(64)) for (; d.length % 4;) d.push(l);
|
|
2263
|
-
return d.join("");
|
|
2264
|
-
},
|
|
2265
|
-
parse: function (d) {
|
|
2266
|
-
var l = d.length,
|
|
2267
|
-
s = this._map,
|
|
2268
|
-
t = s.charAt(64);
|
|
2269
|
-
t && (t = d.indexOf(t), -1 != t && (l = t));
|
|
2270
|
-
for (var t = [], r = 0, w = 0; w < l; w++) if (w % 4) {
|
|
2271
|
-
var v = s.indexOf(d.charAt(w - 1)) << 2 * (w % 4),
|
|
2272
|
-
b = s.indexOf(d.charAt(w)) >>> 6 - 2 * (w % 4);
|
|
2273
|
-
t[r >>> 2] |= (v | b) << 24 - 8 * (r % 4);
|
|
2274
|
-
r++;
|
|
2275
|
-
}
|
|
2276
|
-
return p.create(t, r);
|
|
2277
|
-
},
|
|
2278
|
-
_map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
|
|
2279
|
-
};
|
|
2280
|
-
})();
|
|
2281
|
-
(function (u) {
|
|
2282
|
-
function p(b, n, a, c, e, j, k) {
|
|
2283
|
-
b = b + (n & a | ~n & c) + e + k;
|
|
2284
|
-
return (b << j | b >>> 32 - j) + n;
|
|
2285
|
-
}
|
|
2286
|
-
function d(b, n, a, c, e, j, k) {
|
|
2287
|
-
b = b + (n & c | a & ~c) + e + k;
|
|
2288
|
-
return (b << j | b >>> 32 - j) + n;
|
|
2289
|
-
}
|
|
2290
|
-
function l(b, n, a, c, e, j, k) {
|
|
2291
|
-
b = b + (n ^ a ^ c) + e + k;
|
|
2292
|
-
return (b << j | b >>> 32 - j) + n;
|
|
2293
|
-
}
|
|
2294
|
-
function s(b, n, a, c, e, j, k) {
|
|
2295
|
-
b = b + (a ^ (n | ~c)) + e + k;
|
|
2296
|
-
return (b << j | b >>> 32 - j) + n;
|
|
2297
|
-
}
|
|
2298
|
-
for (var t = CryptoJS, r = t.lib, w = r.WordArray, v = r.Hasher, r = t.algo, b = [], x = 0; 64 > x; x++) b[x] = 4294967296 * u.abs(u.sin(x + 1)) | 0;
|
|
2299
|
-
r = r.MD5 = v.extend({
|
|
2300
|
-
_doReset: function () {
|
|
2301
|
-
this._hash = new w.init([1732584193, 4023233417, 2562383102, 271733878]);
|
|
2302
|
-
},
|
|
2303
|
-
_doProcessBlock: function (q, n) {
|
|
2304
|
-
for (var a = 0; 16 > a; a++) {
|
|
2305
|
-
var c = n + a,
|
|
2306
|
-
e = q[c];
|
|
2307
|
-
q[c] = (e << 8 | e >>> 24) & 16711935 | (e << 24 | e >>> 8) & 4278255360;
|
|
2308
|
-
}
|
|
2309
|
-
var a = this._hash.words,
|
|
2310
|
-
c = q[n + 0],
|
|
2311
|
-
e = q[n + 1],
|
|
2312
|
-
j = q[n + 2],
|
|
2313
|
-
k = q[n + 3],
|
|
2314
|
-
z = q[n + 4],
|
|
2315
|
-
r = q[n + 5],
|
|
2316
|
-
t = q[n + 6],
|
|
2317
|
-
w = q[n + 7],
|
|
2318
|
-
v = q[n + 8],
|
|
2319
|
-
A = q[n + 9],
|
|
2320
|
-
B = q[n + 10],
|
|
2321
|
-
C = q[n + 11],
|
|
2322
|
-
u = q[n + 12],
|
|
2323
|
-
D = q[n + 13],
|
|
2324
|
-
E = q[n + 14],
|
|
2325
|
-
x = q[n + 15],
|
|
2326
|
-
f = a[0],
|
|
2327
|
-
m = a[1],
|
|
2328
|
-
g = a[2],
|
|
2329
|
-
h = a[3],
|
|
2330
|
-
f = p(f, m, g, h, c, 7, b[0]),
|
|
2331
|
-
h = p(h, f, m, g, e, 12, b[1]),
|
|
2332
|
-
g = p(g, h, f, m, j, 17, b[2]),
|
|
2333
|
-
m = p(m, g, h, f, k, 22, b[3]),
|
|
2334
|
-
f = p(f, m, g, h, z, 7, b[4]),
|
|
2335
|
-
h = p(h, f, m, g, r, 12, b[5]),
|
|
2336
|
-
g = p(g, h, f, m, t, 17, b[6]),
|
|
2337
|
-
m = p(m, g, h, f, w, 22, b[7]),
|
|
2338
|
-
f = p(f, m, g, h, v, 7, b[8]),
|
|
2339
|
-
h = p(h, f, m, g, A, 12, b[9]),
|
|
2340
|
-
g = p(g, h, f, m, B, 17, b[10]),
|
|
2341
|
-
m = p(m, g, h, f, C, 22, b[11]),
|
|
2342
|
-
f = p(f, m, g, h, u, 7, b[12]),
|
|
2343
|
-
h = p(h, f, m, g, D, 12, b[13]),
|
|
2344
|
-
g = p(g, h, f, m, E, 17, b[14]),
|
|
2345
|
-
m = p(m, g, h, f, x, 22, b[15]),
|
|
2346
|
-
f = d(f, m, g, h, e, 5, b[16]),
|
|
2347
|
-
h = d(h, f, m, g, t, 9, b[17]),
|
|
2348
|
-
g = d(g, h, f, m, C, 14, b[18]),
|
|
2349
|
-
m = d(m, g, h, f, c, 20, b[19]),
|
|
2350
|
-
f = d(f, m, g, h, r, 5, b[20]),
|
|
2351
|
-
h = d(h, f, m, g, B, 9, b[21]),
|
|
2352
|
-
g = d(g, h, f, m, x, 14, b[22]),
|
|
2353
|
-
m = d(m, g, h, f, z, 20, b[23]),
|
|
2354
|
-
f = d(f, m, g, h, A, 5, b[24]),
|
|
2355
|
-
h = d(h, f, m, g, E, 9, b[25]),
|
|
2356
|
-
g = d(g, h, f, m, k, 14, b[26]),
|
|
2357
|
-
m = d(m, g, h, f, v, 20, b[27]),
|
|
2358
|
-
f = d(f, m, g, h, D, 5, b[28]),
|
|
2359
|
-
h = d(h, f, m, g, j, 9, b[29]),
|
|
2360
|
-
g = d(g, h, f, m, w, 14, b[30]),
|
|
2361
|
-
m = d(m, g, h, f, u, 20, b[31]),
|
|
2362
|
-
f = l(f, m, g, h, r, 4, b[32]),
|
|
2363
|
-
h = l(h, f, m, g, v, 11, b[33]),
|
|
2364
|
-
g = l(g, h, f, m, C, 16, b[34]),
|
|
2365
|
-
m = l(m, g, h, f, E, 23, b[35]),
|
|
2366
|
-
f = l(f, m, g, h, e, 4, b[36]),
|
|
2367
|
-
h = l(h, f, m, g, z, 11, b[37]),
|
|
2368
|
-
g = l(g, h, f, m, w, 16, b[38]),
|
|
2369
|
-
m = l(m, g, h, f, B, 23, b[39]),
|
|
2370
|
-
f = l(f, m, g, h, D, 4, b[40]),
|
|
2371
|
-
h = l(h, f, m, g, c, 11, b[41]),
|
|
2372
|
-
g = l(g, h, f, m, k, 16, b[42]),
|
|
2373
|
-
m = l(m, g, h, f, t, 23, b[43]),
|
|
2374
|
-
f = l(f, m, g, h, A, 4, b[44]),
|
|
2375
|
-
h = l(h, f, m, g, u, 11, b[45]),
|
|
2376
|
-
g = l(g, h, f, m, x, 16, b[46]),
|
|
2377
|
-
m = l(m, g, h, f, j, 23, b[47]),
|
|
2378
|
-
f = s(f, m, g, h, c, 6, b[48]),
|
|
2379
|
-
h = s(h, f, m, g, w, 10, b[49]),
|
|
2380
|
-
g = s(g, h, f, m, E, 15, b[50]),
|
|
2381
|
-
m = s(m, g, h, f, r, 21, b[51]),
|
|
2382
|
-
f = s(f, m, g, h, u, 6, b[52]),
|
|
2383
|
-
h = s(h, f, m, g, k, 10, b[53]),
|
|
2384
|
-
g = s(g, h, f, m, B, 15, b[54]),
|
|
2385
|
-
m = s(m, g, h, f, e, 21, b[55]),
|
|
2386
|
-
f = s(f, m, g, h, v, 6, b[56]),
|
|
2387
|
-
h = s(h, f, m, g, x, 10, b[57]),
|
|
2388
|
-
g = s(g, h, f, m, t, 15, b[58]),
|
|
2389
|
-
m = s(m, g, h, f, D, 21, b[59]),
|
|
2390
|
-
f = s(f, m, g, h, z, 6, b[60]),
|
|
2391
|
-
h = s(h, f, m, g, C, 10, b[61]),
|
|
2392
|
-
g = s(g, h, f, m, j, 15, b[62]),
|
|
2393
|
-
m = s(m, g, h, f, A, 21, b[63]);
|
|
2394
|
-
a[0] = a[0] + f | 0;
|
|
2395
|
-
a[1] = a[1] + m | 0;
|
|
2396
|
-
a[2] = a[2] + g | 0;
|
|
2397
|
-
a[3] = a[3] + h | 0;
|
|
2398
|
-
},
|
|
2399
|
-
_doFinalize: function () {
|
|
2400
|
-
var b = this._data,
|
|
2401
|
-
n = b.words,
|
|
2402
|
-
a = 8 * this._nDataBytes,
|
|
2403
|
-
c = 8 * b.sigBytes;
|
|
2404
|
-
n[c >>> 5] |= 128 << 24 - c % 32;
|
|
2405
|
-
var e = u.floor(a / 4294967296);
|
|
2406
|
-
n[(c + 64 >>> 9 << 4) + 15] = (e << 8 | e >>> 24) & 16711935 | (e << 24 | e >>> 8) & 4278255360;
|
|
2407
|
-
n[(c + 64 >>> 9 << 4) + 14] = (a << 8 | a >>> 24) & 16711935 | (a << 24 | a >>> 8) & 4278255360;
|
|
2408
|
-
b.sigBytes = 4 * (n.length + 1);
|
|
2409
|
-
this._process();
|
|
2410
|
-
b = this._hash;
|
|
2411
|
-
n = b.words;
|
|
2412
|
-
for (a = 0; 4 > a; a++) c = n[a], n[a] = (c << 8 | c >>> 24) & 16711935 | (c << 24 | c >>> 8) & 4278255360;
|
|
2413
|
-
return b;
|
|
2414
|
-
},
|
|
2415
|
-
clone: function () {
|
|
2416
|
-
var b = v.clone.call(this);
|
|
2417
|
-
b._hash = this._hash.clone();
|
|
2418
|
-
return b;
|
|
2419
|
-
}
|
|
2420
|
-
});
|
|
2421
|
-
t.MD5 = v._createHelper(r);
|
|
2422
|
-
t.HmacMD5 = v._createHmacHelper(r);
|
|
2423
|
-
})(Math);
|
|
2424
|
-
(function () {
|
|
2425
|
-
var u = CryptoJS,
|
|
2426
|
-
p = u.lib,
|
|
2427
|
-
d = p.Base,
|
|
2428
|
-
l = p.WordArray,
|
|
2429
|
-
p = u.algo,
|
|
2430
|
-
s = p.EvpKDF = d.extend({
|
|
2431
|
-
cfg: d.extend({
|
|
2432
|
-
keySize: 4,
|
|
2433
|
-
hasher: p.MD5,
|
|
2434
|
-
iterations: 1
|
|
2435
|
-
}),
|
|
2436
|
-
init: function (d) {
|
|
2437
|
-
this.cfg = this.cfg.extend(d);
|
|
2438
|
-
},
|
|
2439
|
-
compute: function (d, r) {
|
|
2440
|
-
for (var p = this.cfg, s = p.hasher.create(), b = l.create(), u = b.words, q = p.keySize, p = p.iterations; u.length < q;) {
|
|
2441
|
-
n && s.update(n);
|
|
2442
|
-
var n = s.update(d).finalize(r);
|
|
2443
|
-
s.reset();
|
|
2444
|
-
for (var a = 1; a < p; a++) n = s.finalize(n), s.reset();
|
|
2445
|
-
b.concat(n);
|
|
2446
|
-
}
|
|
2447
|
-
b.sigBytes = 4 * q;
|
|
2448
|
-
return b;
|
|
2449
|
-
}
|
|
2450
|
-
});
|
|
2451
|
-
u.EvpKDF = function (d, l, p) {
|
|
2452
|
-
return s.create(p).compute(d, l);
|
|
2453
|
-
};
|
|
2454
|
-
})();
|
|
2455
|
-
CryptoJS.lib.Cipher || function (u) {
|
|
2456
|
-
var p = CryptoJS,
|
|
2457
|
-
d = p.lib,
|
|
2458
|
-
l = d.Base,
|
|
2459
|
-
s = d.WordArray,
|
|
2460
|
-
t = d.BufferedBlockAlgorithm,
|
|
2461
|
-
r = p.enc.Base64,
|
|
2462
|
-
w = p.algo.EvpKDF,
|
|
2463
|
-
v = d.Cipher = t.extend({
|
|
2464
|
-
cfg: l.extend(),
|
|
2465
|
-
createEncryptor: function (e, a) {
|
|
2466
|
-
return this.create(this._ENC_XFORM_MODE, e, a);
|
|
2467
|
-
},
|
|
2468
|
-
createDecryptor: function (e, a) {
|
|
2469
|
-
return this.create(this._DEC_XFORM_MODE, e, a);
|
|
2470
|
-
},
|
|
2471
|
-
init: function (e, a, b) {
|
|
2472
|
-
this.cfg = this.cfg.extend(b);
|
|
2473
|
-
this._xformMode = e;
|
|
2474
|
-
this._key = a;
|
|
2475
|
-
this.reset();
|
|
2476
|
-
},
|
|
2477
|
-
reset: function () {
|
|
2478
|
-
t.reset.call(this);
|
|
2479
|
-
this._doReset();
|
|
2480
|
-
},
|
|
2481
|
-
process: function (e) {
|
|
2482
|
-
this._append(e);
|
|
2483
|
-
return this._process();
|
|
2484
|
-
},
|
|
2485
|
-
finalize: function (e) {
|
|
2486
|
-
e && this._append(e);
|
|
2487
|
-
return this._doFinalize();
|
|
2488
|
-
},
|
|
2489
|
-
keySize: 4,
|
|
2490
|
-
ivSize: 4,
|
|
2491
|
-
_ENC_XFORM_MODE: 1,
|
|
2492
|
-
_DEC_XFORM_MODE: 2,
|
|
2493
|
-
_createHelper: function (e) {
|
|
2494
|
-
return {
|
|
2495
|
-
encrypt: function (b, k, d) {
|
|
2496
|
-
return ("string" == typeof k ? c : a).encrypt(e, b, k, d);
|
|
2497
|
-
},
|
|
2498
|
-
decrypt: function (b, k, d) {
|
|
2499
|
-
return ("string" == typeof k ? c : a).decrypt(e, b, k, d);
|
|
2500
|
-
}
|
|
2501
|
-
};
|
|
2502
|
-
}
|
|
2503
|
-
});
|
|
2504
|
-
d.StreamCipher = v.extend({
|
|
2505
|
-
_doFinalize: function () {
|
|
2506
|
-
return this._process(!0);
|
|
2507
|
-
},
|
|
2508
|
-
blockSize: 1
|
|
2509
|
-
});
|
|
2510
|
-
var b = p.mode = {},
|
|
2511
|
-
x = function (e, a, b) {
|
|
2512
|
-
var c = this._iv;
|
|
2513
|
-
c ? this._iv = u : c = this._prevBlock;
|
|
2514
|
-
for (var d = 0; d < b; d++) e[a + d] ^= c[d];
|
|
2515
|
-
},
|
|
2516
|
-
q = (d.BlockCipherMode = l.extend({
|
|
2517
|
-
createEncryptor: function (e, a) {
|
|
2518
|
-
return this.Encryptor.create(e, a);
|
|
2519
|
-
},
|
|
2520
|
-
createDecryptor: function (e, a) {
|
|
2521
|
-
return this.Decryptor.create(e, a);
|
|
2522
|
-
},
|
|
2523
|
-
init: function (e, a) {
|
|
2524
|
-
this._cipher = e;
|
|
2525
|
-
this._iv = a;
|
|
2526
|
-
}
|
|
2527
|
-
})).extend();
|
|
2528
|
-
q.Encryptor = q.extend({
|
|
2529
|
-
processBlock: function (e, a) {
|
|
2530
|
-
var b = this._cipher,
|
|
2531
|
-
c = b.blockSize;
|
|
2532
|
-
x.call(this, e, a, c);
|
|
2533
|
-
b.encryptBlock(e, a);
|
|
2534
|
-
this._prevBlock = e.slice(a, a + c);
|
|
2535
|
-
}
|
|
2536
|
-
});
|
|
2537
|
-
q.Decryptor = q.extend({
|
|
2538
|
-
processBlock: function (e, a) {
|
|
2539
|
-
var b = this._cipher,
|
|
2540
|
-
c = b.blockSize,
|
|
2541
|
-
d = e.slice(a, a + c);
|
|
2542
|
-
b.decryptBlock(e, a);
|
|
2543
|
-
x.call(this, e, a, c);
|
|
2544
|
-
this._prevBlock = d;
|
|
2545
|
-
}
|
|
2546
|
-
});
|
|
2547
|
-
b = b.CBC = q;
|
|
2548
|
-
q = (p.pad = {}).Pkcs7 = {
|
|
2549
|
-
pad: function (a, b) {
|
|
2550
|
-
for (var c = 4 * b, c = c - a.sigBytes % c, d = c << 24 | c << 16 | c << 8 | c, l = [], n = 0; n < c; n += 4) l.push(d);
|
|
2551
|
-
c = s.create(l, c);
|
|
2552
|
-
a.concat(c);
|
|
2553
|
-
},
|
|
2554
|
-
unpad: function (a) {
|
|
2555
|
-
a.sigBytes -= a.words[a.sigBytes - 1 >>> 2] & 255;
|
|
2556
|
-
}
|
|
2557
|
-
};
|
|
2558
|
-
d.BlockCipher = v.extend({
|
|
2559
|
-
cfg: v.cfg.extend({
|
|
2560
|
-
mode: b,
|
|
2561
|
-
padding: q
|
|
2562
|
-
}),
|
|
2563
|
-
reset: function () {
|
|
2564
|
-
v.reset.call(this);
|
|
2565
|
-
var a = this.cfg,
|
|
2566
|
-
b = a.iv,
|
|
2567
|
-
a = a.mode;
|
|
2568
|
-
if (this._xformMode == this._ENC_XFORM_MODE) var c = a.createEncryptor;else c = a.createDecryptor, this._minBufferSize = 1;
|
|
2569
|
-
this._mode = c.call(a, this, b && b.words);
|
|
2570
|
-
},
|
|
2571
|
-
_doProcessBlock: function (a, b) {
|
|
2572
|
-
this._mode.processBlock(a, b);
|
|
2573
|
-
},
|
|
2574
|
-
_doFinalize: function () {
|
|
2575
|
-
var a = this.cfg.padding;
|
|
2576
|
-
if (this._xformMode == this._ENC_XFORM_MODE) {
|
|
2577
|
-
a.pad(this._data, this.blockSize);
|
|
2578
|
-
var b = this._process(!0);
|
|
2579
|
-
} else b = this._process(!0), a.unpad(b);
|
|
2580
|
-
return b;
|
|
2581
|
-
},
|
|
2582
|
-
blockSize: 4
|
|
2583
|
-
});
|
|
2584
|
-
var n = d.CipherParams = l.extend({
|
|
2585
|
-
init: function (a) {
|
|
2586
|
-
this.mixIn(a);
|
|
2587
|
-
},
|
|
2588
|
-
toString: function (a) {
|
|
2589
|
-
return (a || this.formatter).stringify(this);
|
|
2590
|
-
}
|
|
2591
|
-
}),
|
|
2592
|
-
b = (p.format = {}).OpenSSL = {
|
|
2593
|
-
stringify: function (a) {
|
|
2594
|
-
var b = a.ciphertext;
|
|
2595
|
-
a = a.salt;
|
|
2596
|
-
return (a ? s.create([1398893684, 1701076831]).concat(a).concat(b) : b).toString(r);
|
|
2597
|
-
},
|
|
2598
|
-
parse: function (a) {
|
|
2599
|
-
a = r.parse(a);
|
|
2600
|
-
var b = a.words;
|
|
2601
|
-
if (1398893684 == b[0] && 1701076831 == b[1]) {
|
|
2602
|
-
var c = s.create(b.slice(2, 4));
|
|
2603
|
-
b.splice(0, 4);
|
|
2604
|
-
a.sigBytes -= 16;
|
|
2605
|
-
}
|
|
2606
|
-
return n.create({
|
|
2607
|
-
ciphertext: a,
|
|
2608
|
-
salt: c
|
|
2609
|
-
});
|
|
2610
|
-
}
|
|
2611
|
-
},
|
|
2612
|
-
a = d.SerializableCipher = l.extend({
|
|
2613
|
-
cfg: l.extend({
|
|
2614
|
-
format: b
|
|
2615
|
-
}),
|
|
2616
|
-
encrypt: function (a, b, c, d) {
|
|
2617
|
-
d = this.cfg.extend(d);
|
|
2618
|
-
var l = a.createEncryptor(c, d);
|
|
2619
|
-
b = l.finalize(b);
|
|
2620
|
-
l = l.cfg;
|
|
2621
|
-
return n.create({
|
|
2622
|
-
ciphertext: b,
|
|
2623
|
-
key: c,
|
|
2624
|
-
iv: l.iv,
|
|
2625
|
-
algorithm: a,
|
|
2626
|
-
mode: l.mode,
|
|
2627
|
-
padding: l.padding,
|
|
2628
|
-
blockSize: a.blockSize,
|
|
2629
|
-
formatter: d.format
|
|
2630
|
-
});
|
|
2631
|
-
},
|
|
2632
|
-
decrypt: function (a, b, c, d) {
|
|
2633
|
-
d = this.cfg.extend(d);
|
|
2634
|
-
b = this._parse(b, d.format);
|
|
2635
|
-
return a.createDecryptor(c, d).finalize(b.ciphertext);
|
|
2636
|
-
},
|
|
2637
|
-
_parse: function (a, b) {
|
|
2638
|
-
return "string" == typeof a ? b.parse(a, this) : a;
|
|
2639
|
-
}
|
|
2640
|
-
}),
|
|
2641
|
-
p = (p.kdf = {}).OpenSSL = {
|
|
2642
|
-
execute: function (a, b, c, d) {
|
|
2643
|
-
d || (d = s.random(8));
|
|
2644
|
-
a = w.create({
|
|
2645
|
-
keySize: b + c
|
|
2646
|
-
}).compute(a, d);
|
|
2647
|
-
c = s.create(a.words.slice(b), 4 * c);
|
|
2648
|
-
a.sigBytes = 4 * b;
|
|
2649
|
-
return n.create({
|
|
2650
|
-
key: a,
|
|
2651
|
-
iv: c,
|
|
2652
|
-
salt: d
|
|
2653
|
-
});
|
|
2654
|
-
}
|
|
2655
|
-
},
|
|
2656
|
-
c = d.PasswordBasedCipher = a.extend({
|
|
2657
|
-
cfg: a.cfg.extend({
|
|
2658
|
-
kdf: p
|
|
2659
|
-
}),
|
|
2660
|
-
encrypt: function (b, c, d, l) {
|
|
2661
|
-
l = this.cfg.extend(l);
|
|
2662
|
-
d = l.kdf.execute(d, b.keySize, b.ivSize);
|
|
2663
|
-
l.iv = d.iv;
|
|
2664
|
-
b = a.encrypt.call(this, b, c, d.key, l);
|
|
2665
|
-
b.mixIn(d);
|
|
2666
|
-
return b;
|
|
2667
|
-
},
|
|
2668
|
-
decrypt: function (b, c, d, l) {
|
|
2669
|
-
l = this.cfg.extend(l);
|
|
2670
|
-
c = this._parse(c, l.format);
|
|
2671
|
-
d = l.kdf.execute(d, b.keySize, b.ivSize, c.salt);
|
|
2672
|
-
l.iv = d.iv;
|
|
2673
|
-
return a.decrypt.call(this, b, c, d.key, l);
|
|
2674
|
-
}
|
|
2675
|
-
});
|
|
2676
|
-
}();
|
|
2677
|
-
(function () {
|
|
2678
|
-
for (var u = CryptoJS, p = u.lib.BlockCipher, d = u.algo, l = [], s = [], t = [], r = [], w = [], v = [], b = [], x = [], q = [], n = [], a = [], c = 0; 256 > c; c++) a[c] = 128 > c ? c << 1 : c << 1 ^ 283;
|
|
2679
|
-
for (var e = 0, j = 0, c = 0; 256 > c; c++) {
|
|
2680
|
-
var k = j ^ j << 1 ^ j << 2 ^ j << 3 ^ j << 4,
|
|
2681
|
-
k = k >>> 8 ^ k & 255 ^ 99;
|
|
2682
|
-
l[e] = k;
|
|
2683
|
-
s[k] = e;
|
|
2684
|
-
var z = a[e],
|
|
2685
|
-
F = a[z],
|
|
2686
|
-
G = a[F],
|
|
2687
|
-
y = 257 * a[k] ^ 16843008 * k;
|
|
2688
|
-
t[e] = y << 24 | y >>> 8;
|
|
2689
|
-
r[e] = y << 16 | y >>> 16;
|
|
2690
|
-
w[e] = y << 8 | y >>> 24;
|
|
2691
|
-
v[e] = y;
|
|
2692
|
-
y = 16843009 * G ^ 65537 * F ^ 257 * z ^ 16843008 * e;
|
|
2693
|
-
b[k] = y << 24 | y >>> 8;
|
|
2694
|
-
x[k] = y << 16 | y >>> 16;
|
|
2695
|
-
q[k] = y << 8 | y >>> 24;
|
|
2696
|
-
n[k] = y;
|
|
2697
|
-
e ? (e = z ^ a[a[a[G ^ z]]], j ^= a[a[j]]) : e = j = 1;
|
|
2698
|
-
}
|
|
2699
|
-
var H = [0, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54],
|
|
2700
|
-
d = d.AES = p.extend({
|
|
2701
|
-
_doReset: function () {
|
|
2702
|
-
for (var a = this._key, c = a.words, d = a.sigBytes / 4, a = 4 * ((this._nRounds = d + 6) + 1), e = this._keySchedule = [], j = 0; j < a; j++) if (j < d) e[j] = c[j];else {
|
|
2703
|
-
var k = e[j - 1];
|
|
2704
|
-
j % d ? 6 < d && 4 == j % d && (k = l[k >>> 24] << 24 | l[k >>> 16 & 255] << 16 | l[k >>> 8 & 255] << 8 | l[k & 255]) : (k = k << 8 | k >>> 24, k = l[k >>> 24] << 24 | l[k >>> 16 & 255] << 16 | l[k >>> 8 & 255] << 8 | l[k & 255], k ^= H[j / d | 0] << 24);
|
|
2705
|
-
e[j] = e[j - d] ^ k;
|
|
2706
|
-
}
|
|
2707
|
-
c = this._invKeySchedule = [];
|
|
2708
|
-
for (d = 0; d < a; d++) j = a - d, k = d % 4 ? e[j] : e[j - 4], c[d] = 4 > d || 4 >= j ? k : b[l[k >>> 24]] ^ x[l[k >>> 16 & 255]] ^ q[l[k >>> 8 & 255]] ^ n[l[k & 255]];
|
|
2709
|
-
},
|
|
2710
|
-
encryptBlock: function (a, b) {
|
|
2711
|
-
this._doCryptBlock(a, b, this._keySchedule, t, r, w, v, l);
|
|
2712
|
-
},
|
|
2713
|
-
decryptBlock: function (a, c) {
|
|
2714
|
-
var d = a[c + 1];
|
|
2715
|
-
a[c + 1] = a[c + 3];
|
|
2716
|
-
a[c + 3] = d;
|
|
2717
|
-
this._doCryptBlock(a, c, this._invKeySchedule, b, x, q, n, s);
|
|
2718
|
-
d = a[c + 1];
|
|
2719
|
-
a[c + 1] = a[c + 3];
|
|
2720
|
-
a[c + 3] = d;
|
|
2721
|
-
},
|
|
2722
|
-
_doCryptBlock: function (a, b, c, d, e, j, l, f) {
|
|
2723
|
-
for (var m = this._nRounds, g = a[b] ^ c[0], h = a[b + 1] ^ c[1], k = a[b + 2] ^ c[2], n = a[b + 3] ^ c[3], p = 4, r = 1; r < m; r++) var q = d[g >>> 24] ^ e[h >>> 16 & 255] ^ j[k >>> 8 & 255] ^ l[n & 255] ^ c[p++], s = d[h >>> 24] ^ e[k >>> 16 & 255] ^ j[n >>> 8 & 255] ^ l[g & 255] ^ c[p++], t = d[k >>> 24] ^ e[n >>> 16 & 255] ^ j[g >>> 8 & 255] ^ l[h & 255] ^ c[p++], n = d[n >>> 24] ^ e[g >>> 16 & 255] ^ j[h >>> 8 & 255] ^ l[k & 255] ^ c[p++], g = q, h = s, k = t;
|
|
2724
|
-
q = (f[g >>> 24] << 24 | f[h >>> 16 & 255] << 16 | f[k >>> 8 & 255] << 8 | f[n & 255]) ^ c[p++];
|
|
2725
|
-
s = (f[h >>> 24] << 24 | f[k >>> 16 & 255] << 16 | f[n >>> 8 & 255] << 8 | f[g & 255]) ^ c[p++];
|
|
2726
|
-
t = (f[k >>> 24] << 24 | f[n >>> 16 & 255] << 16 | f[g >>> 8 & 255] << 8 | f[h & 255]) ^ c[p++];
|
|
2727
|
-
n = (f[n >>> 24] << 24 | f[g >>> 16 & 255] << 16 | f[h >>> 8 & 255] << 8 | f[k & 255]) ^ c[p++];
|
|
2728
|
-
a[b] = q;
|
|
2729
|
-
a[b + 1] = s;
|
|
2730
|
-
a[b + 2] = t;
|
|
2731
|
-
a[b + 3] = n;
|
|
2732
|
-
},
|
|
2733
|
-
keySize: 8
|
|
2734
|
-
});
|
|
2735
|
-
u.AES = p._createHelper(d);
|
|
2736
|
-
})();
|
|
2737
|
-
/* harmony default export */
|
|
2738
|
-
var aes = CryptoJS;
|
|
2739
|
-
// CONCATENATED MODULE: ./liveMedia.js
|
|
2740
|
-
/**
|
|
2741
|
-
* @synopsis 流媒体取流
|
|
2742
|
-
*
|
|
2743
|
-
* @note [ADD][2017-07-28]新建 by fengzhongjian
|
|
2744
|
-
*
|
|
2745
|
-
*/
|
|
2746
|
-
|
|
2747
|
-
let LiveMedia = function () {
|
|
2748
|
-
class MediaLive {
|
|
2749
|
-
constructor() {}
|
|
2750
|
-
//to do
|
|
2751
|
-
|
|
2752
|
-
//创建取流客户端对象
|
|
2753
|
-
createClientObject(oWebsocket, szId, szPKD, szRand, oParams) {
|
|
2754
|
-
let key = aes.AES.encrypt(new Date().getTime().toString(), aes.enc.Hex.parse("1234567891234567123456789123456712345678912345671234567891234567"), {
|
|
2755
|
-
mode: aes.mode.CBC,
|
|
2756
|
-
iv: aes.enc.Hex.parse("12345678912345671234567891234567"),
|
|
2757
|
-
padding: aes.pad.Pkcs7
|
|
2758
|
-
}).ciphertext.toString();
|
|
2759
|
-
if (key.length < 64) {
|
|
2760
|
-
key = key + key;
|
|
2761
|
-
}
|
|
2762
|
-
let iv = aes.AES.encrypt(new Date().getTime().toString(), aes.enc.Hex.parse("12345678912345671234567891234567"), {
|
|
2763
|
-
mode: aes.mode.CBC,
|
|
2764
|
-
iv: aes.enc.Hex.parse("12345678912345671234567891234567"),
|
|
2765
|
-
padding: aes.pad.Pkcs7
|
|
2766
|
-
}).ciphertext.toString();
|
|
2767
|
-
return {
|
|
2768
|
-
socket: oWebsocket,
|
|
2769
|
-
id: szId,
|
|
2770
|
-
PKD: szPKD,
|
|
2771
|
-
rand: szRand,
|
|
2772
|
-
playURL: oParams.playURL || "",
|
|
2773
|
-
auth: oParams.auth || "",
|
|
2774
|
-
token: oParams.token || "",
|
|
2775
|
-
key: key,
|
|
2776
|
-
iv: iv,
|
|
2777
|
-
resolve: null,
|
|
2778
|
-
reject: null
|
|
2779
|
-
};
|
|
2780
|
-
}
|
|
2781
|
-
//预览命令
|
|
2782
|
-
playCmd(oWebsocket) {
|
|
2783
|
-
let oCmd = {
|
|
2784
|
-
sequence: 0,
|
|
2785
|
-
cmd: 'realplay',
|
|
2786
|
-
url: oWebsocket.playURL,
|
|
2787
|
-
key: cryptico_default.a.encrypt(oWebsocket.iv + ":" + oWebsocket.key, oWebsocket.PKD).cipher.split("?")[0],
|
|
2788
|
-
authorization: aes.AES.encrypt(oWebsocket.rand + ":" + oWebsocket.auth, aes.enc.Hex.parse(oWebsocket.key), {
|
|
2789
|
-
mode: aes.mode.CBC,
|
|
2790
|
-
iv: aes.enc.Hex.parse(oWebsocket.iv),
|
|
2791
|
-
padding: aes.pad.Pkcs7
|
|
2792
|
-
}).ciphertext.toString(),
|
|
2793
|
-
token: aes.AES.encrypt(oWebsocket.token, aes.enc.Hex.parse(oWebsocket.key), {
|
|
2794
|
-
mode: aes.mode.CBC,
|
|
2795
|
-
iv: aes.enc.Hex.parse(oWebsocket.iv),
|
|
2796
|
-
padding: aes.pad.Pkcs7
|
|
2797
|
-
}).ciphertext.toString()
|
|
2798
|
-
};
|
|
2799
|
-
return JSON.stringify(oCmd);
|
|
2800
|
-
}
|
|
2801
|
-
//回放
|
|
2802
|
-
playbackCmd(oWebsocket, szStartTime, szStopTime) {
|
|
2803
|
-
let oCmd = {
|
|
2804
|
-
sequence: 0,
|
|
2805
|
-
cmd: 'playback',
|
|
2806
|
-
url: oWebsocket.playURL,
|
|
2807
|
-
key: cryptico_default.a.encrypt(oWebsocket.iv + ":" + oWebsocket.key, oWebsocket.PKD).cipher.split("?")[0],
|
|
2808
|
-
authorization: aes.AES.encrypt(oWebsocket.rand + ":" + oWebsocket.auth, aes.enc.Hex.parse(oWebsocket.key), {
|
|
2809
|
-
mode: aes.mode.CBC,
|
|
2810
|
-
iv: aes.enc.Hex.parse(oWebsocket.iv),
|
|
2811
|
-
padding: aes.pad.Pkcs7
|
|
2812
|
-
}).ciphertext.toString(),
|
|
2813
|
-
token: aes.AES.encrypt(oWebsocket.token, aes.enc.Hex.parse(oWebsocket.key), {
|
|
2814
|
-
mode: aes.mode.CBC,
|
|
2815
|
-
iv: aes.enc.Hex.parse(oWebsocket.iv),
|
|
2816
|
-
padding: aes.pad.Pkcs7
|
|
2817
|
-
}).ciphertext.toString(),
|
|
2818
|
-
startTime: szStartTime,
|
|
2819
|
-
endTime: szStopTime
|
|
2820
|
-
};
|
|
2821
|
-
return JSON.stringify(oCmd);
|
|
2822
|
-
}
|
|
2823
|
-
//定位回放
|
|
2824
|
-
seekCmd(szStartTime, szStopTime) {
|
|
2825
|
-
let oCmd = {
|
|
2826
|
-
sequence: 0,
|
|
2827
|
-
cmd: "seek",
|
|
2828
|
-
startTime: szStartTime,
|
|
2829
|
-
endTime: szStopTime
|
|
2830
|
-
};
|
|
2831
|
-
return JSON.stringify(oCmd);
|
|
2832
|
-
}
|
|
2833
|
-
}
|
|
2834
|
-
return MediaLive;
|
|
2835
|
-
}();
|
|
2836
|
-
|
|
2837
|
-
// CONCATENATED MODULE: ./localService.js
|
|
2838
|
-
/**
|
|
2839
|
-
* @synopsis 本地服务取流
|
|
2840
|
-
*
|
|
2841
|
-
* @note [ADD][2017-07-28]新建 by fengzhongjian
|
|
2842
|
-
*
|
|
2843
|
-
*/
|
|
2844
|
-
let LocalService = function () {
|
|
2845
|
-
class LocalServer {
|
|
2846
|
-
constructor() {}
|
|
2847
|
-
//to do
|
|
2848
|
-
|
|
2849
|
-
//创建取流客户端对象
|
|
2850
|
-
createClientObject(oWebsocket, szId, szPlayURL, oParams) {
|
|
2851
|
-
return {
|
|
2852
|
-
socket: oWebsocket,
|
|
2853
|
-
id: szId,
|
|
2854
|
-
playURL: szPlayURL,
|
|
2855
|
-
deviceSerial: oParams.deviceSerial || "",
|
|
2856
|
-
verificationCode: oParams.verificationCode || "",
|
|
2857
|
-
resolve: null,
|
|
2858
|
-
reject: null
|
|
2859
|
-
};
|
|
2860
|
-
}
|
|
2861
|
-
//普通通道预览
|
|
2862
|
-
playCmd(oWebsocket) {
|
|
2863
|
-
let oCmd = {
|
|
2864
|
-
sequence: 0,
|
|
2865
|
-
cmd: 'realplay',
|
|
2866
|
-
deviceSerial: oWebsocket.deviceSerial,
|
|
2867
|
-
verificationCode: oWebsocket.verificationCode,
|
|
2868
|
-
url: oWebsocket.playURL
|
|
2869
|
-
};
|
|
2870
|
-
return JSON.stringify(oCmd);
|
|
2871
|
-
}
|
|
2872
|
-
//回放
|
|
2873
|
-
playbackCmd(oWebsocket, szStartTime, szStopTime) {
|
|
2874
|
-
let oCmd = {
|
|
2875
|
-
sequence: 0,
|
|
2876
|
-
cmd: 'playback',
|
|
2877
|
-
deviceSerial: oWebsocket.deviceSerial,
|
|
2878
|
-
verificationCode: oWebsocket.verificationCode,
|
|
2879
|
-
url: oWebsocket.playURL,
|
|
2880
|
-
startTime: szStartTime,
|
|
2881
|
-
endTime: szStopTime
|
|
2882
|
-
};
|
|
2883
|
-
return JSON.stringify(oCmd);
|
|
2884
|
-
}
|
|
2885
|
-
}
|
|
2886
|
-
return LocalServer;
|
|
2887
|
-
}();
|
|
2888
|
-
|
|
2889
|
-
// CONCATENATED MODULE: ./streamClient.js
|
|
2890
|
-
|
|
2891
|
-
//定制设备直连取流
|
|
2892
|
-
//设备直连取流
|
|
2893
|
-
//流媒体取流
|
|
2894
|
-
//本地服务取流
|
|
2895
|
-
|
|
2896
|
-
/**
|
|
2897
|
-
* @synopsis 取流类
|
|
2898
|
-
*
|
|
2899
|
-
* @note [ADD][2017-01-03]新建 by fengzhongjian
|
|
2900
|
-
*
|
|
2901
|
-
*/
|
|
2902
|
-
let StreamClient = function () {
|
|
2903
|
-
const WEBSOCKET = Symbol("WEBSOCKET");
|
|
2904
|
-
const GETINDEX = Symbol("GETINDEX");
|
|
2905
|
-
const PROTOCOLVERSION = Symbol("PROTOCOLVERSION");
|
|
2906
|
-
const CIPHERSUITES = Symbol("CIPHERSUITES");
|
|
2907
|
-
let oDirectDeviceCustom = new DirectDeviceCustom(); //定制设备直连取流
|
|
2908
|
-
let oDirectDevice = new DirectDevice(); //设备直连取流
|
|
2909
|
-
let oLiveMedia = new LiveMedia(); //流媒体取流
|
|
2910
|
-
let oLocalService = new LocalService(); //本地服务取流
|
|
2911
|
-
|
|
2912
|
-
class WebsocketClient {
|
|
2913
|
-
constructor() {
|
|
2914
|
-
this[PROTOCOLVERSION] = "0.1"; //协议版本
|
|
2915
|
-
this[CIPHERSUITES] = 0; //秘钥套件
|
|
2916
|
-
this[WEBSOCKET] = []; //websocket对象列表
|
|
2917
|
-
this.ERRORS = {//错误码
|
|
2918
|
-
};
|
|
2919
|
-
//openstream后保存当前通道号和当前码流类型
|
|
2920
|
-
this[GETINDEX] = function (id) {
|
|
2921
|
-
let iIndex = -1;
|
|
2922
|
-
for (let i = 0, iLen = this[WEBSOCKET].length; i < iLen; i++) {
|
|
2923
|
-
if (this[WEBSOCKET][i].id === id) {
|
|
2924
|
-
iIndex = i;
|
|
2925
|
-
break;
|
|
2926
|
-
}
|
|
2927
|
-
}
|
|
2928
|
-
return iIndex;
|
|
2929
|
-
};
|
|
2930
|
-
}
|
|
2931
|
-
/**
|
|
2932
|
-
* @synopsis 开流, 此时设备的流还没有发出来
|
|
2933
|
-
* @param {string} szUrl 取流路径,如ws://hostname:port/channel
|
|
2934
|
-
* @param {object} oParams 取流需要涉及的相关参数
|
|
2935
|
-
* @param {function} cbMessage 消息回调函数
|
|
2936
|
-
* @param {function} cbClose 失败回调
|
|
2937
|
-
* @returns {objcet} 返回Promise对象
|
|
2938
|
-
*/
|
|
2939
|
-
openStream(szUrl, oParams, cbMessage, cbClose) {
|
|
2940
|
-
let bIpv6 = false;
|
|
2941
|
-
if (szUrl.indexOf("[") > -1) {
|
|
2942
|
-
bIpv6 = true;
|
|
2943
|
-
}
|
|
2944
|
-
let that = this;
|
|
2945
|
-
let aUrl = szUrl.split("://"); //szUrl格式为ws://ip:port/channel/stream或wss://ip:port/channel/stream
|
|
2946
|
-
let szProtocol = aUrl[0];
|
|
2947
|
-
let szHostname = "";
|
|
2948
|
-
let iPort = 7681;
|
|
2949
|
-
let iCurChannel = 1;
|
|
2950
|
-
let iCurStream = 0;
|
|
2951
|
-
let bWebSocketVideoCtrlProxy = false; //判断是否是开发包代理模式
|
|
2952
|
-
if (bIpv6) {
|
|
2953
|
-
szHostname = aUrl[1].split("]:")[0] + "]";
|
|
2954
|
-
iPort = Math.floor(aUrl[1].split("]:")[1].split("/")[0]);
|
|
2955
|
-
iCurChannel = Math.floor(aUrl[1].split("]:")[1].split("/")[1] / 100); //通道号
|
|
2956
|
-
iCurStream = Math.floor(aUrl[1].split("]:")[1].split("/")[1] % 100) - 1; //码流类型
|
|
2957
|
-
} else {
|
|
2958
|
-
szHostname = aUrl[1].split(":")[0];
|
|
2959
|
-
iPort = Math.floor(aUrl[1].split(":")[1].split("/")[0]);
|
|
2960
|
-
iCurChannel = Math.floor(aUrl[1].split(":")[1].split("/")[1] / 100); //通道号
|
|
2961
|
-
iCurStream = Math.floor(aUrl[1].split(":")[1].split("/")[1] % 100) - 1; //码流类型
|
|
2962
|
-
let szProxyFlag = aUrl[1].split(":")[1].split("/")[2];
|
|
2963
|
-
if (szProxyFlag !== "" && szProxyFlag === "webSocketVideoCtrlProxy") {
|
|
2964
|
-
bWebSocketVideoCtrlProxy = true;
|
|
2965
|
-
}
|
|
2966
|
-
}
|
|
2967
|
-
if (iCurChannel === 0) {
|
|
2968
|
-
//表示零通道
|
|
2969
|
-
iCurStream = 0;
|
|
2970
|
-
}
|
|
2971
|
-
oParams = oParams || {};
|
|
2972
|
-
let szAuthType = "&sessionID=";
|
|
2973
|
-
if (oParams.token && !oParams.playURL) {
|
|
2974
|
-
//流媒体的token和配套token属性名一样,需要区分
|
|
2975
|
-
szAuthType = "&token=";
|
|
2976
|
-
}
|
|
2977
|
-
let szSessionID = oParams.sessionID || oParams.session || (oParams.playURL ? "" : oParams.token) || "";
|
|
2978
|
-
let oWebsocket = new window.WebSocket(szProtocol + "://" + szHostname + ":" + iPort + (oParams.mode ? "/" + oParams.mode : "") + (bWebSocketVideoCtrlProxy ? "/webSocketVideoCtrlProxy" : "") + "?version=" + that[PROTOCOLVERSION] + "&cipherSuites=" + that[CIPHERSUITES] + szAuthType + szSessionID + (oParams.proxy ? "&proxy=" + oParams.proxy : ""));
|
|
2979
|
-
oWebsocket.binaryType = "arraybuffer";
|
|
2980
|
-
let szId = esm_browser_v4(); //取流uuid,由于区分每条取流连接
|
|
2981
|
-
let iDataIndex = -1;
|
|
2982
|
-
let promise = new Promise(function (resolve, reject) {
|
|
2983
|
-
oWebsocket.onopen = function () {
|
|
2984
|
-
if (!oParams.playURL && !oParams.sessionID && !oParams.deviceSerial && !oParams.token) {
|
|
2985
|
-
//定制设备取流,open就表示成功,因为没有命令码返回
|
|
2986
|
-
that[WEBSOCKET].push(oDirectDeviceCustom.createClientObject(oWebsocket, szId, iCurChannel, iCurStream));
|
|
2987
|
-
resolve(szId);
|
|
2988
|
-
}
|
|
2989
|
-
/*let aTest = [73, 77, 75, 72, 1, 2, 0, 0, 4, 0, 0, 1, 16, 113, 1, 16, 64, 31, 0, 0, 0, 250, 0, 0, 129, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
2990
|
-
cbMessage({
|
|
2991
|
-
bHead: true,
|
|
2992
|
-
buf: aTest
|
|
2993
|
-
});*/ //写死head,本地架websokcet服务时使用
|
|
2994
|
-
};
|
|
2995
|
-
|
|
2996
|
-
oWebsocket.onmessage = function (e) {
|
|
2997
|
-
if (typeof e.data === "string") {
|
|
2998
|
-
let oJSON = JSON.parse(e.data);
|
|
2999
|
-
let iWebsocketIndex = that[GETINDEX](szId);
|
|
3000
|
-
if (oJSON && oJSON.version && oJSON.cipherSuite) {
|
|
3001
|
-
//建立websocket连接成功返回
|
|
3002
|
-
that[PROTOCOLVERSION] = oJSON.version;
|
|
3003
|
-
that[CIPHERSUITES] = parseInt(oJSON.cipherSuite, 10);
|
|
3004
|
-
if (oJSON && oJSON.PKD && oJSON.rand) {
|
|
3005
|
-
that[WEBSOCKET].push(oLiveMedia.createClientObject(oWebsocket, szId, oJSON.PKD, oJSON.rand, oParams)); //流媒体
|
|
3006
|
-
} else {
|
|
3007
|
-
let szPlayURL = "live://" + szHostname + ":" + iPort + "/" + iCurChannel + "/" + iCurStream;
|
|
3008
|
-
if (that[CIPHERSUITES] === -1) {
|
|
3009
|
-
that[WEBSOCKET].push(oLocalService.createClientObject(oWebsocket, szId, szPlayURL, oParams)); //本地服务
|
|
3010
|
-
} else {
|
|
3011
|
-
that[WEBSOCKET].push(oDirectDevice.createClientObject(oWebsocket, szId, szPlayURL)); //基线设备
|
|
3012
|
-
}
|
|
3013
|
-
}
|
|
3014
|
-
|
|
3015
|
-
resolve(szId);
|
|
3016
|
-
return;
|
|
3017
|
-
}
|
|
3018
|
-
if (oJSON && oJSON.sdp) {
|
|
3019
|
-
let aSadpHeadBuf = oDirectDevice.getMediaFromSdp(oJSON.sdp); //获取媒体头
|
|
3020
|
-
cbMessage({
|
|
3021
|
-
bHead: true,
|
|
3022
|
-
buf: aSadpHeadBuf
|
|
3023
|
-
});
|
|
3024
|
-
}
|
|
3025
|
-
if (oJSON && oJSON.cmd) {
|
|
3026
|
-
if (oJSON.cmd === "end") {
|
|
3027
|
-
cbMessage({
|
|
3028
|
-
type: "exception",
|
|
3029
|
-
cmd: oJSON.cmd
|
|
3030
|
-
}); //回放结束
|
|
3031
|
-
}
|
|
3032
|
-
}
|
|
3033
|
-
|
|
3034
|
-
if (oJSON && oJSON.statusString) {
|
|
3035
|
-
if (oJSON.statusString.toLowerCase() === "ok") {
|
|
3036
|
-
if (that[WEBSOCKET][iWebsocketIndex].resolve) {
|
|
3037
|
-
that[WEBSOCKET][iWebsocketIndex].resolve(oJSON);
|
|
3038
|
-
}
|
|
3039
|
-
}
|
|
3040
|
-
if (oJSON.statusString.toLowerCase() !== "ok") {
|
|
3041
|
-
let oError = oDirectDevice.getError(oJSON);
|
|
3042
|
-
if (iWebsocketIndex > -1) {
|
|
3043
|
-
//建立连接即返回错误,此时iWebsocketIndex为-1
|
|
3044
|
-
if (that[WEBSOCKET][iWebsocketIndex].reject) {
|
|
3045
|
-
that[WEBSOCKET][iWebsocketIndex].reject(oError);
|
|
3046
|
-
}
|
|
3047
|
-
} else {
|
|
3048
|
-
reject(oError);
|
|
3049
|
-
}
|
|
3050
|
-
}
|
|
3051
|
-
}
|
|
3052
|
-
} else {
|
|
3053
|
-
let dataObj = {};
|
|
3054
|
-
let dataBuf = new Uint8Array(e.data);
|
|
3055
|
-
iDataIndex++;
|
|
3056
|
-
if (dataBuf.byteLength === 64 || dataBuf.byteLength === 40) {
|
|
3057
|
-
//媒体头包含在第一个64字节的数据包中
|
|
3058
|
-
let iMediaHeadIndex = -1; //回放和预览媒体头位置不一致,需要动态查询媒体头位置
|
|
3059
|
-
let iLen = dataBuf.byteLength;
|
|
3060
|
-
for (let i = 0; i < iLen; i++) {
|
|
3061
|
-
if (dataBuf[i] === 73 && dataBuf[i + 1] === 77 && dataBuf[i + 2] === 75 && dataBuf[i + 3] === 72) {
|
|
3062
|
-
iMediaHeadIndex = i;
|
|
3063
|
-
break;
|
|
3064
|
-
}
|
|
3065
|
-
}
|
|
3066
|
-
if (iMediaHeadIndex !== -1) {
|
|
3067
|
-
let aHeadBuf = dataBuf.slice(iMediaHeadIndex, iMediaHeadIndex + 40);
|
|
3068
|
-
dataObj = {
|
|
3069
|
-
bHead: true,
|
|
3070
|
-
buf: aHeadBuf
|
|
3071
|
-
};
|
|
3072
|
-
} else {
|
|
3073
|
-
dataObj = {
|
|
3074
|
-
bHead: false,
|
|
3075
|
-
buf: dataBuf
|
|
3076
|
-
};
|
|
3077
|
-
}
|
|
3078
|
-
cbMessage(dataObj);
|
|
3079
|
-
} else {
|
|
3080
|
-
if (iDataIndex > 0) {
|
|
3081
|
-
dataObj = {
|
|
3082
|
-
bHead: false,
|
|
3083
|
-
buf: dataBuf
|
|
3084
|
-
};
|
|
3085
|
-
cbMessage(dataObj);
|
|
3086
|
-
}
|
|
3087
|
-
}
|
|
3088
|
-
dataBuf = null;
|
|
3089
|
-
dataObj = null;
|
|
3090
|
-
e = null;
|
|
3091
|
-
}
|
|
3092
|
-
};
|
|
3093
|
-
oWebsocket.onclose = function () {
|
|
3094
|
-
for (let i = 0, iLen = that[WEBSOCKET].length; i < iLen; i++) {
|
|
3095
|
-
if (that[WEBSOCKET][i].id === szId) {
|
|
3096
|
-
that[WEBSOCKET][i].resolve(); //关闭连接后触发该事件表示关闭成功
|
|
3097
|
-
that[WEBSOCKET].splice(i, 1);
|
|
3098
|
-
setTimeout(function () {
|
|
3099
|
-
cbClose();
|
|
3100
|
-
}, 200); //延时触发停止成功回调,保证停止成功
|
|
3101
|
-
|
|
3102
|
-
break;
|
|
3103
|
-
}
|
|
3104
|
-
}
|
|
3105
|
-
reject(); //建立websocket连接时就触发onclose
|
|
3106
|
-
};
|
|
3107
|
-
});
|
|
3108
|
-
|
|
3109
|
-
return promise;
|
|
3110
|
-
}
|
|
3111
|
-
/**
|
|
3112
|
-
* @synopsis 开始取流
|
|
3113
|
-
*
|
|
3114
|
-
* @param {string} id websocket id,在openStream的时候生成
|
|
3115
|
-
@param {string} szStartTime 开始时间
|
|
3116
|
-
@param {string} szStopTime 结束时间
|
|
3117
|
-
* @param {function} cbMessage 码流回调函数
|
|
3118
|
-
*
|
|
3119
|
-
* @returns {object} 返回Promise对象
|
|
3120
|
-
*/
|
|
3121
|
-
startPlay(id, szStartTime, szStopTime) {
|
|
3122
|
-
let that = this;
|
|
3123
|
-
let iWebsocketIndex = this[GETINDEX](id);
|
|
3124
|
-
if (szStartTime && szStopTime && that[PROTOCOLVERSION] === "0.1") {
|
|
3125
|
-
szStartTime = szStartTime.replace(/-/g, "").replace(/:/g, "");
|
|
3126
|
-
szStopTime = szStopTime.replace(/-/g, "").replace(/:/g, "");
|
|
3127
|
-
}
|
|
3128
|
-
let promise = new Promise(function (resolve, reject) {
|
|
3129
|
-
if (iWebsocketIndex > -1) {
|
|
3130
|
-
that[WEBSOCKET][iWebsocketIndex].resolve = resolve;
|
|
3131
|
-
that[WEBSOCKET][iWebsocketIndex].reject = reject;
|
|
3132
|
-
let uIntCmd = null;
|
|
3133
|
-
if (!szStartTime || !szStopTime) {
|
|
3134
|
-
//预览
|
|
3135
|
-
if (that[WEBSOCKET][iWebsocketIndex].iCurChannel === 0 && that[PROTOCOLVERSION] === "0.1") {
|
|
3136
|
-
//零通道预览
|
|
3137
|
-
uIntCmd = oDirectDeviceCustom.zeroPlayCmd(that[WEBSOCKET][iWebsocketIndex].iCurChannel, that[WEBSOCKET][iWebsocketIndex].iCurStream);
|
|
3138
|
-
} else {
|
|
3139
|
-
//普通预览
|
|
3140
|
-
if (that[PROTOCOLVERSION] !== "0.1") {
|
|
3141
|
-
if (that[CIPHERSUITES] === 0) {
|
|
3142
|
-
uIntCmd = oLiveMedia.playCmd(that[WEBSOCKET][iWebsocketIndex]); //流媒体预览
|
|
3143
|
-
} else if (that[CIPHERSUITES] === 1) {
|
|
3144
|
-
uIntCmd = oDirectDevice.playCmd(that[WEBSOCKET][iWebsocketIndex].playURL); //基线普通预览
|
|
3145
|
-
} else if (that[CIPHERSUITES] === -1) {
|
|
3146
|
-
uIntCmd = oLocalService.playCmd(that[WEBSOCKET][iWebsocketIndex]); //本地服务预览
|
|
3147
|
-
}
|
|
3148
|
-
} else {
|
|
3149
|
-
uIntCmd = oDirectDeviceCustom.playCmd(that[WEBSOCKET][iWebsocketIndex].iCurChannel, that[WEBSOCKET][iWebsocketIndex].iCurStream); //定制普通预览
|
|
3150
|
-
}
|
|
3151
|
-
}
|
|
3152
|
-
} else {
|
|
3153
|
-
//回放
|
|
3154
|
-
if (that[PROTOCOLVERSION] !== "0.1") {
|
|
3155
|
-
if (that[CIPHERSUITES] === 0) {
|
|
3156
|
-
uIntCmd = oLiveMedia.playbackCmd(that[WEBSOCKET][iWebsocketIndex], szStartTime, szStopTime); //流媒体回放
|
|
3157
|
-
} else if (that[CIPHERSUITES] === 1) {
|
|
3158
|
-
uIntCmd = oDirectDevice.playbackCmd(szStartTime, szStopTime, that[WEBSOCKET][iWebsocketIndex].playURL); //基线设备回放
|
|
3159
|
-
} else if (that[CIPHERSUITES] === -1) {
|
|
3160
|
-
uIntCmd = oLocalService.playbackCmd(that[WEBSOCKET][iWebsocketIndex], szStartTime, szStopTime); //本地服务回放
|
|
3161
|
-
}
|
|
3162
|
-
} else {
|
|
3163
|
-
//定制设备回放
|
|
3164
|
-
uIntCmd = oDirectDeviceCustom.playbackCmd(szStartTime, szStopTime, that[WEBSOCKET][iWebsocketIndex].iCurChannel, that[WEBSOCKET][iWebsocketIndex].iCurStream);
|
|
3165
|
-
}
|
|
3166
|
-
}
|
|
3167
|
-
that[WEBSOCKET][iWebsocketIndex].socket.send(uIntCmd);
|
|
3168
|
-
if (that[PROTOCOLVERSION] === "0.1") {
|
|
3169
|
-
//定制协议没有返回码,发送后直接认为发送成功
|
|
3170
|
-
resolve();
|
|
3171
|
-
}
|
|
3172
|
-
} else {
|
|
3173
|
-
if (that[PROTOCOLVERSION] === "0.1") {
|
|
3174
|
-
//定制协议没有返回码,发送后直接认为发送成功
|
|
3175
|
-
reject();
|
|
3176
|
-
}
|
|
3177
|
-
}
|
|
3178
|
-
});
|
|
3179
|
-
return promise;
|
|
3180
|
-
}
|
|
3181
|
-
singleFrame() {}
|
|
3182
|
-
//do something
|
|
3183
|
-
|
|
3184
|
-
/**
|
|
3185
|
-
* @synopsis 设置倍率
|
|
3186
|
-
*
|
|
3187
|
-
* @param {string} id websocket id在openStream的时候生成
|
|
3188
|
-
@param {number} iRate 播放倍率
|
|
3189
|
-
*
|
|
3190
|
-
* @returns {object} Promise
|
|
3191
|
-
*/
|
|
3192
|
-
setPlayRate(id, iRate) {
|
|
3193
|
-
let that = this;
|
|
3194
|
-
let promise = new Promise(function (resolve, reject) {
|
|
3195
|
-
for (let i = 0, iLen = that[WEBSOCKET].length; i < iLen; i++) {
|
|
3196
|
-
if (that[WEBSOCKET][i].id === id) {
|
|
3197
|
-
if (that[PROTOCOLVERSION] === "0.1") {
|
|
3198
|
-
let uIntCmd = oDirectDeviceCustom.playRateCmd(iRate); //定制协议快慢放
|
|
3199
|
-
that[WEBSOCKET][i].socket.send(uIntCmd);
|
|
3200
|
-
resolve(); //定制协议没有返回码,发送后直接认为发送成功
|
|
3201
|
-
break;
|
|
3202
|
-
} else {
|
|
3203
|
-
that[WEBSOCKET][i].resolve = resolve;
|
|
3204
|
-
that[WEBSOCKET][i].reject = reject;
|
|
3205
|
-
let szCmd = oDirectDevice.playRateCmd(iRate); //标准协议快慢放
|
|
3206
|
-
that[WEBSOCKET][i].socket.send(szCmd);
|
|
3207
|
-
}
|
|
3208
|
-
}
|
|
3209
|
-
}
|
|
3210
|
-
});
|
|
3211
|
-
return promise;
|
|
3212
|
-
}
|
|
3213
|
-
/**
|
|
3214
|
-
* @synopsis 定位回放
|
|
3215
|
-
*
|
|
3216
|
-
* @param {string} id websocket id在openStream的时候生成
|
|
3217
|
-
@param {string} szStartTime 开始时间
|
|
3218
|
-
@param {string} szStopTime 结束时间
|
|
3219
|
-
*
|
|
3220
|
-
* @returns {object} Promise
|
|
3221
|
-
*/
|
|
3222
|
-
seek(id, szStartTime, szStopTime) {
|
|
3223
|
-
let that = this;
|
|
3224
|
-
let promise = new Promise(function (resolve, reject) {
|
|
3225
|
-
for (let i = 0, iLen = that[WEBSOCKET].length; i < iLen; i++) {
|
|
3226
|
-
if (that[WEBSOCKET][i].id === id) {
|
|
3227
|
-
that[WEBSOCKET][i].resolve = resolve;
|
|
3228
|
-
that[WEBSOCKET][i].reject = reject;
|
|
3229
|
-
let szCmd = oLiveMedia.seekCmd(szStartTime, szStopTime);
|
|
3230
|
-
that[WEBSOCKET][i].socket.send(szCmd);
|
|
3231
|
-
}
|
|
3232
|
-
}
|
|
3233
|
-
});
|
|
3234
|
-
return promise;
|
|
3235
|
-
}
|
|
3236
|
-
/**
|
|
3237
|
-
* @synopsis 暂停取流
|
|
3238
|
-
*
|
|
3239
|
-
* @param {string} id websocket id,在openStream的时候生成
|
|
3240
|
-
*
|
|
3241
|
-
* @returns {object} 返回Promise对象
|
|
3242
|
-
*/
|
|
3243
|
-
pause(id) {
|
|
3244
|
-
let that = this;
|
|
3245
|
-
let promise = new Promise(function (resolve, reject) {
|
|
3246
|
-
for (let i = 0, iLen = that[WEBSOCKET].length; i < iLen; i++) {
|
|
3247
|
-
if (that[WEBSOCKET][i].id === id) {
|
|
3248
|
-
if (that[PROTOCOLVERSION] === "0.1") {
|
|
3249
|
-
let uIntCmd = oDirectDeviceCustom.pauseCmd(); //定制协议暂停
|
|
3250
|
-
that[WEBSOCKET][i].socket.send(uIntCmd);
|
|
3251
|
-
resolve(); //定制协议没有返回码,发送后直接认为发送成功
|
|
3252
|
-
break;
|
|
3253
|
-
} else {
|
|
3254
|
-
that[WEBSOCKET][i].resolve = resolve;
|
|
3255
|
-
that[WEBSOCKET][i].reject = reject;
|
|
3256
|
-
let szCmd = oDirectDevice.pauseCmd(); //标准协议暂停
|
|
3257
|
-
that[WEBSOCKET][i].socket.send(szCmd);
|
|
3258
|
-
}
|
|
3259
|
-
}
|
|
3260
|
-
}
|
|
3261
|
-
});
|
|
3262
|
-
return promise;
|
|
3263
|
-
}
|
|
3264
|
-
/**
|
|
3265
|
-
* @synopsis 透传协议
|
|
3266
|
-
*
|
|
3267
|
-
* @param {string} id websocket id,在openStream的时候生成
|
|
3268
|
-
* @param {string} szCmd, 透传的命令码
|
|
3269
|
-
*
|
|
3270
|
-
* @returns {object} 返回Promise对象
|
|
3271
|
-
*/
|
|
3272
|
-
transmission(id, szCmd) {
|
|
3273
|
-
let that = this;
|
|
3274
|
-
let promise = new Promise(function (resolve, reject) {
|
|
3275
|
-
for (let i = 0, iLen = that[WEBSOCKET].length; i < iLen; i++) {
|
|
3276
|
-
if (that[WEBSOCKET][i].id === id) {
|
|
3277
|
-
that[WEBSOCKET][i].resolve = resolve;
|
|
3278
|
-
that[WEBSOCKET][i].reject = reject;
|
|
3279
|
-
that[WEBSOCKET][i].socket.send(szCmd);
|
|
3280
|
-
}
|
|
3281
|
-
}
|
|
3282
|
-
});
|
|
3283
|
-
return promise;
|
|
3284
|
-
}
|
|
3285
|
-
/**
|
|
3286
|
-
* @synopsis 恢复取流
|
|
3287
|
-
*
|
|
3288
|
-
* @param {string} id websocket id,在openStream的时候生成
|
|
3289
|
-
*
|
|
3290
|
-
* @returns {object} 返回Promise对象
|
|
3291
|
-
*/
|
|
3292
|
-
resume(id) {
|
|
3293
|
-
let that = this;
|
|
3294
|
-
let promise = new Promise(function (resolve, reject) {
|
|
3295
|
-
for (let i = 0, iLen = that[WEBSOCKET].length; i < iLen; i++) {
|
|
3296
|
-
if (that[WEBSOCKET][i].id === id) {
|
|
3297
|
-
if (that[PROTOCOLVERSION] === "0.1") {
|
|
3298
|
-
let uIntCmd = oDirectDeviceCustom.resumeCmd(); //定制协议恢复
|
|
3299
|
-
that[WEBSOCKET][i].socket.send(uIntCmd);
|
|
3300
|
-
resolve(); //定制协议没有返回码,发送后直接认为发送成功
|
|
3301
|
-
break;
|
|
3302
|
-
} else {
|
|
3303
|
-
that[WEBSOCKET][i].resolve = resolve;
|
|
3304
|
-
that[WEBSOCKET][i].reject = reject;
|
|
3305
|
-
let szCmd = oDirectDevice.resumeCmd(); //定制协议恢复
|
|
3306
|
-
that[WEBSOCKET][i].socket.send(szCmd);
|
|
3307
|
-
}
|
|
3308
|
-
}
|
|
3309
|
-
}
|
|
3310
|
-
});
|
|
3311
|
-
return promise;
|
|
3312
|
-
}
|
|
3313
|
-
/**
|
|
3314
|
-
* @synopsis 停止取流
|
|
3315
|
-
*
|
|
3316
|
-
* @param {string} id websocket id,在openStream的时候生成
|
|
3317
|
-
*
|
|
3318
|
-
* @returns {object} 返回Promise对象
|
|
3319
|
-
*/
|
|
3320
|
-
stop(id) {
|
|
3321
|
-
let that = this;
|
|
3322
|
-
let promise = new Promise(function (resolve, reject) {
|
|
3323
|
-
if (!id) {
|
|
3324
|
-
reject();
|
|
3325
|
-
} else {
|
|
3326
|
-
let iIndex = -1;
|
|
3327
|
-
for (let i = 0, iLen = that[WEBSOCKET].length; i < iLen; i++) {
|
|
3328
|
-
if (that[WEBSOCKET][i].id === id) {
|
|
3329
|
-
iIndex = i;
|
|
3330
|
-
that[WEBSOCKET][i].resolve = resolve; //onclose中处理,判断是否停止成功
|
|
3331
|
-
that[WEBSOCKET][i].socket.close(1000, "CLOSE");
|
|
3332
|
-
break;
|
|
3333
|
-
}
|
|
3334
|
-
}
|
|
3335
|
-
if (iIndex === -1) {
|
|
3336
|
-
reject();
|
|
3337
|
-
}
|
|
3338
|
-
}
|
|
3339
|
-
});
|
|
3340
|
-
return promise;
|
|
3341
|
-
}
|
|
3342
|
-
/**
|
|
3343
|
-
* @synopsis 停止所有通道取流
|
|
3344
|
-
*
|
|
3345
|
-
* @returns {object} 返回Promise对象
|
|
3346
|
-
*/
|
|
3347
|
-
stopAll() {
|
|
3348
|
-
let that = this;
|
|
3349
|
-
let promise = new Promise(function (resolve, reject) {
|
|
3350
|
-
for (let i = 0, iLen = that[WEBSOCKET].length; i < iLen; i++) {
|
|
3351
|
-
that[WEBSOCKET][i].socket.close(1000, "CLOSE");
|
|
3352
|
-
}
|
|
3353
|
-
console.log("停止所有流");
|
|
3354
|
-
resolve();
|
|
3355
|
-
});
|
|
3356
|
-
return promise;
|
|
3357
|
-
}
|
|
3358
|
-
}
|
|
3359
|
-
return WebsocketClient;
|
|
3360
|
-
}();
|
|
3361
|
-
|
|
3362
|
-
/***/
|
|
3363
|
-
}
|
|
3364
|
-
/******/])
|
|
3365
|
-
);
|
|
3366
|
-
});
|
|
3367
|
-
|
|
3368
|
-
!function (e, t) {
|
|
3369
|
-
if ("object" == typeof exports && "object" == typeof module) module.exports = t();else if ("function" == typeof define && define.amd) define([], t);else {
|
|
3370
|
-
var n = t();
|
|
3371
|
-
for (var r in n) ("object" == typeof exports ? exports : e)[r] = n[r];
|
|
3372
|
-
}
|
|
3373
|
-
}(window, function () {
|
|
3374
|
-
return function (e) {
|
|
3375
|
-
var t = {};
|
|
3376
|
-
function n(r) {
|
|
3377
|
-
if (t[r]) return t[r].exports;
|
|
3378
|
-
var a = t[r] = {
|
|
3379
|
-
i: r,
|
|
3380
|
-
l: !1,
|
|
3381
|
-
exports: {}
|
|
3382
|
-
};
|
|
3383
|
-
return e[r].call(a.exports, a, a.exports, n), a.l = !0, a.exports;
|
|
3384
|
-
}
|
|
3385
|
-
return n.m = e, n.c = t, n.d = function (e, t, r) {
|
|
3386
|
-
n.o(e, t) || Object.defineProperty(e, t, {
|
|
3387
|
-
enumerable: !0,
|
|
3388
|
-
get: r
|
|
3389
|
-
});
|
|
3390
|
-
}, n.r = function (e) {
|
|
3391
|
-
"undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(e, Symbol.toStringTag, {
|
|
3392
|
-
value: "Module"
|
|
3393
|
-
}), Object.defineProperty(e, "__esModule", {
|
|
3394
|
-
value: !0
|
|
3395
|
-
});
|
|
3396
|
-
}, n.t = function (e, t) {
|
|
3397
|
-
if (1 & t && (e = n(e)), 8 & t) return e;
|
|
3398
|
-
if (4 & t && "object" == typeof e && e && e.__esModule) return e;
|
|
3399
|
-
var r = Object.create(null);
|
|
3400
|
-
if (n.r(r), Object.defineProperty(r, "default", {
|
|
3401
|
-
enumerable: !0,
|
|
3402
|
-
value: e
|
|
3403
|
-
}), 2 & t && "string" != typeof e) for (var a in e) n.d(r, a, function (t) {
|
|
3404
|
-
return e[t];
|
|
3405
|
-
}.bind(null, a));
|
|
3406
|
-
return r;
|
|
3407
|
-
}, n.n = function (e) {
|
|
3408
|
-
var t = e && e.__esModule ? function () {
|
|
3409
|
-
return e.default;
|
|
3410
|
-
} : function () {
|
|
3411
|
-
return e;
|
|
3412
|
-
};
|
|
3413
|
-
return n.d(t, "a", t), t;
|
|
3414
|
-
}, n.o = function (e, t) {
|
|
3415
|
-
return Object.prototype.hasOwnProperty.call(e, t);
|
|
3416
|
-
}, n.p = "", n(n.s = 0);
|
|
3417
|
-
}([function (e, t, n) {
|
|
3418
|
-
|
|
3419
|
-
var r;
|
|
3420
|
-
n.r(t), n.d(t, "StorageManager", function () {
|
|
3421
|
-
return y;
|
|
3422
|
-
});
|
|
3423
|
-
var a = new Uint8Array(16);
|
|
3424
|
-
function i() {
|
|
3425
|
-
if (!r && !(r = "undefined" != typeof crypto && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || "undefined" != typeof msCrypto && "function" == typeof msCrypto.getRandomValues && msCrypto.getRandomValues.bind(msCrypto))) throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
3426
|
-
return r(a);
|
|
3427
|
-
}
|
|
3428
|
-
var o = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
|
|
3429
|
-
for (var s = function (e) {
|
|
3430
|
-
return "string" == typeof e && o.test(e);
|
|
3431
|
-
}, u = [], f = 0; f < 256; ++f) u.push((f + 256).toString(16).substr(1));
|
|
3432
|
-
var l = function (e) {
|
|
3433
|
-
var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 0,
|
|
3434
|
-
n = (u[e[t + 0]] + u[e[t + 1]] + u[e[t + 2]] + u[e[t + 3]] + "-" + u[e[t + 4]] + u[e[t + 5]] + "-" + u[e[t + 6]] + u[e[t + 7]] + "-" + u[e[t + 8]] + u[e[t + 9]] + "-" + u[e[t + 10]] + u[e[t + 11]] + u[e[t + 12]] + u[e[t + 13]] + u[e[t + 14]] + u[e[t + 15]]).toLowerCase();
|
|
3435
|
-
if (!s(n)) throw TypeError("Stringified UUID is invalid");
|
|
3436
|
-
return n;
|
|
3437
|
-
};
|
|
3438
|
-
var d = function (e, t, n) {
|
|
3439
|
-
var r = (e = e || {}).random || (e.rng || i)();
|
|
3440
|
-
if (r[6] = 15 & r[6] | 64, r[8] = 63 & r[8] | 128, t) {
|
|
3441
|
-
n = n || 0;
|
|
3442
|
-
for (var a = 0; a < 16; ++a) t[n + a] = r[a];
|
|
3443
|
-
return t;
|
|
3444
|
-
}
|
|
3445
|
-
return l(r);
|
|
3446
|
-
};
|
|
3447
|
-
let c = new class {
|
|
3448
|
-
constructor() {
|
|
3449
|
-
this._keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
|
3450
|
-
}
|
|
3451
|
-
$(e) {
|
|
3452
|
-
var t = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
|
|
3453
|
-
n = /^(?:\s*(<[\w\W]+>)[^>]*|.([\w-]*))$/;
|
|
3454
|
-
if (t.test(e)) {
|
|
3455
|
-
var r = t.exec(e);
|
|
3456
|
-
return document.getElementById(r[2]);
|
|
3457
|
-
}
|
|
3458
|
-
if (n.test(e)) {
|
|
3459
|
-
for (var a = n.exec(e), i = document.getElementsByTagName("*"), o = [], s = 0, u = i.length; s < u; s++) i[s].className.match(new RegExp("(\\s|^)" + a[2] + "(\\s|$)")) && o.push(i[s]);
|
|
3460
|
-
return o;
|
|
3461
|
-
}
|
|
3462
|
-
}
|
|
3463
|
-
dateFormat(e, t) {
|
|
3464
|
-
var n = {
|
|
3465
|
-
"M+": e.getMonth() + 1,
|
|
3466
|
-
"d+": e.getDate(),
|
|
3467
|
-
"h+": e.getHours(),
|
|
3468
|
-
"m+": e.getMinutes(),
|
|
3469
|
-
"s+": e.getSeconds(),
|
|
3470
|
-
"q+": Math.floor((e.getMonth() + 3) / 3),
|
|
3471
|
-
S: e.getMilliseconds()
|
|
3472
|
-
};
|
|
3473
|
-
for (var r in /(y+)/.test(t) && (t = t.replace(RegExp.$1, (e.getFullYear() + "").substr(4 - RegExp.$1.length))), n) new RegExp("(" + r + ")").test(t) && (t = t.replace(RegExp.$1, 1 === RegExp.$1.length ? n[r] : ("00" + n[r]).substr(("" + n[r]).length)));
|
|
3474
|
-
return t;
|
|
3475
|
-
}
|
|
3476
|
-
downloadFile(e, t) {
|
|
3477
|
-
let n = e;
|
|
3478
|
-
e instanceof Blob || e instanceof File || (n = new Blob([e]));
|
|
3479
|
-
var r = window.URL.createObjectURL(n),
|
|
3480
|
-
a = window.document.createElement("a");
|
|
3481
|
-
a.href = r, a.download = t;
|
|
3482
|
-
var i = document.createEvent("MouseEvents");
|
|
3483
|
-
i.initEvent("click", !0, !0), a.dispatchEvent(i);
|
|
3484
|
-
}
|
|
3485
|
-
createxmlDoc() {
|
|
3486
|
-
for (var e, t = ["MSXML2.DOMDocument", "MSXML2.DOMDocument.5.0", "MSXML2.DOMDocument.4.0", "MSXML2.DOMDocument.3.0", "Microsoft.XmlDom"], n = 0, r = t.length; n < r; n++) try {
|
|
3487
|
-
e = new ActiveXObject(t[n]);
|
|
3488
|
-
break;
|
|
3489
|
-
} catch (t) {
|
|
3490
|
-
e = document.implementation.createDocument("", "", null);
|
|
3491
|
-
break;
|
|
3492
|
-
}
|
|
3493
|
-
return e.async = "false", e;
|
|
3494
|
-
}
|
|
3495
|
-
parseXmlFromStr(e) {
|
|
3496
|
-
if (null === e || "" === e) return null;
|
|
3497
|
-
var t = this.createxmlDoc();
|
|
3498
|
-
"Netscape" === navigator.appName || "Opera" === navigator.appName ? t = new DOMParser().parseFromString(e, "text/xml") : t.loadXML(e);
|
|
3499
|
-
return t;
|
|
3500
|
-
}
|
|
3501
|
-
encode(e) {
|
|
3502
|
-
var t,
|
|
3503
|
-
n,
|
|
3504
|
-
r,
|
|
3505
|
-
a,
|
|
3506
|
-
i,
|
|
3507
|
-
o,
|
|
3508
|
-
s,
|
|
3509
|
-
u = "",
|
|
3510
|
-
f = 0;
|
|
3511
|
-
for (e = this._utf8_encode(e); f < e.length;) a = (t = e.charCodeAt(f++)) >> 2, i = (3 & t) << 4 | (n = e.charCodeAt(f++)) >> 4, o = (15 & n) << 2 | (r = e.charCodeAt(f++)) >> 6, s = 63 & r, isNaN(n) ? o = s = 64 : isNaN(r) && (s = 64), u = u + this._keyStr.charAt(a) + this._keyStr.charAt(i) + this._keyStr.charAt(o) + this._keyStr.charAt(s);
|
|
3512
|
-
return u;
|
|
3513
|
-
}
|
|
3514
|
-
decode(e) {
|
|
3515
|
-
var t,
|
|
3516
|
-
n,
|
|
3517
|
-
r,
|
|
3518
|
-
a,
|
|
3519
|
-
i,
|
|
3520
|
-
o,
|
|
3521
|
-
s = "",
|
|
3522
|
-
u = 0;
|
|
3523
|
-
for (e = e.replace(/[^A-Za-z0-9+/=]/g, ""); u < e.length;) t = this._keyStr.indexOf(e.charAt(u++)) << 2 | (a = this._keyStr.indexOf(e.charAt(u++))) >> 4, n = (15 & a) << 4 | (i = this._keyStr.indexOf(e.charAt(u++))) >> 2, r = (3 & i) << 6 | (o = this._keyStr.indexOf(e.charAt(u++))), s += String.fromCharCode(t), 64 !== i && (s += String.fromCharCode(n)), 64 !== o && (s += String.fromCharCode(r));
|
|
3524
|
-
return s = this._utf8_decode(s);
|
|
3525
|
-
}
|
|
3526
|
-
_utf8_encode(e) {
|
|
3527
|
-
e = e.replace(/\r\n/g, "\n");
|
|
3528
|
-
for (var t = "", n = 0; n < e.length; n++) {
|
|
3529
|
-
var r = e.charCodeAt(n);
|
|
3530
|
-
r < 128 ? t += String.fromCharCode(r) : r > 127 && r < 2048 ? (t += String.fromCharCode(r >> 6 | 192), t += String.fromCharCode(63 & r | 128)) : (t += String.fromCharCode(r >> 12 | 224), t += String.fromCharCode(r >> 6 & 63 | 128), t += String.fromCharCode(63 & r | 128));
|
|
3531
|
-
}
|
|
3532
|
-
return t;
|
|
3533
|
-
}
|
|
3534
|
-
_utf8_decode(e) {
|
|
3535
|
-
for (var t = "", n = 0, r = 0, a = 0; n < e.length;) if ((r = e.charCodeAt(n)) < 128) t += String.fromCharCode(r), n++;else if (r > 191 && r < 224) a = e.charCodeAt(n + 1), t += String.fromCharCode((31 & r) << 6 | 63 & a), n += 2;else {
|
|
3536
|
-
a = e.charCodeAt(n + 1);
|
|
3537
|
-
var i = e.charCodeAt(n + 2);
|
|
3538
|
-
t += String.fromCharCode((15 & r) << 12 | (63 & a) << 6 | 63 & i), n += 3;
|
|
3539
|
-
}
|
|
3540
|
-
return t;
|
|
3541
|
-
}
|
|
3542
|
-
isFirefox() {
|
|
3543
|
-
var e = !1,
|
|
3544
|
-
t = navigator.userAgent.toLowerCase(),
|
|
3545
|
-
n = "";
|
|
3546
|
-
return t.match(/firefox\/([\d.]+)/) && (n = t.match(/firefox\/([\d.]+)/)[1], parseInt(n.split(".")[0], 10) > -1 && (e = !0)), e;
|
|
3547
|
-
}
|
|
3548
|
-
isSafari() {
|
|
3549
|
-
var e = !1,
|
|
3550
|
-
t = navigator.userAgent.toLowerCase(),
|
|
3551
|
-
n = "";
|
|
3552
|
-
return t.match(/version\/([\d.]+).safari./) && (n = t.match(/version\/([\d.]+).safari./)[1], parseInt(n.split(".")[0], 10) > -1 && (e = !0)), e;
|
|
3553
|
-
}
|
|
3554
|
-
isEdge() {
|
|
3555
|
-
return navigator.userAgent.toLowerCase().indexOf("edge") > -1;
|
|
3556
|
-
}
|
|
3557
|
-
isIOS() {
|
|
3558
|
-
return !!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
|
|
3559
|
-
}
|
|
3560
|
-
}();
|
|
3561
|
-
var h = (e = "https://open.ys7.com/assets/ezuikit_v3.6") => `(function() {\n const RECORDRTP = 0; //录制一份未经过转封装的码流原始数据,用于定位问题\n self.Module = { memoryInitializerRequest: loadMemInitFile(), TOTAL_MEMORY: 128*1024*1024 };\n importScripts = (function (globalEval) {\n var xhr = new XMLHttpRequest;\n return function importScripts() {\n var\n args = Array.prototype.slice.call(arguments)\n , len = args.length\n , i = 0\n , meta\n , data\n , content\n ;\n for (; i < len; i++) {\n if (args[i].substr(0, 5).toLowerCase() === "data:") {\n data = args[i];\n content = data.indexOf(",");\n meta = data.substr(5, content).toLowerCase();\n data = decodeURIComponent(data.substr(content + 1));\n if (/;s*base64s*[;,]/.test(meta)) {\n data = atob(data);\n }\n if (/;s*charset=[uU][tT][fF]-?8s*[;,]/.test(meta)) {\n data = decodeURIComponent(escape(data));\n }\n } else {\n xhr.open("GET", args[i], false);\n xhr.send(null);\n data = xhr.responseText;\n }\n globalEval(data);\n }\n };\n }(eval));\n importScripts('${e}/js/transform/SystemTransform.js');\n\n Module.postRun.push(function() {\n postMessage({type: "loaded"});\n });\n\n onmessage = function (e) {\n var data = e.data;\n\n if ("create" === data.type) {\n var iHeadLen = data.len;\n var pHead = Module._malloc(iHeadLen);\n\n var aData = Module.HEAPU8.subarray(pHead, pHead + iHeadLen);\n aData.set(new Uint8Array(data.buf));\n\n var iTransType = data.packType;//目标格式 RTP->PS\n if (RECORDRTP) {\n postMessage({type: "created"});\n postMessage({type: "outputData", buf: data.buf, dType: 1}, [data.buf]);\n } else {\n var iRet = Module._ST_Create(pHead, iHeadLen, iTransType);\n if (iRet != 0) {\n console.log("_ST_Create failed!");\n } else {\n Module._ST_Start();\n postMessage({type: "created"});\n }\n }\n\n } else if ("inputData" === data.type) {\n if (RECORDRTP) {\n var aFileData = new Uint8Array(data.buf); // 拷贝一份\n var iBufferLen = aFileData.length;\n var szBufferLen = iBufferLen.toString(16);\n if (szBufferLen.length === 1) {\n szBufferLen = "000" + szBufferLen;\n } else if (szBufferLen.length === 2) {\n szBufferLen = "00" + szBufferLen;\n } else if (szBufferLen.length === 3) {\n szBufferLen = "0" + szBufferLen;\n }\n var aData = [0, 0, parseInt(szBufferLen.substring(0, 2), 16), parseInt(szBufferLen.substring(2, 4), 16)];\n for(var iIndex = 0, iDataLength = aFileData.length; iIndex < iDataLength; iIndex++) {\n aData[iIndex + 4] = aFileData[iIndex]\n }\n var dataUint8 = new Uint8Array(aData);\n postMessage({type: "outputData", buf: dataUint8.buffer, dType: 2}, [dataUint8.buffer]);\n } else {\n var iDataLen = data.len;\n var pData = Module._malloc(iDataLen);\n\n var aData = Module.HEAPU8.subarray(pData, pData + iDataLen);\n aData.set(new Uint8Array(data.buf));\n\n var iRet = Module._ST_InputData(0, pData, iDataLen);\n if (iRet != 0) {\n //console.log("_ST_InputData failed!");// 一开始会有一些失败,但是不影响后面的文件存储\n }\n\n Module._free(pData);\n }\n } else if ("release" === data.type) {\n Module._ST_Stop();\n Module._ST_Release();\n\n close();\n }\n };\n\n function loadMemInitFile() {\n var req = new XMLHttpRequest();\n req.open('GET', '${e}/js/transform/SystemTransform.js.mem');\n req.responseType = 'arraybuffer';\n req.send();\n\n return req;\n }\n})();`;
|
|
3562
|
-
window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem, window.URL = window.URL || window.webkitURL;
|
|
3563
|
-
class p {
|
|
3564
|
-
constructor(e, t, n, r) {
|
|
3565
|
-
this.szUUID = e, this.szFileName = t, this.iStreamType = n, this.szPath = "", this.bStart = !1, this.aStreamList = [], this.options = r;
|
|
3566
|
-
}
|
|
3567
|
-
init() {
|
|
3568
|
-
var e = this;
|
|
3569
|
-
0 === this.iStreamType ? this.szPath = "Web/RecordFiles/" : 1 === this.iStreamType && (this.szPath = "Web/PlaybackFiles/"), this.szPath += this.getDateDir();
|
|
3570
|
-
var t = e.szPath.split("/");
|
|
3571
|
-
return new Promise(function (n) {
|
|
3572
|
-
window.requestFileSystem(window.TEMPORARY, e.options.iFileSize, function (r) {
|
|
3573
|
-
e.createDir(r.root, t, function () {
|
|
3574
|
-
n();
|
|
3575
|
-
});
|
|
3576
|
-
}, e.errorHandler);
|
|
3577
|
-
});
|
|
3578
|
-
}
|
|
3579
|
-
getDateDir() {
|
|
3580
|
-
return c.dateFormat(new Date(), "yyyy-MM-dd");
|
|
3581
|
-
}
|
|
3582
|
-
createDir(e, t, n) {
|
|
3583
|
-
var r = this;
|
|
3584
|
-
t.length ? e.getDirectory(t[0], {
|
|
3585
|
-
create: !0
|
|
3586
|
-
}, function (e) {
|
|
3587
|
-
r.createDir(e, t.slice(1), n);
|
|
3588
|
-
}, r.errorHandler) : n();
|
|
3589
|
-
}
|
|
3590
|
-
errorHandler() {}
|
|
3591
|
-
writeFileHeader(e) {
|
|
3592
|
-
var t = this;
|
|
3593
|
-
window.requestFileSystem(window.TEMPORARY, t.options.iFileSize, function (n) {
|
|
3594
|
-
n.root.getFile(t.szPath + "/" + t.szFileName, {
|
|
3595
|
-
create: !0
|
|
3596
|
-
}, function (n) {
|
|
3597
|
-
n.createWriter(function (n) {
|
|
3598
|
-
n.onwriteend = function () {
|
|
3599
|
-
t.bStart = !0, t.writeFile(n);
|
|
3600
|
-
}, n.onerror = function () {}, n.seek(n.length);
|
|
3601
|
-
var r = new Blob([e]);
|
|
3602
|
-
n.write(r);
|
|
3603
|
-
}, t.errorHandler);
|
|
3604
|
-
}, t.errorHandler);
|
|
3605
|
-
}, t.errorHandler);
|
|
3606
|
-
}
|
|
3607
|
-
writeFileContent(e) {
|
|
3608
|
-
this.aStreamList.push(e);
|
|
3609
|
-
}
|
|
3610
|
-
writeFile(e) {
|
|
3611
|
-
var t = this;
|
|
3612
|
-
if (this.bStart) if (this.aStreamList.length > 0) {
|
|
3613
|
-
var n = this.aStreamList.shift();
|
|
3614
|
-
if (e.seek(e.length), e.length >= this.options.iFileSize) return void (this.options.cbEventHandler && this.options.cbEventHandler(3001, this.szUUID));
|
|
3615
|
-
var r = new Blob([n]);
|
|
3616
|
-
e.write(r);
|
|
3617
|
-
} else setTimeout(function () {
|
|
3618
|
-
t.writeFile(e);
|
|
3619
|
-
}, 1e3);
|
|
3620
|
-
}
|
|
3621
|
-
stopWriteFile() {
|
|
3622
|
-
var e = this;
|
|
3623
|
-
return this.bStart = !1, this.aStreamList.length = 0, new Promise(function (t) {
|
|
3624
|
-
window.requestFileSystem(window.TEMPORARY, e.options.iFileSize, function (n) {
|
|
3625
|
-
n.root.getFile(e.szPath + "/" + e.szFileName, {
|
|
3626
|
-
create: !1
|
|
3627
|
-
}, function (e) {
|
|
3628
|
-
e.file(function (e) {
|
|
3629
|
-
t(), c.downloadFile(e, e.name);
|
|
3630
|
-
});
|
|
3631
|
-
}, e.errorHandler);
|
|
3632
|
-
}, e.errorHandler);
|
|
3633
|
-
});
|
|
3634
|
-
}
|
|
3635
|
-
}
|
|
3636
|
-
class m {
|
|
3637
|
-
constructor(e, t, n, r, a, i, o, s) {
|
|
3638
|
-
this.szBasePath = e, this.szUUID = t, this.szFileName = n, this.aHeadBuf = new Uint8Array(r), this.iPackType = a, this.iStreamType = i, this.oWorker = null, this.oFileSystem = null, this.options = o, this.bHead = !0, this.staticPath = s;
|
|
3639
|
-
}
|
|
3640
|
-
init() {
|
|
3641
|
-
var e = this;
|
|
3642
|
-
return new Promise(function (t, n) {
|
|
3643
|
-
e.initFileSystem().then(function () {
|
|
3644
|
-
e.initWorker().then(function () {
|
|
3645
|
-
t(e.szUUID);
|
|
3646
|
-
}, function (e) {
|
|
3647
|
-
n(e);
|
|
3648
|
-
});
|
|
3649
|
-
}, function (e) {
|
|
3650
|
-
n(e);
|
|
3651
|
-
});
|
|
3652
|
-
});
|
|
3653
|
-
}
|
|
3654
|
-
initFileSystem() {
|
|
3655
|
-
var e = this;
|
|
3656
|
-
return this.oFileSystem = new p(this.szUUID, this.szFileName, this.iStreamType, this.options), new Promise(function (t, n) {
|
|
3657
|
-
e.oFileSystem.init().then(function () {
|
|
3658
|
-
t();
|
|
3659
|
-
}, function (e) {
|
|
3660
|
-
n(e);
|
|
3661
|
-
});
|
|
3662
|
-
});
|
|
3663
|
-
}
|
|
3664
|
-
initWorker() {
|
|
3665
|
-
var e = this;
|
|
3666
|
-
return new Promise(function (t) {
|
|
3667
|
-
var n = new Blob([h(e.staticPath)]);
|
|
3668
|
-
const r = URL.createObjectURL(n);
|
|
3669
|
-
e.oWorker = new Worker(r), e.oWorker.onmessage = function (n) {
|
|
3670
|
-
var r = n.data;
|
|
3671
|
-
let a = e.iPackType;
|
|
3672
|
-
if (1 === e.options.iPackage && (a = 12), "loaded" === r.type) e.oWorker.postMessage({
|
|
3673
|
-
type: "create",
|
|
3674
|
-
buf: e.aHeadBuf.buffer,
|
|
3675
|
-
len: 40,
|
|
3676
|
-
packType: a
|
|
3677
|
-
}, [e.aHeadBuf.buffer]);else if ("created" === r.type) t();else if ("outputData" === r.type) {
|
|
3678
|
-
var i = new Uint8Array(r.buf);
|
|
3679
|
-
1 === e.options.iPackage ? e.bHead ? (e.oFileSystem.writeFileHeader(i), e.bHead = !1) : e.oFileSystem.writeFileContent(i) : 1 === r.dType ? e.oFileSystem.writeFileHeader(i) : e.oFileSystem.writeFileContent(i);
|
|
3680
|
-
}
|
|
3681
|
-
};
|
|
3682
|
-
});
|
|
3683
|
-
}
|
|
3684
|
-
inputData(e) {
|
|
3685
|
-
if (this.oWorker) {
|
|
3686
|
-
var t = new Uint8Array(e);
|
|
3687
|
-
this.oWorker.postMessage({
|
|
3688
|
-
type: "inputData",
|
|
3689
|
-
buf: t.buffer,
|
|
3690
|
-
len: t.length
|
|
3691
|
-
}, [t.buffer]);
|
|
3692
|
-
}
|
|
3693
|
-
}
|
|
3694
|
-
stopRecord() {
|
|
3695
|
-
var e = this;
|
|
3696
|
-
return new Promise(function (t, n) {
|
|
3697
|
-
e.oWorker ? e.oWorker.postMessage({
|
|
3698
|
-
type: "release"
|
|
3699
|
-
}) : n(), e.oFileSystem ? e.oFileSystem.stopWriteFile().then(function () {
|
|
3700
|
-
e.bHead = !0, t();
|
|
3701
|
-
}, function () {
|
|
3702
|
-
n();
|
|
3703
|
-
}) : n();
|
|
3704
|
-
});
|
|
3705
|
-
}
|
|
3706
|
-
}
|
|
3707
|
-
var g,
|
|
3708
|
-
y = (g = Symbol("STORAGELIST"), class {
|
|
3709
|
-
constructor(e, t, n) {
|
|
3710
|
-
this.szBasePath = e, this[g] = {}, this.options = {
|
|
3711
|
-
iFileSize: 1073741824
|
|
3712
|
-
}, Object.assign(this.options, t), "string" == typeof t.staticPath && (this.staticPath = t.staticPath);
|
|
3713
|
-
}
|
|
3714
|
-
startRecord(e, t, n, r, a) {
|
|
3715
|
-
var i = this,
|
|
3716
|
-
o = d(),
|
|
3717
|
-
s = Object.assign({}, this.options, a),
|
|
3718
|
-
u = new m(this.szBasePath, o, e, t, n, r, s, this.staticPath);
|
|
3719
|
-
return new Promise(function (e, t) {
|
|
3720
|
-
u.init().then(function (t) {
|
|
3721
|
-
i[g][t] = u, e(t);
|
|
3722
|
-
}, function (e) {
|
|
3723
|
-
t(e);
|
|
3724
|
-
});
|
|
3725
|
-
});
|
|
3726
|
-
}
|
|
3727
|
-
inputData(e, t) {
|
|
3728
|
-
var n = this[g][e];
|
|
3729
|
-
n && n.inputData(t);
|
|
3730
|
-
}
|
|
3731
|
-
stopRecord(e) {
|
|
3732
|
-
var t = this;
|
|
3733
|
-
return new Promise(function (n, r) {
|
|
3734
|
-
var a = t[g][e];
|
|
3735
|
-
a ? a.stopRecord().then(function () {
|
|
3736
|
-
delete t[g][e], n();
|
|
3737
|
-
}, function () {
|
|
3738
|
-
r();
|
|
3739
|
-
}) : r();
|
|
3740
|
-
});
|
|
3741
|
-
}
|
|
3742
|
-
});
|
|
3743
|
-
}]);
|
|
3744
|
-
});
|
|
3745
|
-
|
|
3746
|
-
//const SR_DE_FISH_PLANET = 0x11; ///< 应用于小行星
|
|
3747
|
-
//const SR_DE_FISH_ARCSPHERE_HORIZONTAL_WALL = 0x12; ///< 应用于水平壁装弧面鱼眼显示
|
|
3748
|
-
//const SR_DE_FISH_ARCSPHERE_VERTICAL_WALL = 0x13; ///< 应用于垂直壁装弧面鱼眼显示
|
|
3749
|
-
//const SR_DE_FISH_ANIMATION_SWITCH_CEILING = 0x14; ///< 应用于顶装矫正方式动画切换显示
|
|
3750
|
-
//const SR_DE_FISH_ANIMATION_SWITCH_FLOOR = 0x15; ///< 应用于底装矫正方式动画切换显示
|
|
3751
|
-
//const SR_DE_PANORAMA_SPHERE = 0x16; ///< 应用于全景球面展示
|
|
3752
|
-
//const SR_DE_PANORAMA_PLANET = 0x17; ///< 应用于全景小行星展示
|
|
3753
|
-
//宽、高
|
|
3754
|
-
var nWidth = 0;
|
|
3755
|
-
var nHeight = 0;
|
|
3756
|
-
var g_port;
|
|
3757
|
-
// 录制
|
|
3758
|
-
// var aHead = [];
|
|
3759
|
-
function downloadFile(oData, szName) {
|
|
3760
|
-
console.log("oData", oData);
|
|
3761
|
-
let oBlob = oData;
|
|
3762
|
-
if (!(oData instanceof Blob || oData instanceof File)) {
|
|
3763
|
-
oBlob = new Blob([oData]);
|
|
3764
|
-
}
|
|
3765
|
-
let szFileUrl = window.URL.createObjectURL(oBlob);
|
|
3766
|
-
let oLink = window.document.createElement("a");
|
|
3767
|
-
oLink.href = szFileUrl;
|
|
3768
|
-
oLink.download = szName;
|
|
3769
|
-
let oClick = document.createEvent("MouseEvents");
|
|
3770
|
-
oClick.initEvent("click", true, true);
|
|
3771
|
-
oLink.dispatchEvent(oClick);
|
|
3772
|
-
}
|
|
3773
|
-
// 字母字符串转byte数组
|
|
3774
|
-
function stringToBytes(str) {
|
|
3775
|
-
let ch,
|
|
3776
|
-
st,
|
|
3777
|
-
re = [];
|
|
3778
|
-
for (let i = 0; i < str.length; i++) {
|
|
3779
|
-
ch = str.charCodeAt(i); // get char
|
|
3780
|
-
st = []; // set up "stack"
|
|
3781
|
-
do {
|
|
3782
|
-
st.push(ch & 0xFF); // push byte to stack
|
|
3783
|
-
ch = ch >> 8; // shift value down by 1 byte
|
|
3784
|
-
} while (ch);
|
|
3785
|
-
// add stack contents to result
|
|
3786
|
-
// done because chars have "wrong" endianness
|
|
3787
|
-
re = re.concat(st.reverse());
|
|
3788
|
-
}
|
|
3789
|
-
// return an array of bytes
|
|
3790
|
-
return re;
|
|
3791
|
-
}
|
|
3792
|
-
class JSPluginV2 {
|
|
3793
|
-
constructor(props) {
|
|
3794
|
-
this.oStreamClient = new StreamClient();
|
|
3795
|
-
this.oStorageManager = new StorageManager("./transform", {
|
|
3796
|
-
staticPath: "https://open.ys7.com/assets/ezuikit_v4.0"
|
|
3797
|
-
});
|
|
3798
|
-
this.aHead = [];
|
|
3799
|
-
this.pCanvasData = null;
|
|
3800
|
-
this.bPlaySound = -1;
|
|
3801
|
-
this.szStorageUUID = '';
|
|
3802
|
-
this.szStreamUUID = '';
|
|
3803
|
-
this.g_port = 0;
|
|
3804
|
-
this.szId = props.szId;
|
|
3805
|
-
this.iWidth = props.iWidth;
|
|
3806
|
-
this.iHeight = props.iHeight;
|
|
3807
|
-
this.iRate = 1;
|
|
3808
|
-
this.decoderVersion = '2.0';
|
|
3809
|
-
this.staticPath = props.staticPath || "https://open.ys7.com/assets/ezuikit_v5.0";
|
|
3810
|
-
this.bPause = false;
|
|
3811
|
-
this.bPlay = false;
|
|
3812
|
-
this.bInit = false;
|
|
3813
|
-
this.portAvailable = true; // 端口可用状态,可以用来判断播放停止状态。
|
|
3814
|
-
//this.staticPath = "http://localhost:9090";
|
|
3815
|
-
document.getElementById(props.szId).style = `display:inline-block;width:${props.iWidth}px;height:${props.iHeight}px;background:#000000;background-size:100% 100%;vertical-align:top;`;
|
|
3816
|
-
this.JS_Init();
|
|
3817
|
-
}
|
|
3818
|
-
JS_Init() {
|
|
3819
|
-
if (window.initIng) {
|
|
3820
|
-
//多个实例同时初始化,判断已有实例正在加载
|
|
3821
|
-
return;
|
|
3822
|
-
}
|
|
3823
|
-
window.initIng = true;
|
|
3824
|
-
var that = this;
|
|
3825
|
-
if (this.bPlay) {
|
|
3826
|
-
return false;
|
|
3827
|
-
}
|
|
3828
|
-
const promise = new Promise((resolve, reject) => {
|
|
3829
|
-
if (window.JSPlayerModuleLoaded) {
|
|
3830
|
-
// 实例已经加载过,不需要再次加载
|
|
3831
|
-
that.bInit = true;
|
|
3832
|
-
resolve();
|
|
3833
|
-
}
|
|
3834
|
-
loadJSByBlobToHeader(`${that.staticPath}/js/Decoder.js`, () => {
|
|
3835
|
-
window.JSPlayerModule({
|
|
3836
|
-
staticPath: that.staticPath
|
|
3837
|
-
}).then(instance => {
|
|
3838
|
-
window.Module = instance;
|
|
3839
|
-
that.Module = instance;
|
|
3840
|
-
that.bInit = true;
|
|
3841
|
-
window.JSPlayerModuleLoaded = true;
|
|
3842
|
-
resolve();
|
|
3843
|
-
});
|
|
3844
|
-
}, that.bInit);
|
|
3845
|
-
});
|
|
3846
|
-
return promise;
|
|
3847
|
-
}
|
|
3848
|
-
PlayM4_openStream(ng_port, fileHead) {
|
|
3849
|
-
var Module = window.Module;
|
|
3850
|
-
let pInputData = Module._malloc(40);
|
|
3851
|
-
if (pInputData === null) {
|
|
3852
|
-
return RETURN_ERROR;
|
|
3853
|
-
}
|
|
3854
|
-
let inputData = new Uint8Array(fileHead.buffer);
|
|
3855
|
-
Module.writeArrayToMemory(inputData, pInputData);
|
|
3856
|
-
let resO = Module._JSPlayM4_OpenStream(ng_port, pInputData, 40, 2 * 1024 * 1024);
|
|
3857
|
-
inputData = null;
|
|
3858
|
-
if (pInputData !== null) {
|
|
3859
|
-
Module._free(pInputData);
|
|
3860
|
-
pInputData = null;
|
|
3861
|
-
}
|
|
3862
|
-
console.log("3.打开流 resO:" + resO);
|
|
3863
|
-
}
|
|
3864
|
-
//执行播放方法
|
|
3865
|
-
_doPlay(szUrl, oParams, iWndNum, szStartTime, szStopTime) {
|
|
3866
|
-
const Module = window.Module;
|
|
3867
|
-
// if(this.bPlay || this.bPlayIng) {
|
|
3868
|
-
// return false;
|
|
3869
|
-
// }
|
|
3870
|
-
this.bPlayIng = true;
|
|
3871
|
-
var _this = this;
|
|
3872
|
-
_this.playURL = oParams.playURL;
|
|
3873
|
-
_this.szUrl = szUrl;
|
|
3874
|
-
// 创建canvas
|
|
3875
|
-
if (!document.getElementById(_this.szId + '-player')) {
|
|
3876
|
-
let canvasList = document.getElementById(_this.szId);
|
|
3877
|
-
let canvas = document.createElement('canvas');
|
|
3878
|
-
canvasList.appendChild(canvas);
|
|
3879
|
-
canvas.width = _this.iWidth;
|
|
3880
|
-
canvas.height = _this.iHeight;
|
|
3881
|
-
canvas.id = _this.szId + '-player';
|
|
3882
|
-
//canvas.style.backgroundColor = '#000000';
|
|
3883
|
-
} else {
|
|
3884
|
-
let canvasList = document.getElementById(this.szId);
|
|
3885
|
-
let oldcanv = document.getElementById(this.szId + '-player');
|
|
3886
|
-
// oldcanv.id = this.szId + '-player-tmp';
|
|
3887
|
-
oldcanv.style = "position: absolute;";
|
|
3888
|
-
canvasList.removeChild(oldcanv);
|
|
3889
|
-
let canvas = document.createElement('canvas');
|
|
3890
|
-
canvas.width = _this.iWidth;
|
|
3891
|
-
canvas.height = _this.iHeight;
|
|
3892
|
-
canvas.id = _this.szId + '-player';
|
|
3893
|
-
//canvas.style.backgroundColor = '#000000';
|
|
3894
|
-
canvasList.appendChild(canvas);
|
|
3895
|
-
}
|
|
3896
|
-
let promise = new Promise((resolve, reject) => {
|
|
3897
|
-
// 先停止所有流
|
|
3898
|
-
this.oStreamClient.stopAll();
|
|
3899
|
-
//获取端口号
|
|
3900
|
-
_this.g_port = Module._JSPlayM4_GetPort();
|
|
3901
|
-
console.log("1.获取播放库端口号 g_port:" + _this.g_port);
|
|
3902
|
-
// 端口已经使用,设置为不可用状态
|
|
3903
|
-
this.portAvailable = false;
|
|
3904
|
-
_this.oStreamClient.openStream(szUrl, oParams, data => {
|
|
3905
|
-
if (data.bHead) {
|
|
3906
|
-
//判断是否开启预览,用于初始化播放库,回放跳片段是会返回媒体头,不能只判断是否为媒体头
|
|
3907
|
-
_this.PlayM4_openStream(_this.g_port, data.buf);
|
|
3908
|
-
_this.aHead = new Uint8Array(data.buf);
|
|
3909
|
-
_this.pCanvasData = Module._malloc(128); //通过emscripten分配C/C++中的堆内存
|
|
3910
|
-
if (_this.pCanvasData === null) {
|
|
3911
|
-
return;
|
|
3912
|
-
}
|
|
3913
|
-
//let bufData = stringToBytes (`#${this.szId}-player1`);
|
|
3914
|
-
let bufData = stringToBytes(`#${_this.szId}-player`);
|
|
3915
|
-
////方法一:
|
|
3916
|
-
let aKeyData = Module.HEAPU8.subarray(_this.pCanvasData, _this.pCanvasData + 128); //堆内存绑定到视图对象
|
|
3917
|
-
let u8aTemp = new Uint8Array(128);
|
|
3918
|
-
aKeyData.set(u8aTemp, 0);
|
|
3919
|
-
aKeyData.set(new Uint8Array(bufData)); // 数据写入到emscripten分配的内存中去
|
|
3920
|
-
aKeyData = null;
|
|
3921
|
-
let resP = Module._JSPlayM4_Play(_this.g_port, _this.pCanvasData); //pCanvasString或pCanvasData
|
|
3922
|
-
console.log("4.开始播放 resP:" + resP);
|
|
3923
|
-
_this.bPlay = true;
|
|
3924
|
-
_this.bPlayIng = false;
|
|
3925
|
-
// 设置一系列回调
|
|
3926
|
-
let resFCB = Module._JSPlayM4_SetFrameInfoCallBack(_this.g_port, 1); //帧信息回调
|
|
3927
|
-
if (resFCB != 1) {
|
|
3928
|
-
let resFrameInfoError = Module._JSPlayM4_GetLastError(_this.g_port);
|
|
3929
|
-
console.log("resFrameInfoError:" + resFrameInfoError);
|
|
3930
|
-
}
|
|
3931
|
-
Module._JSPlayM4_RenderPrivateData(0, 1, 0);
|
|
3932
|
-
Module._JSPlayM4_RenderPrivateData(0, 2, 0);
|
|
3933
|
-
Module._JSPlayM4_RenderPrivateData(0, 4, 0);
|
|
3934
|
-
Module._JSPlayM4_RenderPrivateData(0, 16, 0);
|
|
3935
|
-
this.firstFlag = true;
|
|
3936
|
-
resolve(resP);
|
|
3937
|
-
} else {
|
|
3938
|
-
if (this.firstFlag) {
|
|
3939
|
-
let oFrameInfo = Module._JSPlayM4_GetFrameInfo(this.g_port);
|
|
3940
|
-
var nWidth = Module.HEAP32[oFrameInfo + 12 >> 2];
|
|
3941
|
-
var nHeight = Module.HEAP32[oFrameInfo + 16 >> 2];
|
|
3942
|
-
if (nWidth) {
|
|
3943
|
-
console.log("首帧展示", nWidth, nHeight);
|
|
3944
|
-
this.firstFlag = false;
|
|
3945
|
-
if (document.getElementById(this.szId + '-player-tmp')) {
|
|
3946
|
-
document.getElementById(this.szId + '-player-tmp').parentNode.removeChild(document.getElementById(this.szId + '-player-tmp'));
|
|
3947
|
-
}
|
|
3948
|
-
}
|
|
3949
|
-
}
|
|
3950
|
-
let aBuffer = new Uint8Array(data.buf); //拷贝一份数据进行使
|
|
3951
|
-
let pInputData1 = Module._malloc(aBuffer.length);
|
|
3952
|
-
if (pInputData1 === null) {
|
|
3953
|
-
console.log("inputdata malloc failed!!!");
|
|
3954
|
-
return -1;
|
|
3955
|
-
}
|
|
3956
|
-
Module.writeArrayToMemory(aBuffer, pInputData1);
|
|
3957
|
-
// 解密-end
|
|
3958
|
-
//console.log("resSetSecretKey:"+resS);
|
|
3959
|
-
// 监听数据错误
|
|
3960
|
-
if (data.statusString) {
|
|
3961
|
-
if (_this.EventCallback && _this.EventCallback.pluginErrorHandler) {
|
|
3962
|
-
_this.EventCallback.pluginErrorHandler(_this.g_port, 1001, data);
|
|
3963
|
-
}
|
|
3964
|
-
} else if (data.type && data.type === "exception") {
|
|
3965
|
-
if (_this.EventCallback && _this.EventCallback.pluginErrorHandler) {
|
|
3966
|
-
_this.EventCallback.pluginErrorHandler(_this.g_port, 1002, data);
|
|
3967
|
-
}
|
|
3968
|
-
}
|
|
3969
|
-
Module._JSPlayM4_InputData(_this.g_port, pInputData1, aBuffer.length);
|
|
3970
|
-
if (pInputData1 !== null) {
|
|
3971
|
-
// console.log('释放内存')
|
|
3972
|
-
Module._free(pInputData1);
|
|
3973
|
-
pInputData1 = null;
|
|
3974
|
-
}
|
|
3975
|
-
aBuffer = null;
|
|
3976
|
-
}
|
|
3977
|
-
// 录制
|
|
3978
|
-
if (_this.szStorageUUID) {
|
|
3979
|
-
_this.oStorageManager.inputData(_this.szStorageUUID, data.buf);
|
|
3980
|
-
}
|
|
3981
|
-
// data = null;
|
|
3982
|
-
}, function () {
|
|
3983
|
-
if (_this.bPlay) {
|
|
3984
|
-
if (_this.EventCallback && _this.EventCallback.pluginErrorHandler) {
|
|
3985
|
-
_this.EventCallback.pluginErrorHandler(iWndNum, 1003);
|
|
3986
|
-
}
|
|
3987
|
-
}
|
|
3988
|
-
_this.bPlayIng = false;
|
|
3989
|
-
reject();
|
|
3990
|
-
}).then(id => {
|
|
3991
|
-
//websocket onopen事件触发
|
|
3992
|
-
_this.szStreamUUID = id;
|
|
3993
|
-
_this.oStreamClient.startPlay(id).then(() => {
|
|
3994
|
-
let resSSOM = Module._JSPlayM4_SetStreamOpenMode(g_port, 1);
|
|
3995
|
-
console.log("2.设置流模式 resSSOM:" + resSSOM);
|
|
3996
|
-
}).catch(err => {
|
|
3997
|
-
console.log("err", err);
|
|
3998
|
-
_this._doRelease();
|
|
3999
|
-
_this.bPlayIng = false;
|
|
4000
|
-
reject(err);
|
|
4001
|
-
});
|
|
4002
|
-
}, function (oError) {
|
|
4003
|
-
//websocekt 未进入onopen
|
|
4004
|
-
_this.bPlayIng = false;
|
|
4005
|
-
_this._doRelease();
|
|
4006
|
-
reject(oError);
|
|
4007
|
-
});
|
|
4008
|
-
});
|
|
4009
|
-
return promise;
|
|
4010
|
-
}
|
|
4011
|
-
/**
|
|
4012
|
-
*
|
|
4013
|
-
* @param {*} szUrl "示例:wss://jsdecoder-aeye.hwwt2.com:443"
|
|
4014
|
-
* @param {*} oParams "示例: {playURL: "/live?dev=F99467170&chn=9&stream=1&ssn=ot.9oovv27v00lck3ft0krfw61n8ugr4j5b-1ao1cqq1fm-1od8d0d-h1lnhi0w0&auth=1&biz=4&cln=100"}"
|
|
4015
|
-
* @param {*} iWndNum
|
|
4016
|
-
* @param {*} szStartTime
|
|
4017
|
-
* @param {*} szStopTime
|
|
4018
|
-
* @returns
|
|
4019
|
-
*/
|
|
4020
|
-
JS_Play(szUrl = "", oParams = {
|
|
4021
|
-
playURL: ""
|
|
4022
|
-
}, iWndNum, szStartTime, szStopTime) {
|
|
4023
|
-
return new Promise((resolve, reject) => {
|
|
4024
|
-
let loadWasmTimer = setInterval(() => {
|
|
4025
|
-
if (window.JSPlayerModuleLoaded) {
|
|
4026
|
-
clearInterval(loadWasmTimer);
|
|
4027
|
-
this._doPlay(szUrl, oParams, iWndNum, szStartTime, szStopTime).then(data => {
|
|
4028
|
-
resolve(data);
|
|
4029
|
-
}).catch(err => {
|
|
4030
|
-
reject(err);
|
|
4031
|
-
});
|
|
4032
|
-
}
|
|
4033
|
-
}, 50);
|
|
4034
|
-
});
|
|
4035
|
-
}
|
|
4036
|
-
JS_SetSecretKey(iWndNum, secretKey) {
|
|
4037
|
-
const {
|
|
4038
|
-
g_port
|
|
4039
|
-
} = this;
|
|
4040
|
-
const {
|
|
4041
|
-
Module
|
|
4042
|
-
} = window;
|
|
4043
|
-
// 字母字符串转byte数组
|
|
4044
|
-
function stringToBytes(str) {
|
|
4045
|
-
let ch,
|
|
4046
|
-
st,
|
|
4047
|
-
re = [];
|
|
4048
|
-
for (let i = 0; i < str.length; i++) {
|
|
4049
|
-
ch = str.charCodeAt(i); // get char
|
|
4050
|
-
st = []; // set up "stack"
|
|
4051
|
-
do {
|
|
4052
|
-
st.push(ch & 0xFF); // push byte to stack
|
|
4053
|
-
ch = ch >> 8; // shift value down by 1 byte
|
|
4054
|
-
} while (ch);
|
|
4055
|
-
// add stack contents to result
|
|
4056
|
-
// done because chars have "wrong" endianness
|
|
4057
|
-
re = re.concat(st.reverse());
|
|
4058
|
-
}
|
|
4059
|
-
// return an array of bytes
|
|
4060
|
-
return re;
|
|
4061
|
-
}
|
|
4062
|
-
let pKeyData = Module._malloc(128);
|
|
4063
|
-
if (pKeyData === null) {
|
|
4064
|
-
return;
|
|
4065
|
-
}
|
|
4066
|
-
let bufData = stringToBytes(secretKey);
|
|
4067
|
-
let aKeyData = Module.HEAPU8.subarray(pKeyData, pKeyData + 128);
|
|
4068
|
-
aKeyData.set(new Uint8Array(bufData));
|
|
4069
|
-
let resS = Module._JSPlayM4_SetSecretKey(g_port, 1, pKeyData, 128);
|
|
4070
|
-
if (pKeyData !== null) {
|
|
4071
|
-
Module._free(pKeyData);
|
|
4072
|
-
pKeyData = null;
|
|
4073
|
-
}
|
|
4074
|
-
console.log("resSetSecretKey:" + resS);
|
|
4075
|
-
}
|
|
4076
|
-
JS_OpenSound() {
|
|
4077
|
-
var {
|
|
4078
|
-
Module
|
|
4079
|
-
} = window;
|
|
4080
|
-
let resPS = Module._JSPlayM4_PlaySound(this.g_port);
|
|
4081
|
-
console.log("resPS", resPS);
|
|
4082
|
-
if (resPS === 1) {
|
|
4083
|
-
this.bPlaySound = 1;
|
|
4084
|
-
}
|
|
4085
|
-
return resPS;
|
|
4086
|
-
}
|
|
4087
|
-
JS_CloseSound() {
|
|
4088
|
-
var {
|
|
4089
|
-
Module
|
|
4090
|
-
} = window;
|
|
4091
|
-
let resPS = Module._JSPlayM4_StopSound(this.g_port);
|
|
4092
|
-
console.log("resPS", resPS);
|
|
4093
|
-
if (resPS === 1) {
|
|
4094
|
-
this.bPlaySound = -1;
|
|
4095
|
-
}
|
|
4096
|
-
return resPS;
|
|
4097
|
-
}
|
|
4098
|
-
JS_StartSave(g_port, fileName = `${new Date().getTime()}`) {
|
|
4099
|
-
// this.szStorageUUID = `11111111`;
|
|
4100
|
-
this.oStorageManager.startRecord(`${fileName}.mp4`, this.aHead, 2, 0, {
|
|
4101
|
-
cbEventHandler: function (iErrorType) {
|
|
4102
|
-
console.log("录制错误", iErrorType);
|
|
4103
|
-
},
|
|
4104
|
-
iPackage: 0
|
|
4105
|
-
}).then(szUUID => {
|
|
4106
|
-
this.szStorageUUID = szUUID;
|
|
4107
|
-
//resolve();
|
|
4108
|
-
}, function () {
|
|
4109
|
-
//reject();
|
|
4110
|
-
});
|
|
4111
|
-
}
|
|
4112
|
-
JS_StopSave() {
|
|
4113
|
-
this.oStorageManager.stopRecord(this.szStorageUUID).then(() => {
|
|
4114
|
-
this.szStorageUUID = ""; //关闭录像 删除存储ID
|
|
4115
|
-
}, function (iError) {
|
|
4116
|
-
console.log("iError", iError);
|
|
4117
|
-
});
|
|
4118
|
-
}
|
|
4119
|
-
_JSPlayM4_GetFrameInfo() {
|
|
4120
|
-
const {
|
|
4121
|
-
Module
|
|
4122
|
-
} = window;
|
|
4123
|
-
let oFrameInfo = Module._JSPlayM4_GetFrameInfo(this.g_port);
|
|
4124
|
-
Module.HEAP32[oFrameInfo >> 2];
|
|
4125
|
-
Module.HEAP32[oFrameInfo + 4 >> 2];
|
|
4126
|
-
Module.HEAP32[oFrameInfo + 8 >> 2];
|
|
4127
|
-
let width = Module.HEAP32[oFrameInfo + 12 >> 2];
|
|
4128
|
-
let height = Module.HEAP32[oFrameInfo + 16 >> 2];
|
|
4129
|
-
console.log("width:" + width + ",height:" + height);
|
|
4130
|
-
Module.HEAP32[oFrameInfo + 20 >> 2];
|
|
4131
|
-
let year = Module.HEAP16[oFrameInfo + 60 >> 1];
|
|
4132
|
-
let month = Module.HEAP16[oFrameInfo + 62 >> 1];
|
|
4133
|
-
Module.HEAP16[oFrameInfo + 64 >> 1];
|
|
4134
|
-
let day = Module.HEAP16[oFrameInfo + 66 >> 1];
|
|
4135
|
-
let hour = Module.HEAP16[oFrameInfo + 68 >> 1];
|
|
4136
|
-
let minute = Module.HEAP16[oFrameInfo + 70 >> 1];
|
|
4137
|
-
let second = Module.HEAP16[oFrameInfo + 72 >> 1];
|
|
4138
|
-
let milliseconds = Module.HEAP16[oFrameInfo + 74 >> 1];
|
|
4139
|
-
console.log("OSD时间:" + year + "-" + month + "-" + day + "-" + hour + "-" + minute + "-" + second + "-" + milliseconds);
|
|
4140
|
-
return {
|
|
4141
|
-
width,
|
|
4142
|
-
height,
|
|
4143
|
-
year,
|
|
4144
|
-
month,
|
|
4145
|
-
day,
|
|
4146
|
-
hour,
|
|
4147
|
-
minute,
|
|
4148
|
-
second
|
|
4149
|
-
};
|
|
4150
|
-
}
|
|
4151
|
-
JS_SetFrameInfoCallBack(value) {
|
|
4152
|
-
const {
|
|
4153
|
-
Module
|
|
4154
|
-
} = window;
|
|
4155
|
-
let resFCB = Module._JSPlayM4_SetFrameInfoCallBack(this.g_port, value); //帧信息回调
|
|
4156
|
-
if (resFCB != 1) {
|
|
4157
|
-
let resFrameInfoError = Module._JSPlayM4_GetLastError(this.g_port);
|
|
4158
|
-
console.log("resFrameInfoError:" + resFrameInfoError);
|
|
4159
|
-
}
|
|
4160
|
-
console.log("resFCB:" + resFCB);
|
|
4161
|
-
}
|
|
4162
|
-
JS_CapturePicture(iWind, fileName = `${new Date().getTime()}.jpeg`, type, callback, isDownload) {
|
|
4163
|
-
const {
|
|
4164
|
-
g_port
|
|
4165
|
-
} = this;
|
|
4166
|
-
const {
|
|
4167
|
-
Module
|
|
4168
|
-
} = window;
|
|
4169
|
-
//未播放,暂停状态且有缓冲数据
|
|
4170
|
-
if (!this.bPlay && this.bPause && this.tmpCapturePictureData) {
|
|
4171
|
-
doCapturePicture(this.tmpCapturePictureData);
|
|
4172
|
-
return;
|
|
4173
|
-
}
|
|
4174
|
-
let oFrameInfo = Module._JSPlayM4_GetFrameInfo(g_port);
|
|
4175
|
-
Module.HEAP32[oFrameInfo >> 2];
|
|
4176
|
-
let width = Module.HEAP32[oFrameInfo + 12 >> 2];
|
|
4177
|
-
let height = Module.HEAP32[oFrameInfo + 16 >> 2];
|
|
4178
|
-
nWidth = width;
|
|
4179
|
-
nHeight = height;
|
|
4180
|
-
if (nWidth && nHeight) {
|
|
4181
|
-
// 分配Jpeg空间
|
|
4182
|
-
let nJpegSize = nWidth * nHeight * 4 + 60;
|
|
4183
|
-
let pJpegData = Module._malloc(nJpegSize);
|
|
4184
|
-
let pJpegSize = Module._malloc(4);
|
|
4185
|
-
if (pJpegData === null) {
|
|
4186
|
-
return;
|
|
4187
|
-
}
|
|
4188
|
-
Module._JSPlayM4_GetJPEG(g_port, pJpegData, nJpegSize, pJpegSize); //buffer,buffer大小,Jpeg大小
|
|
4189
|
-
// 获取Jpeg图片大小
|
|
4190
|
-
let nJpegDataSize = Module.getValue(pJpegSize, "i32");
|
|
4191
|
-
console.log("JPEGSIZE:" + nJpegDataSize);
|
|
4192
|
-
// 获取Jpeg图片数据
|
|
4193
|
-
let aJpegData = new Uint8Array(nJpegDataSize);
|
|
4194
|
-
aJpegData.set(Module.HEAPU8.subarray(pJpegData, pJpegData + nJpegDataSize));
|
|
4195
|
-
doCapturePicture(aJpegData);
|
|
4196
|
-
aJpegData = null;
|
|
4197
|
-
if (pJpegData != null) {
|
|
4198
|
-
Module._free(pJpegData);
|
|
4199
|
-
pJpegData = null;
|
|
4200
|
-
}
|
|
4201
|
-
if (pJpegSize != null) {
|
|
4202
|
-
Module._free(pJpegSize);
|
|
4203
|
-
pJpegSize = null;
|
|
4204
|
-
}
|
|
4205
|
-
}
|
|
4206
|
-
function doCapturePicture(aJpegData) {
|
|
4207
|
-
if (fileName.indexOf(".jpeg") === -1) {
|
|
4208
|
-
fileName += '.jpeg';
|
|
4209
|
-
}
|
|
4210
|
-
if (!callback) {
|
|
4211
|
-
downloadFile(aJpegData, fileName);
|
|
4212
|
-
} else {
|
|
4213
|
-
const arrayBufferToBase64Img = buffer => {
|
|
4214
|
-
const arr = new Uint8Array(buffer);
|
|
4215
|
-
var str = "";
|
|
4216
|
-
for (let i = 0; i < arr.length; i++) {
|
|
4217
|
-
str += String.fromCharCode(arr[i]);
|
|
4218
|
-
}
|
|
4219
|
-
return `data:image/jpeg;base64,${window.btoa(str)}`;
|
|
4220
|
-
};
|
|
4221
|
-
callback({
|
|
4222
|
-
fileName: fileName,
|
|
4223
|
-
fileUint8Array: aJpegData,
|
|
4224
|
-
base64: arrayBufferToBase64Img(aJpegData)
|
|
4225
|
-
});
|
|
4226
|
-
}
|
|
4227
|
-
}
|
|
4228
|
-
}
|
|
4229
|
-
JS_GetOSDTime() {
|
|
4230
|
-
const {
|
|
4231
|
-
g_port
|
|
4232
|
-
} = this;
|
|
4233
|
-
const {
|
|
4234
|
-
Module
|
|
4235
|
-
} = window;
|
|
4236
|
-
const promise = new Promise((resolve, reject) => {
|
|
4237
|
-
let oFrameInfo = Module._JSPlayM4_GetFrameInfo(g_port);
|
|
4238
|
-
let year = Module.HEAP16[oFrameInfo + 60 >> 1];
|
|
4239
|
-
let month = Module.HEAP16[oFrameInfo + 62 >> 1];
|
|
4240
|
-
let day = Module.HEAP16[oFrameInfo + 66 >> 1];
|
|
4241
|
-
let hour = Module.HEAP16[oFrameInfo + 68 >> 1];
|
|
4242
|
-
let minute = Module.HEAP16[oFrameInfo + 70 >> 1];
|
|
4243
|
-
let second = Module.HEAP16[oFrameInfo + 72 >> 1];
|
|
4244
|
-
var time = new Date(`${year}-${month}-${day} ${hour}:${minute}:${second}`).getTime() / 1000;
|
|
4245
|
-
resolve(time);
|
|
4246
|
-
});
|
|
4247
|
-
return promise;
|
|
4248
|
-
}
|
|
4249
|
-
JS_Resize(width, height) {
|
|
4250
|
-
const {
|
|
4251
|
-
g_port
|
|
4252
|
-
} = this;
|
|
4253
|
-
const {
|
|
4254
|
-
Module
|
|
4255
|
-
} = window;
|
|
4256
|
-
console.log("width:" + width + ",height:" + height);
|
|
4257
|
-
let resSet = Module._JSPlayM4_SetCanvasSize(g_port, width, height);
|
|
4258
|
-
this.iWidth = width;
|
|
4259
|
-
this.iHeight = height;
|
|
4260
|
-
document.getElementById(this.szId).style.height = height + "px";
|
|
4261
|
-
document.getElementById(this.szId).style.width = width + "px";
|
|
4262
|
-
let oldcanv = document.getElementById(this.szId + '-player');
|
|
4263
|
-
if (oldcanv) {
|
|
4264
|
-
oldcanv.style.height = height + "px";
|
|
4265
|
-
oldcanv.style.width = width + "px";
|
|
4266
|
-
}
|
|
4267
|
-
console.log("resSet:" + resSet);
|
|
4268
|
-
}
|
|
4269
|
-
_doRelease() {
|
|
4270
|
-
const {
|
|
4271
|
-
g_port,
|
|
4272
|
-
szStreamUUID
|
|
4273
|
-
} = this;
|
|
4274
|
-
const {
|
|
4275
|
-
Module
|
|
4276
|
-
} = window;
|
|
4277
|
-
let resCS = Module._JSPlayM4_CloseStream(g_port);
|
|
4278
|
-
let resFP = Module._JSPlayM4_FreePort(g_port);
|
|
4279
|
-
if (resFP === 1) {
|
|
4280
|
-
// 端口是否已经被释放,设置为可用状态。
|
|
4281
|
-
this.portAvailable = true;
|
|
4282
|
-
}
|
|
4283
|
-
console.log("doRelease", resCS, resFP);
|
|
4284
|
-
if (this.pCanvasData !== null) {
|
|
4285
|
-
Module._free(this.pCanvasData);
|
|
4286
|
-
this.pCanvasData = null;
|
|
4287
|
-
}
|
|
4288
|
-
// this.pCanvasString = null;
|
|
4289
|
-
// this.pCanvasString = null;
|
|
4290
|
-
console.log("stop end");
|
|
4291
|
-
this.bPlay = false;
|
|
4292
|
-
this.bPlayIng = false;
|
|
4293
|
-
}
|
|
4294
|
-
JS_Stop() {
|
|
4295
|
-
const {
|
|
4296
|
-
g_port,
|
|
4297
|
-
szStreamUUID
|
|
4298
|
-
} = this;
|
|
4299
|
-
const {
|
|
4300
|
-
Module
|
|
4301
|
-
} = window; //销毁canvas资源
|
|
4302
|
-
|
|
4303
|
-
let canvasList = document.getElementById(this.szId);
|
|
4304
|
-
let oldcanv = document.getElementById(this.szId + '-player');
|
|
4305
|
-
if (oldcanv) {
|
|
4306
|
-
canvasList.removeChild(oldcanv);
|
|
4307
|
-
}
|
|
4308
|
-
if (this.szStorageUUID) {
|
|
4309
|
-
this.JS_StopSave();
|
|
4310
|
-
}
|
|
4311
|
-
// 暂停缓存截图数据 start
|
|
4312
|
-
|
|
4313
|
-
const callback = data => {
|
|
4314
|
-
if (data.fileUint8Array) {
|
|
4315
|
-
this.tmpCapturePictureData = data.fileUint8Array;
|
|
4316
|
-
}
|
|
4317
|
-
};
|
|
4318
|
-
const arrayBufferToBase64Img = buffer => {
|
|
4319
|
-
const arr = new Uint8Array(buffer);
|
|
4320
|
-
var str = "";
|
|
4321
|
-
for (let i = 0; i < arr.length; i++) {
|
|
4322
|
-
str += String.fromCharCode(arr[i]);
|
|
4323
|
-
}
|
|
4324
|
-
return `data:image/jpeg;base64,${window.btoa(str)}`;
|
|
4325
|
-
};
|
|
4326
|
-
this.JS_CapturePicture(0, `${new Date().getTime()}`, "JPEG", callback, true); // 保留最后一帧
|
|
4327
|
-
if (this.tmpCapturePictureData && this.tmpCapturePictureData.length > 0) {
|
|
4328
|
-
canvasList.style.backgroundImage = `url(${arrayBufferToBase64Img(this.tmpCapturePictureData)})`;
|
|
4329
|
-
} // 暂停缓存截图数据 end
|
|
4330
|
-
|
|
4331
|
-
const promise = new Promise((resolve, reject) => {
|
|
4332
|
-
if (this.portAvailable) {
|
|
4333
|
-
// 当前端口可用,不需要执行停止
|
|
4334
|
-
console.log("当前端口可用,不需要执行停止");
|
|
4335
|
-
return resolve({});
|
|
4336
|
-
}
|
|
4337
|
-
var stopStreamPromise = this.oStreamClient.stopAll(szStreamUUID);
|
|
4338
|
-
stopStreamPromise.then(data => {
|
|
4339
|
-
console.log("防抖 停止取流成功");
|
|
4340
|
-
let resS = Module._JSPlayM4_Stop(g_port);
|
|
4341
|
-
if (resS == 1) {
|
|
4342
|
-
this._doRelease();
|
|
4343
|
-
resolve({
|
|
4344
|
-
resS
|
|
4345
|
-
});
|
|
4346
|
-
} else {
|
|
4347
|
-
var jsPluginErrorCode = Module._JSPlayM4_GetLastError(g_port);
|
|
4348
|
-
if (jsPluginErrorCode == 35) {
|
|
4349
|
-
let timer10 = setInterval(() => {
|
|
4350
|
-
if (!resS) {
|
|
4351
|
-
resS = Module._JSPlayM4_Stop(g_port);
|
|
4352
|
-
if (resS == 1) {
|
|
4353
|
-
this._doRelease();
|
|
4354
|
-
resolve({
|
|
4355
|
-
resS
|
|
4356
|
-
});
|
|
4357
|
-
} else {
|
|
4358
|
-
jsPluginErrorCode = Module._JSPlayM4_GetLastError(g_port);
|
|
4359
|
-
console.log("stop error ", jsPluginErrorCode); // 停止失败,持续停止
|
|
4360
|
-
}
|
|
4361
|
-
} else {
|
|
4362
|
-
clearInterval(timer10);
|
|
4363
|
-
}
|
|
4364
|
-
}, 50);
|
|
4365
|
-
} else {
|
|
4366
|
-
console.log("stop - other error, still resolve", jsPluginErrorCode, resS);
|
|
4367
|
-
this._doRelease();
|
|
4368
|
-
resolve({
|
|
4369
|
-
resS,
|
|
4370
|
-
jsPluginErrorCode
|
|
4371
|
-
});
|
|
4372
|
-
}
|
|
4373
|
-
}
|
|
4374
|
-
}).catch(err => {
|
|
4375
|
-
console.log("停止取流失败_jsPluginErrorCode", err);
|
|
4376
|
-
this._doRelease();
|
|
4377
|
-
var jsPluginErrorCode = Module._JSPlayM4_GetLastError(g_port);
|
|
4378
|
-
console.log("停止取流失败_jsPluginErrorCode", g_port, jsPluginErrorCode);
|
|
4379
|
-
resolve({
|
|
4380
|
-
jsPluginErrorCode
|
|
4381
|
-
});
|
|
4382
|
-
});
|
|
4383
|
-
});
|
|
4384
|
-
return promise;
|
|
4385
|
-
}
|
|
4386
|
-
JS_DestroyWorker() {
|
|
4387
|
-
const {
|
|
4388
|
-
Module
|
|
4389
|
-
} = window;
|
|
4390
|
-
//buffer清空
|
|
4391
|
-
//bodyData.splice(0,bodyData.length);
|
|
4392
|
-
// aVideoYUVBuffer.splice(0, aVideoYUVBuffer.length);
|
|
4393
|
-
// aAudioPCMBuffer.splice(0, aAudioPCMBuffer.length);
|
|
4394
|
-
// aPsBuffer.splice(0, aPsBuffer.length);
|
|
4395
|
-
//销毁canvas资源
|
|
4396
|
-
let canvasList = document.getElementById(this.szId);
|
|
4397
|
-
let oldcanv = document.getElementById(this.szId + '-player');
|
|
4398
|
-
if (oldcanv) {
|
|
4399
|
-
canvasList.removeChild(oldcanv);
|
|
4400
|
-
}
|
|
4401
|
-
if (this.pCanvasData !== null) {
|
|
4402
|
-
Module._free(this.pCanvasData);
|
|
4403
|
-
this.pCanvasData = null;
|
|
4404
|
-
}
|
|
4405
|
-
this.pCanvasString = null;
|
|
4406
|
-
console.log("stop end");
|
|
4407
|
-
}
|
|
4408
|
-
JS_Fast(iWind, next) {
|
|
4409
|
-
var nextRate = this.iRate;
|
|
4410
|
-
if (next) {
|
|
4411
|
-
switch (next) {
|
|
4412
|
-
case 1:
|
|
4413
|
-
case 2:
|
|
4414
|
-
case 4:
|
|
4415
|
-
nextRate = next;
|
|
4416
|
-
break;
|
|
4417
|
-
case 3:
|
|
4418
|
-
nextRate = 0.5;
|
|
4419
|
-
break;
|
|
4420
|
-
default:
|
|
4421
|
-
nextRate = this.iRate;
|
|
4422
|
-
break;
|
|
4423
|
-
}
|
|
4424
|
-
} else {
|
|
4425
|
-
switch (this.iRate) {
|
|
4426
|
-
case 1:
|
|
4427
|
-
nextRate = 2;
|
|
4428
|
-
break;
|
|
4429
|
-
case 2:
|
|
4430
|
-
nextRate = 4;
|
|
4431
|
-
break;
|
|
4432
|
-
default:
|
|
4433
|
-
nextRate = this.iRate;
|
|
4434
|
-
break;
|
|
4435
|
-
}
|
|
4436
|
-
}
|
|
4437
|
-
this.oStreamClient.setPlayRate(this.szStreamUUID, nextRate);
|
|
4438
|
-
this.iRate = nextRate;
|
|
4439
|
-
console.log("开启倍速播放,多线程倍速,全解", nextRate);
|
|
4440
|
-
if (nextRate == 4) {
|
|
4441
|
-
// 用户启动4倍速,执行8线程解码。
|
|
4442
|
-
let SetDecodeThreadNumRes = window.Module._JSPlayM4_SetDecodeThreadNum(this.g_port, 8);
|
|
4443
|
-
console.log("SetDecodeThreadNumRes", SetDecodeThreadNumRes);
|
|
4444
|
-
}
|
|
4445
|
-
let res = window.Module._JSPlayM4_Fast(this.g_port);
|
|
4446
|
-
console.log("res", res);
|
|
4447
|
-
// if(nextRate < 2) {
|
|
4448
|
-
// this.Module._JSPlayM4_SetDecodeFrameType(this.g_port,0)
|
|
4449
|
-
// } else {
|
|
4450
|
-
// this.Module._JSPlayM4_SetDecodeFrameType(this.g_port,1);
|
|
4451
|
-
// // this.Module._JSPlayM4_SetIFrameDecInterval(this.g_port,0);
|
|
4452
|
-
// }
|
|
4453
|
-
}
|
|
4454
|
-
|
|
4455
|
-
JS_Slow() {
|
|
4456
|
-
var nextRate = this.iRate;
|
|
4457
|
-
switch (this.iRate) {
|
|
4458
|
-
case 2:
|
|
4459
|
-
nextRate = 1;
|
|
4460
|
-
break;
|
|
4461
|
-
case 4:
|
|
4462
|
-
nextRate = 2;
|
|
4463
|
-
break;
|
|
4464
|
-
default:
|
|
4465
|
-
nextRate = this.iRate;
|
|
4466
|
-
break;
|
|
4467
|
-
}
|
|
4468
|
-
this.oStreamClient.setPlayRate(this.szStreamUUID, nextRate);
|
|
4469
|
-
this.iRate = nextRate;
|
|
4470
|
-
console.log("开启倍速播放", nextRate);
|
|
4471
|
-
}
|
|
4472
|
-
JS_Speed(nextRate) {
|
|
4473
|
-
this.oStreamClient.setPlayRate(this.szStreamUUID, nextRate);
|
|
4474
|
-
this.iRate = nextRate;
|
|
4475
|
-
console.log("开启倍速播放", nextRate);
|
|
4476
|
-
}
|
|
4477
|
-
JS_Seek(iWndNum, szStartTime, szStopTime) {
|
|
4478
|
-
let oPromise = new Promise((resolve, reject) => {
|
|
4479
|
-
var res = window.Module._JSPlayM4_ResetBuffer(this.g_port, 1);
|
|
4480
|
-
console.log("seek 清理缓存", res);
|
|
4481
|
-
this.oStreamClient.seek(this.szStreamUUID, szStartTime, szStopTime).then(function () {
|
|
4482
|
-
resolve();
|
|
4483
|
-
}, function (oError) {
|
|
4484
|
-
reject(oError);
|
|
4485
|
-
});
|
|
4486
|
-
});
|
|
4487
|
-
return oPromise;
|
|
4488
|
-
}
|
|
4489
|
-
JSPlayM4_SetPrintLogFlag() {
|
|
4490
|
-
let resDR = window.Module._JSPlayM4_SetPrintLogFlag(this.g_port, 2);
|
|
4491
|
-
console.log("LogValue:" + 2 + ",resDR:" + resDR);
|
|
4492
|
-
}
|
|
4493
|
-
_JSPlayM4_SetDisplayRegion(left, right, top, bottom) {
|
|
4494
|
-
new Promise((resolve, reject) => {
|
|
4495
|
-
let resDR = window.Module._JSPlayM4_SetDisplayRegion(this.g_port, this.szId, left, right, top, bottom);
|
|
4496
|
-
resolve({
|
|
4497
|
-
code: 0,
|
|
4498
|
-
data: resDR
|
|
4499
|
-
});
|
|
4500
|
-
});
|
|
4501
|
-
}
|
|
4502
|
-
/**
|
|
4503
|
-
* @synopsis 暂停
|
|
4504
|
-
*
|
|
4505
|
-
* @param {number} iWndNum 窗口号
|
|
4506
|
-
*
|
|
4507
|
-
* @returns {none} 无
|
|
4508
|
-
*/
|
|
4509
|
-
JS_Pause(iWndNum) {
|
|
4510
|
-
if (!this.bPlay) {
|
|
4511
|
-
console.log("当前不是播放状态,无法暂停");
|
|
4512
|
-
return new Promise((resolve, reject) => {
|
|
4513
|
-
reject({
|
|
4514
|
-
code: 0,
|
|
4515
|
-
msg: "当前不是播放状态,不需要暂停"
|
|
4516
|
-
});
|
|
4517
|
-
});
|
|
4518
|
-
}
|
|
4519
|
-
// 暂停缓存截图数据 start
|
|
4520
|
-
const callback = data => {
|
|
4521
|
-
if (data.fileUint8Array) {
|
|
4522
|
-
this.tmpCapturePictureData = data.fileUint8Array;
|
|
4523
|
-
}
|
|
4524
|
-
};
|
|
4525
|
-
this.JS_CapturePicture(0, `${new Date().getTime()}`, "JPEG", callback, true);
|
|
4526
|
-
// 暂停缓存截图数据 end
|
|
4527
|
-
|
|
4528
|
-
if (this.playURL.indexOf("playback") !== -1) {
|
|
4529
|
-
//回放暂停
|
|
4530
|
-
// 如果为回放,需要记录暂停时间
|
|
4531
|
-
var pauseTimeFrame = this._JSPlayM4_GetFrameInfo(this.g_port);
|
|
4532
|
-
console.log("开始暂停");
|
|
4533
|
-
var pauseTime = `${pauseTimeFrame.year}` + (pauseTimeFrame.month > 9 ? pauseTimeFrame.month : `0${pauseTimeFrame.month}`) + (pauseTimeFrame.day > 9 ? pauseTimeFrame.day : `0${pauseTimeFrame.day}`) + (pauseTimeFrame.hour > 9 ? pauseTimeFrame.hour : `0${pauseTimeFrame.hour}`) + (pauseTimeFrame.minute > 9 ? pauseTimeFrame.minute : `0${pauseTimeFrame.minute}`) + (pauseTimeFrame.second > 9 ? pauseTimeFrame.second : `0${pauseTimeFrame.second}`);
|
|
4534
|
-
if (pauseTime.length === 14) {
|
|
4535
|
-
// 符合yyyymmddhhmmss后赋值
|
|
4536
|
-
this.bPauseTime = pauseTime;
|
|
4537
|
-
}
|
|
4538
|
-
}
|
|
4539
|
-
const promise = new Promise((resolve, reject) => {
|
|
4540
|
-
this.JS_Stop().then(() => {
|
|
4541
|
-
this.bPlay = false; // 停止后暂停状态需要复原
|
|
4542
|
-
this.bPause = true;
|
|
4543
|
-
resolve({
|
|
4544
|
-
code: 1,
|
|
4545
|
-
msg: "暂停成功"
|
|
4546
|
-
});
|
|
4547
|
-
}).catch(err => {
|
|
4548
|
-
reject({
|
|
4549
|
-
code: 0,
|
|
4550
|
-
msg: "暂停失败"
|
|
4551
|
-
});
|
|
4552
|
-
console.log("err", err);
|
|
4553
|
-
});
|
|
4554
|
-
});
|
|
4555
|
-
return promise;
|
|
4556
|
-
}
|
|
4557
|
-
|
|
4558
|
-
/**
|
|
4559
|
-
* @synopsis 恢复
|
|
4560
|
-
*
|
|
4561
|
-
* @param {number} iWndNum 窗口号
|
|
4562
|
-
*
|
|
4563
|
-
* @returns {none} 无
|
|
4564
|
-
*/
|
|
4565
|
-
JS_Resume(resumeTime) {
|
|
4566
|
-
const promise = new Promise((resolve, reject) => {
|
|
4567
|
-
if (resumeTime) {
|
|
4568
|
-
if (this.bPauseTime) {
|
|
4569
|
-
this.bPauseTime = this.bPauseTime.slice(0, 14 - resumeTime.length) + resumeTime;
|
|
4570
|
-
} else {
|
|
4571
|
-
this.bPauseTime = resumeTime;
|
|
4572
|
-
}
|
|
4573
|
-
}
|
|
4574
|
-
if (this.playURL.indexOf("playback") !== -1) {
|
|
4575
|
-
this.playURL = this.playURL.replace(/begin=[0-9]{8}T[0-9]{6}Z/gi, `begin=${this.bPauseTime.slice(0, 8)}T${this.bPauseTime.slice(8, 14)}Z`);
|
|
4576
|
-
}
|
|
4577
|
-
this.bPause = false;
|
|
4578
|
-
this.JS_Play(this.szUrl, {
|
|
4579
|
-
playURL: this.playURL
|
|
4580
|
-
}).then(data => {
|
|
4581
|
-
resolve({
|
|
4582
|
-
code: 1,
|
|
4583
|
-
msg: "恢复成功"
|
|
4584
|
-
});
|
|
4585
|
-
}).catch(err => {
|
|
4586
|
-
reject({
|
|
4587
|
-
code: 0,
|
|
4588
|
-
msg: "恢复失败"
|
|
4589
|
-
});
|
|
4590
|
-
});
|
|
4591
|
-
});
|
|
4592
|
-
return promise;
|
|
4593
|
-
}
|
|
4594
|
-
}
|
|
4595
|
-
window.JSPluginV2 = JSPluginV2;
|