正在显示
28 个修改的文件
包含
791 行增加
和
0 行删除
public/disttest/dist/EasyPlayer-lib.min.js
0 → 100644
此 diff 太大无法显示。
public/disttest/dist/EasyPlayer.wasm
0 → 100644
不能预览此文件类型

15.9 KB
1 | +*{margin:0;padding:0;height:100vh;width:100vw}#app[data-v-be9d76f5]{width:100vw;height:100vh}video[data-v-055abdc3]::-webkit-media-controls-play-button{display:none!important}video[data-v-055abdc3]::-webkit-media-controls-current-time-display{display:none!important}video[data-v-055abdc3]::-webkit-media-controls-time-remaining-display{display:none!important}video[data-v-055abdc3]::-webkit-media-controls-volume-control-container{display:none!important}video[data-v-055abdc3]::-webkit-media-controls-timeline{display:none!important}video[data-v-055abdc3]::-internal-media-controls-overflow-button{display:none!important}video[data-v-055abdc3]::-webkit-media-controls-fullscreen-button{display:none}.ali-player[data-v-055abdc3],.main[data-v-055abdc3],.video-center[data-v-055abdc3],.video[data-v-055abdc3]{width:100%;height:100%}.playerHome[data-v-78f825c0]{width:100%;height:100%;overflow:hidden;background:#f5f7fc}.player_box[data-v-78f825c0]{width:100vw;height:40vh}.player_box1[data-v-78f825c0]{width:99vw;height:99vh}.liveCon1[data-v-78f825c0],.liveCon[data-v-78f825c0]{width:100%;height:100%}.player_mian[data-v-78f825c0]{width:100%;height:60vh}.player_mian_yuntai[data-v-78f825c0]{height:40%;width:80%;margin-top:5%;margin-left:10%;display:flex;align-items:center;justify-content:space-between}.player_mian_yunta_left[data-v-78f825c0]{width:60%;height:100%;position:relative}.player_mian_yunta_left>img[data-v-78f825c0]{position:absolute;width:40vw;height:40vw}.player_mian_yunta_left .towards_top[data-v-78f825c0]{position:absolute;left:12vw;top:1vw;width:16vw;height:11vw;z-index:10}.player_mian_yunta_left .towards_right[data-v-78f825c0]{position:absolute;left:28vw;top:12vw;width:11vw;height:16vw;z-index:10}.player_mian_yunta_left .towards_lower[data-v-78f825c0]{position:absolute;left:12vw;top:28vw;width:16vw;height:11vw;z-index:10}.player_mian_yunta_left .towards_left[data-v-78f825c0]{position:absolute;left:1vw;top:12vw;width:11vw;height:16vw;z-index:10}.player_mian_yunta_right[data-v-78f825c0]{width:30%;height:100%}.player_mian_yunta_right>div[data-v-78f825c0]{width:100%;height:40vw;display:flex;flex-direction:column;align-items:center;justify-content:space-around}.player_mian_yunta_right>div>.towards_far[data-v-78f825c0]{width:10vw;height:10vw;background:#fff}.player_mian_yunta_right>div>.towards_far>img[data-v-78f825c0]{width:100%;height:100%}.player_mian_yunta_right>div>.towards_near[data-v-78f825c0]{width:10vw;height:10vw;background:#fff}.player_mian_yunta_right>div>.towards_near>img[data-v-78f825c0]{width:100%;height:100%}.player_mian_playback[data-v-78f825c0]{height:20%;width:70%} |
此 diff 太大无法显示。

16.0 KB

15.9 KB

16.0 KB
public/disttest/dist/assets/top-79b412a9.png
0 → 100644

16.0 KB
public/disttest/dist/crossdomain.xml
0 → 100644
public/disttest/dist/index.html
0 → 100644
1 | +<!doctype html> | ||
2 | +<html lang="en"> | ||
3 | + | ||
4 | +<head> | ||
5 | + <meta charset="UTF-8" /> | ||
6 | + <link rel="icon" type="image/svg+xml" href="/vite.svg" /> | ||
7 | + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
8 | + <!-- <meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
9 | + <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests"> --> | ||
10 | + <title>个旧市水库监控</title> | ||
11 | + <script type="module" crossorigin src="./assets/index-f06c19d5.js"></script> | ||
12 | + <link rel="stylesheet" href="./assets/index-304ce928.css"> | ||
13 | +</head> | ||
14 | + | ||
15 | +<body> | ||
16 | + <div id="app"></div> | ||
17 | + | ||
18 | + <script src="./public/lib/js/h5player.min.js" charset="utf-8"></script> | ||
19 | +</body> | ||
20 | + | ||
21 | +</html> |
public/disttest/dist/lib/js/h5player.min.js
0 → 100644
此 diff 太大无法显示。
1 | +/** | ||
2 | + * Created by wangweijie5 on 2016/12/5. | ||
3 | + */ | ||
4 | +(function (event) { | ||
5 | + const AUDIO_TYPE = 0; // 音频 | ||
6 | + const VIDEO_TYPE = 1; // 视频 | ||
7 | + const PRIVT_TYPE = 2; // 私有帧 | ||
8 | + | ||
9 | + const PLAYM4_AUDIO_FRAME = 100; // 音频帧 | ||
10 | + const PLAYM4_VIDEO_FRAME = 101; // 视频帧 | ||
11 | + | ||
12 | + const PLAYM4_OK = 1; | ||
13 | + const PLAYM4_ORDER_ERROR = 2; | ||
14 | + const PLAYM4_DECODE_ERROR = 44 // 解码失败 | ||
15 | + const PLAYM4_NOT_KEYFRAME = 48; // 非关键帧 | ||
16 | + const PLAYM4_NEED_MORE_DATA = 31; // 需要更多数据才能解析 | ||
17 | + const PLAYM4_NEED_NEET_LOOP = 35; //丢帧需要下个循环 | ||
18 | + const PLAYM4_SYS_NOT_SUPPORT = 16; // 不支持 | ||
19 | + | ||
20 | + importScripts('Decoder.js'); | ||
21 | + Module.addOnPostRun(function () { | ||
22 | + postMessage({ 'function': "loaded" }); | ||
23 | + }); | ||
24 | + | ||
25 | + var iStreamMode = 0; // 流模式 | ||
26 | + | ||
27 | + var bOpenMode = false; | ||
28 | + var bOpenStream = false; | ||
29 | + | ||
30 | + var funGetFrameData = null; | ||
31 | + var funGetAudFrameData = null; | ||
32 | + | ||
33 | + var bWorkerPrintLog = false;//worker层log开关 | ||
34 | + | ||
35 | + var g_nPort = -1; | ||
36 | + var pInputData = null; | ||
37 | + var inputBufferSize = 40960; | ||
38 | + | ||
39 | + self.JSPlayM4_RunTimeInfoCallBack = function (nPort, pstRunTimeInfo, pUser) { | ||
40 | + let port = nPort; | ||
41 | + let user = pUser; | ||
42 | + let nRunTimeModule = Module.HEAP32[pstRunTimeInfo >> 2]; | ||
43 | + let nStrVersion = Module.HEAP32[pstRunTimeInfo + 4 >> 2]; | ||
44 | + let nFrameTimeStamp = Module.HEAP32[pstRunTimeInfo + 8 >> 2]; | ||
45 | + let nFrameNum = Module.HEAP32[pstRunTimeInfo + 12 >> 2]; | ||
46 | + let nErrorCode = Module.HEAP32[pstRunTimeInfo + 16 >> 2]; | ||
47 | + // console.log("nRunTimeModule:"+nRunTimeModule+",nFrameNum:"+nFrameNum+",nErrorCode:"+nErrorCode); | ||
48 | + postMessage({ 'function': "RunTimeInfoCallBack", 'nRunTimeModule': nRunTimeModule, 'nStrVersion': nStrVersion, 'nFrameTimeStamp': nFrameTimeStamp, 'nFrameNum': nFrameNum, 'nErrorCode': nErrorCode }); | ||
49 | + } | ||
50 | + | ||
51 | + onmessage = function (event) { | ||
52 | + var eventData = event.data; | ||
53 | + var res = 0; | ||
54 | + switch (eventData.command) { | ||
55 | + case "printLog": | ||
56 | + let downloadFlag = eventData.data; | ||
57 | + if (downloadFlag === true) { | ||
58 | + bWorkerPrintLog = true; | ||
59 | + res = Module._SetPrintLogFlag(g_nPort, downloadFlag); | ||
60 | + } | ||
61 | + else { | ||
62 | + bWorkerPrintLog = false; | ||
63 | + res = Module._SetPrintLogFlag(g_nPort, downloadFlag); | ||
64 | + } | ||
65 | + | ||
66 | + if (res !== PLAYM4_OK) { | ||
67 | + console.log("DecodeWorker.js: PlayerSDK print log failed,res" + res); | ||
68 | + postMessage({ 'function': "printLog", 'errorCode': res }); | ||
69 | + } | ||
70 | + break; | ||
71 | + case "SetPlayPosition": | ||
72 | + let nFrameNumOrTime = eventData.data; | ||
73 | + let enPosType = eventData.type; | ||
74 | + // res = Module._SetPlayPosition(nFrameNumOrTime,enPosType); | ||
75 | + // if (res !== PLAYM4_OK) | ||
76 | + // { | ||
77 | + // postMessage({'function': "SetPlayPosition", 'errorCode': res}); | ||
78 | + // return; | ||
79 | + // } | ||
80 | + // //有没有buffer需要清除 | ||
81 | + | ||
82 | + break; | ||
83 | + case "SetStreamOpenMode": | ||
84 | + //获取端口号 | ||
85 | + g_nPort = Module._GetPort(); | ||
86 | + //设置流打开模式 | ||
87 | + iStreamMode = eventData.data; | ||
88 | + res = Module._SetStreamOpenMode(g_nPort, iStreamMode); | ||
89 | + if (res !== PLAYM4_OK) { | ||
90 | + postMessage({ 'function': "SetStreamOpenMode", 'errorCode': res }); | ||
91 | + return; | ||
92 | + } | ||
93 | + bOpenMode = true; | ||
94 | + break; | ||
95 | + | ||
96 | + case "OpenStream": | ||
97 | + // 接收到的数据 | ||
98 | + var iHeadLen = eventData.dataSize; | ||
99 | + var pHead = Module._malloc(iHeadLen + 4); | ||
100 | + if (pHead === null) { | ||
101 | + return; | ||
102 | + } | ||
103 | + var aHead = Module.HEAPU8.subarray(pHead, pHead + iHeadLen); | ||
104 | + aHead.set(new Uint8Array(eventData.data)); | ||
105 | + res = Module._OpenStream(g_nPort, pHead, iHeadLen, eventData.bufPoolSize); | ||
106 | + postMessage({ 'function': "OpenStream", 'errorCode': res }); | ||
107 | + if (res !== PLAYM4_OK) { | ||
108 | + //释放内存 | ||
109 | + Module._free(pHead); | ||
110 | + pHead = null; | ||
111 | + return; | ||
112 | + } | ||
113 | + bOpenStream = true; | ||
114 | + break; | ||
115 | + case "Play": | ||
116 | + let resP = Module._Play(g_nPort); | ||
117 | + if (resP !== PLAYM4_OK) { | ||
118 | + return; | ||
119 | + } | ||
120 | + break; | ||
121 | + case "InputData": | ||
122 | + // 接收到的数据 | ||
123 | + var iLen = eventData.dataSize; | ||
124 | + if (iLen > 0) { | ||
125 | + if (pInputData == null || iLen > inputBufferSize) { | ||
126 | + if (pInputData != null) { | ||
127 | + Module._free(pInputData); | ||
128 | + pInputData = null; | ||
129 | + } | ||
130 | + if (iLen > inputBufferSize) { | ||
131 | + inputBufferSize = iLen; | ||
132 | + } | ||
133 | + | ||
134 | + pInputData = Module._malloc(inputBufferSize); | ||
135 | + if (pInputData === null) { | ||
136 | + return; | ||
137 | + } | ||
138 | + } | ||
139 | + | ||
140 | + var inputData = new Uint8Array(eventData.data); | ||
141 | + // var aInputData = Module.HEAPU8.subarray(pInputData, pInputData + iLen); | ||
142 | + // aInputData.set(inputData); | ||
143 | + Module.writeArrayToMemory(inputData, pInputData); | ||
144 | + inputData = null; | ||
145 | + res = Module._InputData(g_nPort, pInputData, iLen); | ||
146 | + if (res !== PLAYM4_OK) { | ||
147 | + let errorCode = Module._GetLastError(g_nPort); | ||
148 | + let sourceRemain = Module._GetSourceBufferRemain(g_nPort); | ||
149 | + postMessage({ 'function': "InputData", 'errorCode': errorCode, "sourceRemain": sourceRemain }); | ||
150 | + } | ||
151 | + //Module._free(pInputData); | ||
152 | + //pInputData = null; | ||
153 | + } else { | ||
154 | + let sourceRemain = Module._GetSourceBufferRemain(g_nPort); | ||
155 | + if (sourceRemain == 0) { | ||
156 | + postMessage({ 'function': "InputData", 'errorCode': PLAYM4_NEED_MORE_DATA }); | ||
157 | + return; | ||
158 | + } | ||
159 | + } | ||
160 | + | ||
161 | + ///////////////////// | ||
162 | + // if (funGetFrameData === null) { | ||
163 | + // funGetFrameData = Module.cwrap('GetFrameData', 'number'); | ||
164 | + // } | ||
165 | + | ||
166 | + while (bOpenMode && bOpenStream) { | ||
167 | + | ||
168 | + var ret = getFrameData(); | ||
169 | + // 直到获取视频帧或数据不足为止 | ||
170 | + if (PLAYM4_VIDEO_FRAME === ret || PLAYM4_NEED_MORE_DATA === ret || PLAYM4_ORDER_ERROR === ret)//PLAYM4_VIDEO_FRAME === ret || || PLAYM4_NEED_NEET_LOOP === ret | ||
171 | + { | ||
172 | + break; | ||
173 | + } | ||
174 | + } | ||
175 | + break; | ||
176 | + | ||
177 | + case "SetSecretKey": | ||
178 | + var keyLen = eventData.nKeyLen; | ||
179 | + var pKeyData = Module._malloc(keyLen); | ||
180 | + if (pKeyData === null) { | ||
181 | + return; | ||
182 | + } | ||
183 | + var nKeySize = eventData.data.length | ||
184 | + var bufData = stringToBytes(eventData.data); | ||
185 | + var aKeyData = Module.HEAPU8.subarray(pKeyData, pKeyData + keyLen); | ||
186 | + let u8array = new Uint8Array(keyLen); | ||
187 | + aKeyData.set(u8array, 0); | ||
188 | + aKeyData.set(new Uint8Array(bufData)); | ||
189 | + aKeyData = null; | ||
190 | + u8array = null; | ||
191 | + | ||
192 | + res = Module._SetSecretKey(g_nPort, eventData.nKeyType, pKeyData, keyLen);//, nKeySize | ||
193 | + if (res !== PLAYM4_OK) { | ||
194 | + postMessage({ 'function': "SetSecretKey", 'errorCode': res }); | ||
195 | + Module._free(pKeyData); | ||
196 | + pKeyData = null; | ||
197 | + return; | ||
198 | + } | ||
199 | + | ||
200 | + Module._free(pKeyData); | ||
201 | + pKeyData = null; | ||
202 | + break; | ||
203 | + | ||
204 | + case "GetBMP": | ||
205 | + var nBMPWidth = eventData.width; | ||
206 | + var nBMPHeight = eventData.height; | ||
207 | + var pYUVData = eventData.data; | ||
208 | + var nYUVSize = nBMPWidth * nBMPHeight * 3 / 2; | ||
209 | + var oJpegCropRect = { | ||
210 | + left: eventData.left, | ||
211 | + top: eventData.top, | ||
212 | + right: eventData.right, | ||
213 | + bottom: eventData.bottom | ||
214 | + }; | ||
215 | + | ||
216 | + var pDataYUV = Module._malloc(nYUVSize); | ||
217 | + if (pDataYUV === null) { | ||
218 | + return; | ||
219 | + } | ||
220 | + | ||
221 | + Module.writeArrayToMemory(new Uint8Array(pYUVData, 0, nYUVSize), pDataYUV); | ||
222 | + | ||
223 | + // 分配BMP空间 | ||
224 | + var nBmpSize = nBMPWidth * nBMPHeight * 4 + 60; | ||
225 | + var pBmpData = Module._malloc(nBmpSize); | ||
226 | + var pBmpSize = Module._malloc(4); | ||
227 | + if (pBmpData === null || pBmpSize === null) { | ||
228 | + Module._free(pDataYUV); | ||
229 | + pDataYUV = null; | ||
230 | + | ||
231 | + if (pBmpData != null) { | ||
232 | + Module._free(pBmpData); | ||
233 | + pBmpData = null; | ||
234 | + } | ||
235 | + | ||
236 | + if (pBmpSize != null) { | ||
237 | + Module._free(pBmpSize); | ||
238 | + pBmpSize = null; | ||
239 | + } | ||
240 | + return; | ||
241 | + } | ||
242 | + | ||
243 | + //Module._memset(pBmpSize, nBmpSize, 4); // 防止bmp截图出现输入数据过大的错误码 | ||
244 | + Module.setValue(pBmpSize, nBmpSize, "i32"); | ||
245 | + res = Module._GetBMP(g_nPort, pDataYUV, nYUVSize, pBmpData, pBmpSize, | ||
246 | + oBMPCropRect.left, oBMPCropRect.top, oBMPCropRect.right, oBMPCropRect.bottom); | ||
247 | + if (res !== PLAYM4_OK) { | ||
248 | + postMessage({ 'function': "GetBMP", 'errorCode': res }); | ||
249 | + Module._free(pDataYUV); | ||
250 | + pDataYUV = null; | ||
251 | + Module._free(pBmpData); | ||
252 | + pBmpData = null; | ||
253 | + Module._free(pBmpSize); | ||
254 | + pBmpSize = null; | ||
255 | + return; | ||
256 | + } | ||
257 | + | ||
258 | + // 获取BMP图片大小 | ||
259 | + var nBmpDataSize = Module.getValue(pBmpSize, "i32"); | ||
260 | + | ||
261 | + // 获取BMP图片数据 | ||
262 | + var aBmpData = new Uint8Array(nBmpDataSize); | ||
263 | + aBmpData.set(Module.HEAPU8.subarray(pBmpData, pBmpData + nBmpDataSize)); | ||
264 | + | ||
265 | + postMessage({ 'function': "GetBMP", 'data': aBmpData, 'errorCode': res }, [aBmpData.buffer]); | ||
266 | + aBmpData = null; | ||
267 | + if (pDataYUV != null) { | ||
268 | + Module._free(pDataYUV); | ||
269 | + pDataYUV = null; | ||
270 | + } | ||
271 | + if (pBmpData != null) { | ||
272 | + Module._free(pBmpData); | ||
273 | + pBmpData = null; | ||
274 | + } | ||
275 | + if (pBmpSize != null) { | ||
276 | + Module._free(pBmpSize); | ||
277 | + pBmpSize = null; | ||
278 | + } | ||
279 | + break; | ||
280 | + | ||
281 | + case "GetJPEG": | ||
282 | + var nJpegWidth = eventData.width; | ||
283 | + var nJpegHeight = eventData.height; | ||
284 | + var pYUVData1 = eventData.data; | ||
285 | + var nYUVSize1 = nJpegWidth * nJpegHeight * 3 / 2; | ||
286 | + var oJpegCropRect = { | ||
287 | + left: eventData.left, | ||
288 | + top: eventData.top, | ||
289 | + right: eventData.right, | ||
290 | + bottom: eventData.bottom | ||
291 | + }; | ||
292 | + | ||
293 | + var pDataYUV1 = Module._malloc(nYUVSize1); | ||
294 | + if (pDataYUV1 === null) { | ||
295 | + return; | ||
296 | + } | ||
297 | + | ||
298 | + Module.writeArrayToMemory(new Uint8Array(pYUVData1, 0, nYUVSize1), pDataYUV1); | ||
299 | + | ||
300 | + // 分配JPEG空间 | ||
301 | + var pJpegData = Module._malloc(nYUVSize1); | ||
302 | + var pJpegSize = Module._malloc(4); | ||
303 | + if (pJpegData === null || pJpegSize === null) { | ||
304 | + if (pJpegData != null) { | ||
305 | + Module._free(pJpegData); | ||
306 | + pJpegData = null; | ||
307 | + } | ||
308 | + | ||
309 | + if (pJpegSize != null) { | ||
310 | + Module._free(pJpegSize); | ||
311 | + pJpegSize = null; | ||
312 | + } | ||
313 | + | ||
314 | + if (pDataYUV1 != null) { | ||
315 | + Module._free(pDataYUV1); | ||
316 | + pDataYUV1 = null; | ||
317 | + } | ||
318 | + return; | ||
319 | + } | ||
320 | + | ||
321 | + Module.setValue(pJpegSize, nJpegWidth * nJpegHeight * 2, "i32"); // JPEG抓图,输入缓冲长度不小于当前帧YUV大小 | ||
322 | + | ||
323 | + res = Module._GetJPEG(g_nPort, pDataYUV1, nYUVSize1, pJpegData, pJpegSize, | ||
324 | + oJpegCropRect.left, oJpegCropRect.top, oJpegCropRect.right, oJpegCropRect.bottom); | ||
325 | + if (res !== PLAYM4_OK) { | ||
326 | + postMessage({ 'function': "GetJPEG", 'errorCode': res }); | ||
327 | + if (pJpegData != null) { | ||
328 | + Module._free(pJpegData); | ||
329 | + pJpegData = null; | ||
330 | + } | ||
331 | + | ||
332 | + if (pJpegSize != null) { | ||
333 | + Module._free(pJpegSize); | ||
334 | + pJpegSize = null; | ||
335 | + } | ||
336 | + | ||
337 | + if (pDataYUV1 != null) { | ||
338 | + Module._free(pDataYUV1); | ||
339 | + pDataYUV1 = null; | ||
340 | + } | ||
341 | + return; | ||
342 | + } | ||
343 | + | ||
344 | + // 获取JPEG图片大小 | ||
345 | + var nJpegSize = Module.getValue(pJpegSize, "i32"); | ||
346 | + | ||
347 | + // 获取JPEG图片数据 | ||
348 | + var aJpegData = new Uint8Array(nJpegSize); | ||
349 | + aJpegData.set(Module.HEAPU8.subarray(pJpegData, pJpegData + nJpegSize)); | ||
350 | + | ||
351 | + postMessage({ 'function': "GetJPEG", 'data': aJpegData, 'errorCode': res }, [aJpegData.buffer]); | ||
352 | + | ||
353 | + nJpegSize = null; | ||
354 | + aJpegData = null; | ||
355 | + | ||
356 | + if (pDataYUV1 != null) { | ||
357 | + Module._free(pDataYUV1); | ||
358 | + pDataYUV1 = null; | ||
359 | + } | ||
360 | + if (pJpegData != null) { | ||
361 | + Module._free(pJpegData); | ||
362 | + pJpegData = null; | ||
363 | + } | ||
364 | + if (pJpegSize != null) { | ||
365 | + Module._free(pJpegSize); | ||
366 | + pJpegSize = null; | ||
367 | + } | ||
368 | + break; | ||
369 | + | ||
370 | + case "SetDecodeFrameType": | ||
371 | + var nFrameType = eventData.data; | ||
372 | + res = Module._SetDecodeFrameType(g_nPort, nFrameType); | ||
373 | + if (res !== PLAYM4_OK) { | ||
374 | + postMessage({ 'function': "SetDecodeFrameType", 'errorCode': res }); | ||
375 | + return; | ||
376 | + } | ||
377 | + break; | ||
378 | + case "CloseStream": | ||
379 | + //stop | ||
380 | + let resS = Module._Stop(g_nPort); | ||
381 | + if (resS !== PLAYM4_OK) { | ||
382 | + postMessage({ 'function': "Stop", 'errorCode': res }); | ||
383 | + return; | ||
384 | + } | ||
385 | + //closeStream | ||
386 | + res = Module._CloseStream(g_nPort); | ||
387 | + if (res !== PLAYM4_OK) { | ||
388 | + postMessage({ 'function': "CloseStream", 'errorCode': res }); | ||
389 | + return; | ||
390 | + } | ||
391 | + //freePort | ||
392 | + let resF = Module._FreePort(g_nPort); | ||
393 | + if (resF !== PLAYM4_OK) { | ||
394 | + postMessage({ 'function': "FreePort", 'errorCode': res }); | ||
395 | + return; | ||
396 | + } | ||
397 | + if (pInputData != null) { | ||
398 | + Module._free(pInputData); | ||
399 | + pInputData = null; | ||
400 | + } | ||
401 | + break; | ||
402 | + case "PlaySound": | ||
403 | + let resPS = Module._PlaySound(g_nPort); | ||
404 | + if (resPS !== PLAYM4_OK) { | ||
405 | + console.log("PlaySound failed"); | ||
406 | + return; | ||
407 | + } | ||
408 | + break; | ||
409 | + case "StopSound": | ||
410 | + let resSS = Module._StopSound(); | ||
411 | + if (resSS !== PLAYM4_OK) { | ||
412 | + console.log("StopSound failed"); | ||
413 | + return; | ||
414 | + } | ||
415 | + break; | ||
416 | + case "SetVolume": | ||
417 | + let resSV = Module._SetVolume(g_nPort, eventData.volume); | ||
418 | + if (resSV !== PLAYM4_OK) { | ||
419 | + console.log("Audio SetVolume failed"); | ||
420 | + return; | ||
421 | + } | ||
422 | + break; | ||
423 | + case "GetVolume": | ||
424 | + let volume = Module._GetVolume(); | ||
425 | + if (volume > 0) { | ||
426 | + postMessage({ 'function': "GetVolume", 'volume': volume }); | ||
427 | + } | ||
428 | + else { | ||
429 | + console.log("Audio GetVolume failed"); | ||
430 | + return; | ||
431 | + } | ||
432 | + break; | ||
433 | + case "OnlyPlaySound": | ||
434 | + let resOPS = Module._OnlyPlaySound(g_nPort); | ||
435 | + if (resOPS !== PLAYM4_OK) { | ||
436 | + console.log("OnlyPlaySound failed"); | ||
437 | + return; | ||
438 | + } | ||
439 | + break; | ||
440 | + case "Pause": | ||
441 | + let resPa = Module._Pause(g_nPort, eventData.bPlay); | ||
442 | + if (resPa !== PLAYM4_OK) { | ||
443 | + console.log("Pause failed"); | ||
444 | + return; | ||
445 | + } | ||
446 | + case "PlayRate": | ||
447 | + Module._SetPlayRate(g_nPort, eventData.playRate); | ||
448 | + break; | ||
449 | + case "SetIFrameDecInterval": | ||
450 | + Module._SetIFrameDecInterval(g_nPort, eventData.data); | ||
451 | + break; | ||
452 | + case "SetLostFrameMode": | ||
453 | + Module._SetLostFrameMode(g_nPort, eventData.data, 0); | ||
454 | + break; | ||
455 | + case "SetDemuxModel": | ||
456 | + Module._SetDemuxModel(g_nPort, eventData.nIdemuxType, eventData.bTrue); | ||
457 | + break; | ||
458 | + case "SkipErrorData": | ||
459 | + Module._SkipErrorData(g_nPort, eventData.bSkip); | ||
460 | + break; | ||
461 | + case "SetDecodeERC": | ||
462 | + Module._SetDecodeERC(g_nPort, eventData.nLevel); | ||
463 | + break; | ||
464 | + case "SetANRParam": | ||
465 | + Module._SetANRParam(g_nPort, eventData.nEnable, eventData.nANRLevel); | ||
466 | + break; | ||
467 | + case "SetResampleValue": | ||
468 | + Module._SetResampleValue(g_nPort, eventData.nEnable, eventData.resampleValue); | ||
469 | + break; | ||
470 | + case "GetLastError": | ||
471 | + let errorCode = Module._GetLastError(g_nPort); | ||
472 | + postMessage({ 'function': "GetLastError", 'errorCode': errorCode }); | ||
473 | + break; | ||
474 | + case "SetGlobalBaseTime": | ||
475 | + Module._SetGlobalBaseTime(g_nPort, eventData.year, eventData.month, eventData.day, eventData.hour, eventData.min, eventData.sec, eventData.ms); | ||
476 | + break; | ||
477 | + case "SetRunTimeInfoCB": | ||
478 | + Module._SetRunTimeInfoCallBackEx(g_nPort, eventData.nModuleType, 0); | ||
479 | + break; | ||
480 | + default: | ||
481 | + break; | ||
482 | + } | ||
483 | + }; | ||
484 | + | ||
485 | + function getOSDTime(oFrameInfo) { | ||
486 | + var iYear = oFrameInfo.year; | ||
487 | + var iMonth = oFrameInfo.month; | ||
488 | + var iDay = oFrameInfo.day; | ||
489 | + var iHour = oFrameInfo.hour; | ||
490 | + var iMinute = oFrameInfo.minute; | ||
491 | + var iSecond = oFrameInfo.second; | ||
492 | + | ||
493 | + if (iMonth < 10) { | ||
494 | + iMonth = "0" + iMonth; | ||
495 | + } | ||
496 | + if (iDay < 10) { | ||
497 | + iDay = "0" + iDay; | ||
498 | + } | ||
499 | + if (iHour < 10) { | ||
500 | + iHour = "0" + iHour; | ||
501 | + } | ||
502 | + if (iMinute < 10) { | ||
503 | + iMinute = "0" + iMinute; | ||
504 | + } | ||
505 | + if (iSecond < 10) { | ||
506 | + iSecond = "0" + iSecond; | ||
507 | + } | ||
508 | + | ||
509 | + return iYear + "-" + iMonth + "-" + iDay + " " + iHour + ":" + iMinute + ":" + iSecond; | ||
510 | + } | ||
511 | + // 获取帧数据 | ||
512 | + function getFrameData() { | ||
513 | + // function getFrameData() { | ||
514 | + // 获取帧数据 | ||
515 | + var res = Module._GetFrameData(); | ||
516 | + //var res = fun(); | ||
517 | + if (res === PLAYM4_OK) { | ||
518 | + var oFrameInfo = Module._GetFrameInfo(); | ||
519 | + switch (oFrameInfo.frameType) { | ||
520 | + case AUDIO_TYPE: | ||
521 | + var iSize = oFrameInfo.frameSize; | ||
522 | + if (0 === iSize) { | ||
523 | + return -1; | ||
524 | + } | ||
525 | + var pPCM = Module._GetFrameBuffer(); | ||
526 | + // var audioBuf = new ArrayBuffer(iSize); | ||
527 | + var aPCMData = new Uint8Array(iSize); | ||
528 | + aPCMData.set(Module.HEAPU8.subarray(pPCM, pPCM + iSize)); | ||
529 | + if (bWorkerPrintLog) { | ||
530 | + console.log("<<<Worker: audio media Info: nSise:" + oFrameInfo.frameSize + ",nSampleRate:" + oFrameInfo.samplesPerSec + ',channel:' + oFrameInfo.channels + ',bitsPerSample:' + oFrameInfo.bitsPerSample); | ||
531 | + } | ||
532 | + postMessage({ | ||
533 | + 'function': "GetFrameData", 'type': "audioType", 'data': aPCMData.buffer, | ||
534 | + 'frameInfo': oFrameInfo, 'errorCode': res | ||
535 | + }, [aPCMData.buffer]); | ||
536 | + | ||
537 | + oFrameInfo = null; | ||
538 | + pPCM = null; | ||
539 | + aPCMData = null; | ||
540 | + return PLAYM4_AUDIO_FRAME; | ||
541 | + | ||
542 | + case VIDEO_TYPE: | ||
543 | + var szOSDTime = getOSDTime(oFrameInfo); | ||
544 | + | ||
545 | + var iWidth = oFrameInfo.width; | ||
546 | + var iHeight = oFrameInfo.height; | ||
547 | + | ||
548 | + var iYUVSize = iWidth * iHeight * 3 / 2; | ||
549 | + if (0 === iYUVSize) { | ||
550 | + return -1; | ||
551 | + } | ||
552 | + | ||
553 | + var pYUV = Module._GetFrameBuffer(); | ||
554 | + | ||
555 | + // 图像数据渲染后压回,若从主码流切到子码流,存在数组大小与图像大小不匹配现象 | ||
556 | + var aYUVData = new Uint8Array(iYUVSize); | ||
557 | + aYUVData.set(Module.HEAPU8.subarray(pYUV, pYUV + iYUVSize)); | ||
558 | + if (bWorkerPrintLog) { | ||
559 | + console.log("<<<Worker: video media Info: Width:" + oFrameInfo.width + ",Height:" + oFrameInfo.height + ",timeStamp:" + oFrameInfo.timeStamp); | ||
560 | + } | ||
561 | + | ||
562 | + postMessage({ | ||
563 | + 'function': "GetFrameData", 'type': "videoType", 'data': aYUVData.buffer, | ||
564 | + 'dataLen': aYUVData.length, 'osd': szOSDTime, 'frameInfo': oFrameInfo, 'errorCode': res | ||
565 | + }, [aYUVData.buffer]); | ||
566 | + | ||
567 | + oFrameInfo = null; | ||
568 | + pYUV = null; | ||
569 | + aYUVData = null; | ||
570 | + return PLAYM4_VIDEO_FRAME; | ||
571 | + | ||
572 | + case PRIVT_TYPE: | ||
573 | + postMessage({ | ||
574 | + 'function': "GetFrameData", 'type': "", 'data': null, | ||
575 | + 'dataLen': -1, 'osd': 0, 'frameInfo': null, 'errorCode': PLAYM4_SYS_NOT_SUPPORT | ||
576 | + }); | ||
577 | + return PLAYM4_SYS_NOT_SUPPORT; | ||
578 | + | ||
579 | + default: | ||
580 | + postMessage({ | ||
581 | + 'function': "GetFrameData", 'type': "", 'data': null, | ||
582 | + 'dataLen': -1, 'osd': 0, 'frameInfo': null, 'errorCode': PLAYM4_SYS_NOT_SUPPORT | ||
583 | + }); | ||
584 | + return PLAYM4_SYS_NOT_SUPPORT; | ||
585 | + } | ||
586 | + } | ||
587 | + else { | ||
588 | + let errorCode = Module._GetLastError(g_nPort); | ||
589 | + //解码失败返回裸数据 | ||
590 | + if (PLAYM4_DECODE_ERROR === errorCode) { | ||
591 | + var rawInfo = Module._GetRawDataInfo(); | ||
592 | + var pRawData = Module._GetRawDataBuffer(); | ||
593 | + var aRawData = new Uint8Array(rawInfo.isize); | ||
594 | + aRawData.set(Module.HEAPU8.subarray(pRawData, pRawData + rawInfo.isize)); | ||
595 | + postMessage({ | ||
596 | + 'function': "GetRawData", 'type': "", 'data': aRawData.buffer, | ||
597 | + 'rawDataLen': rawInfo.isize, 'osd': 0, 'frameInfo': null, 'errorCode': errorCode | ||
598 | + }); | ||
599 | + rawInfo = null; | ||
600 | + pRawData = null; | ||
601 | + aRawData = null; | ||
602 | + } | ||
603 | + //需要更多数据 | ||
604 | + if (PLAYM4_NEED_MORE_DATA === errorCode || PLAYM4_SYS_NOT_SUPPORT === errorCode || PLAYM4_NEED_NEET_LOOP === errorCode) { | ||
605 | + postMessage({ | ||
606 | + 'function': "GetFrameData", 'type': "", 'data': null, | ||
607 | + 'dataLen': -1, 'osd': 0, 'frameInfo': null, 'errorCode': errorCode | ||
608 | + }); | ||
609 | + } | ||
610 | + return errorCode; | ||
611 | + } | ||
612 | + } | ||
613 | + | ||
614 | + // 开始计算时间 | ||
615 | + function startTime() { | ||
616 | + return new Date().getTime(); | ||
617 | + } | ||
618 | + | ||
619 | + // 结束计算时间 | ||
620 | + function endTime() { | ||
621 | + return new Date().getTime(); | ||
622 | + } | ||
623 | + | ||
624 | + // 字母字符串转byte数组 | ||
625 | + function stringToBytes(str) { | ||
626 | + var ch, st, re = []; | ||
627 | + for (var i = 0; i < str.length; i++) { | ||
628 | + ch = str.charCodeAt(i); // get char | ||
629 | + st = []; // set up "stack" | ||
630 | + do { | ||
631 | + st.push(ch & 0xFF); // push byte to stack | ||
632 | + ch = ch >> 8; // shift value down by 1 byte | ||
633 | + } | ||
634 | + while (ch); | ||
635 | + // add stack contents to result | ||
636 | + // done because chars have "wrong" endianness | ||
637 | + re = re.concat(st.reverse()); | ||
638 | + } | ||
639 | + // return an array of bytes | ||
640 | + return re; | ||
641 | + } | ||
642 | +})(); |
此 diff 太大无法显示。
此 diff 太大无法显示。
不能预览此文件类型
1 | +"use strict";var Module={};var initializedJS=false;function threadPrintErr(){var text=Array.prototype.slice.call(arguments).join(" ");console.error(text)}function threadAlert(){var text=Array.prototype.slice.call(arguments).join(" ");postMessage({cmd:"alert",text:text,threadId:Module["_pthread_self"]()})}var err=threadPrintErr;self.alert=threadAlert;Module["instantiateWasm"]=function(info,receiveInstance){var instance=new WebAssembly.Instance(Module["wasmModule"],info);receiveInstance(instance);Module["wasmModule"]=null;return instance.exports};self.onmessage=function(e){try{if(e.data.cmd==="load"){Module["wasmModule"]=e.data.wasmModule;Module["wasmMemory"]=e.data.wasmMemory;Module["buffer"]=Module["wasmMemory"].buffer;Module["ENVIRONMENT_IS_PTHREAD"]=true;if(typeof e.data.urlOrBlob==="string"){importScripts(e.data.urlOrBlob)}else{var objectUrl=URL.createObjectURL(e.data.urlOrBlob);importScripts(objectUrl);URL.revokeObjectURL(objectUrl)}JSPlayerModule(Module).then(function(instance){Module=instance})}else if(e.data.cmd==="run"){Module["__performance_now_clock_drift"]=performance.now()-e.data.time;Module["__emscripten_thread_init"](e.data.threadInfoStruct,0,0);var max=e.data.stackBase;var top=e.data.stackBase+e.data.stackSize;Module["establishStackSpace"](top,max);Module["PThread"].receiveObjectTransfer(e.data);Module["PThread"].threadInit();if(!initializedJS){Module["___embind_register_native_and_builtin_types"]();initializedJS=true}try{var result=Module["invokeEntryPoint"](e.data.start_routine,e.data.arg);if(Module["keepRuntimeAlive"]()){Module["PThread"].setExitStatus(result)}else{Module["__emscripten_thread_exit"](result)}}catch(ex){if(ex!="unwind"){if(ex instanceof Module["ExitStatus"]){if(Module["keepRuntimeAlive"]()){}else{Module["__emscripten_thread_exit"](ex.status)}}else{Module["__emscripten_thread_exit"](-2);throw ex}}}}else if(e.data.cmd==="cancel"){if(Module["_pthread_self"]()){Module["__emscripten_thread_exit"](-1)}postMessage({"cmd":"cancelDone"})}else if(e.data.target==="setimmediate"){}else if(e.data.cmd==="processThreadQueue"){if(Module["_pthread_self"]()){Module["_emscripten_current_thread_process_queued_calls"]()}}else{err("worker.js received unknown command "+e.data.cmd);err(e.data)}}catch(ex){err("worker.js onmessage() captured an uncaught exception: "+ex);if(ex&&ex.stack)err(ex.stack);throw ex}}; |
此 diff 太大无法显示。
不能预览此文件类型
1 | +"use strict";var Module={};var initializedJS=false;function threadPrintErr(){var text=Array.prototype.slice.call(arguments).join(" ");console.error(text)}function threadAlert(){var text=Array.prototype.slice.call(arguments).join(" ");postMessage({cmd:"alert",text:text,threadId:Module["_pthread_self"]()})}var err=threadPrintErr;self.alert=threadAlert;Module["instantiateWasm"]=function(info,receiveInstance){var instance=new WebAssembly.Instance(Module["wasmModule"],info);receiveInstance(instance);Module["wasmModule"]=null;return instance.exports};self.onmessage=function(e){try{if(e.data.cmd==="load"){Module["wasmModule"]=e.data.wasmModule;Module["wasmMemory"]=e.data.wasmMemory;Module["buffer"]=Module["wasmMemory"].buffer;Module["ENVIRONMENT_IS_PTHREAD"]=true;if(typeof e.data.urlOrBlob==="string"){importScripts(e.data.urlOrBlob)}else{var objectUrl=URL.createObjectURL(e.data.urlOrBlob);importScripts(objectUrl);URL.revokeObjectURL(objectUrl)}JSPlayerModule(Module).then(function(instance){Module=instance})}else if(e.data.cmd==="run"){Module["__performance_now_clock_drift"]=performance.now()-e.data.time;Module["__emscripten_thread_init"](e.data.threadInfoStruct,0,0);var max=e.data.stackBase;var top=e.data.stackBase+e.data.stackSize;Module["establishStackSpace"](top,max);Module["PThread"].receiveObjectTransfer(e.data);Module["PThread"].threadInit();if(!initializedJS){Module["___embind_register_native_and_builtin_types"]();initializedJS=true}try{var result=Module["invokeEntryPoint"](e.data.start_routine,e.data.arg);if(Module["keepRuntimeAlive"]()){Module["PThread"].setExitStatus(result)}else{Module["__emscripten_thread_exit"](result)}}catch(ex){if(ex!="unwind"){if(ex instanceof Module["ExitStatus"]){if(Module["keepRuntimeAlive"]()){}else{Module["__emscripten_thread_exit"](ex.status)}}else{Module["__emscripten_thread_exit"](-2);throw ex}}}}else if(e.data.cmd==="cancel"){if(Module["_pthread_self"]()){Module["__emscripten_thread_exit"](-1)}postMessage({"cmd":"cancelDone"})}else if(e.data.target==="setimmediate"){}else if(e.data.cmd==="processThreadQueue"){if(Module["_pthread_self"]()){Module["_emscripten_current_thread_process_queued_calls"]()}}else{err("worker.js received unknown command "+e.data.cmd);err(e.data)}}catch(ex){err("worker.js onmessage() captured an uncaught exception: "+ex);if(ex&&ex.stack)err(ex.stack);throw ex}}; |
此 diff 太大无法显示。
不能预览此文件类型
此 diff 太大无法显示。
不能预览此文件类型
1 | +"use strict";var Module={};if(typeof process==="object"&&typeof process.versions==="object"&&typeof process.versions.node==="string"){var nodeWorkerThreads=require("worker_threads");var parentPort=nodeWorkerThreads.parentPort;parentPort.on("message",function(data){onmessage({data:data})});var nodeFS=require("fs");Object.assign(global,{self:global,require:require,Module:Module,location:{href:__filename},Worker:nodeWorkerThreads.Worker,importScripts:function(f){(0,eval)(nodeFS.readFileSync(f,"utf8"))},postMessage:function(msg){parentPort.postMessage(msg)},performance:global.performance||{now:function(){return Date.now()}}})}var initializedJS=false;function threadPrintErr(){var text=Array.prototype.slice.call(arguments).join(" ");console.error(text)}function threadAlert(){var text=Array.prototype.slice.call(arguments).join(" ");postMessage({cmd:"alert",text:text,threadId:Module["_pthread_self"]()})}var err=threadPrintErr;self.alert=threadAlert;Module["instantiateWasm"]=function(info,receiveInstance){var instance=new WebAssembly.Instance(Module["wasmModule"],info);receiveInstance(instance);Module["wasmModule"]=null;return instance.exports};self.onmessage=function(e){try{if(e.data.cmd==="load"){Module["wasmModule"]=e.data.wasmModule;Module["wasmMemory"]=e.data.wasmMemory;Module["buffer"]=Module["wasmMemory"].buffer;Module["ENVIRONMENT_IS_PTHREAD"]=true;if(typeof e.data.urlOrBlob==="string"){importScripts(e.data.urlOrBlob)}else{var objectUrl=URL.createObjectURL(e.data.urlOrBlob);importScripts(objectUrl);URL.revokeObjectURL(objectUrl)}JSAudioInterComModule(Module).then(function(instance){Module=instance})}else if(e.data.cmd==="run"){Module["__performance_now_clock_drift"]=performance.now()-e.data.time;Module["__emscripten_thread_init"](e.data.threadInfoStruct,0,0);var max=e.data.stackBase;var top=e.data.stackBase+e.data.stackSize;Module["establishStackSpace"](top,max);Module["PThread"].receiveObjectTransfer(e.data);Module["PThread"].threadInit();if(!initializedJS){Module["___embind_register_native_and_builtin_types"]();initializedJS=true}try{var result=Module["invokeEntryPoint"](e.data.start_routine,e.data.arg);if(Module["keepRuntimeAlive"]()){Module["PThread"].setExitStatus(result)}else{Module["__emscripten_thread_exit"](result)}}catch(ex){if(ex!="unwind"){if(ex instanceof Module["ExitStatus"]){if(Module["keepRuntimeAlive"]()){}else{Module["__emscripten_thread_exit"](ex.status)}}else{Module["__emscripten_thread_exit"](-2);throw ex}}}}else if(e.data.cmd==="cancel"){if(Module["_pthread_self"]()){Module["__emscripten_thread_exit"](-1)}postMessage({"cmd":"cancelDone"})}else if(e.data.target==="setimmediate"){}else if(e.data.cmd==="processThreadQueue"){if(Module["_pthread_self"]()){Module["_emscripten_current_thread_process_queued_calls"]()}}else{err("worker.js received unknown command "+e.data.cmd);err(e.data)}}catch(ex){err("worker.js onmessage() captured an uncaught exception: "+ex);if(ex&&ex.stack)err(ex.stack);throw ex}}; |
此 diff 太大无法显示。
不能预览此文件类型
1 | +importScripts('libSystemTransform.js'); | ||
2 | + const RECORDRTP = 0; //录制一份未经过转封装的码流原始数据,用于定位问题 | ||
3 | + let dataType = 1; | ||
4 | + | ||
5 | + // 转封装库回调函数 | ||
6 | + self.STCallBack = function (fileIndex,indexLen, data, dataLen) | ||
7 | + { | ||
8 | + //stFrameInfo的类型见DETAIL_FRAME_INFO | ||
9 | + let stFrameInfo = Module._GetDetialFrameInfo(); | ||
10 | + let nIsMp4Index = stFrameInfo.nIsMp4Index; | ||
11 | + //console.log("FrameType is " , stFrameInfo); | ||
12 | + //console.log("nIsMp4Index is " + nIsMp4Index); | ||
13 | + //debugger | ||
14 | + var pData = null; | ||
15 | + pData = new Uint8Array(dataLen); | ||
16 | + pData.set(Module.HEAPU8.subarray(data, data + dataLen)); | ||
17 | + if (dataType === 1) { | ||
18 | + if (pData[0] == 0x49 && pData[1] == 0x4d && pData[2] == 0x4b && pData[3] == 0x48) {//码流头丢掉 | ||
19 | + return; | ||
20 | + } | ||
21 | + postMessage({type: "outputData", buf: pData, dType: 1}); | ||
22 | + dataType = 2; | ||
23 | + } else { | ||
24 | + if (nIsMp4Index) { | ||
25 | + postMessage({type: "outputData", buf: pData, dType: 6}); //6:索引类型 | ||
26 | + } else { | ||
27 | + postMessage({type: "outputData", buf: pData, dType: 2}); //2:码流 | ||
28 | + } | ||
29 | + } | ||
30 | + | ||
31 | + //stFrameInfo的类型见DETAIL_FRAME_INFO | ||
32 | + //let stFrameInfo = Module._GetDetialFrameInfo(); | ||
33 | + //let stFrameType = stFrameInfo.nFrameType; | ||
34 | + //let nFrameNum = stFrameInfo.nFrameNum; | ||
35 | + //let nTimeStamp = stFrameInfo.nTimeStamp; | ||
36 | + //let nIsMp4Index = stFrameInfo.nIsMp4Index; | ||
37 | + | ||
38 | + //console.log("FrameType is " + stFrameType); | ||
39 | + //console.log("nIsMp4Index is " + nIsMp4Index); | ||
40 | + | ||
41 | + } | ||
42 | + | ||
43 | + // self.Module = { memoryInitializerRequest: loadMemInitFile(), TOTAL_MEMORY: 128*1024*1024 }; | ||
44 | + // importScripts('SystemTransform.js'); | ||
45 | + | ||
46 | + self.Module['onRuntimeInitialized'] = function (){ | ||
47 | + postMessage({type: "loaded"}); | ||
48 | + } | ||
49 | + onmessage = function (e) { | ||
50 | + var data = e.data; | ||
51 | + if ("create" === data.type) { | ||
52 | + if (RECORDRTP) { | ||
53 | + postMessage({type: "created"}); | ||
54 | + postMessage({type: "outputData", buf: data.buf, dType: 1}); | ||
55 | + } else { | ||
56 | + var iHeadLen = data.len; | ||
57 | + var pHead = Module._malloc(iHeadLen); | ||
58 | + | ||
59 | + self.writeArrayToMemory(new Uint8Array(data.buf), pHead); | ||
60 | + var iTransType = data.packType;//目标格式 | ||
61 | + var iRet = Module._CreatHandle(pHead, iTransType, 4096); | ||
62 | + if (iRet != 0) { | ||
63 | + console.log("_CreatHandle failed!" + iRet); | ||
64 | + } else { | ||
65 | + iRet = Module._SysTransRegisterDataCallBack(); | ||
66 | + if(iRet != 0) | ||
67 | + { | ||
68 | + console.log("_SysTransRegisterDataCallBack Failed:" + iRet); | ||
69 | + } | ||
70 | + | ||
71 | + iRet = Module._SysTransStart(null, null); | ||
72 | + if(iRet != 0) | ||
73 | + { | ||
74 | + console.log("_SysTransStart Failed:" + iRet); | ||
75 | + } | ||
76 | + postMessage({type: "created"}); | ||
77 | + } | ||
78 | + } | ||
79 | + | ||
80 | + } else if ("inputData" === data.type) { | ||
81 | + if (RECORDRTP) { | ||
82 | + var aFileData = new Uint8Array(data.buf); // 拷贝一份 | ||
83 | + var iBufferLen = aFileData.length; | ||
84 | + var szBufferLen = iBufferLen.toString(16); | ||
85 | + if (szBufferLen.length === 1) { | ||
86 | + szBufferLen = "000" + szBufferLen; | ||
87 | + } else if (szBufferLen.length === 2) { | ||
88 | + szBufferLen = "00" + szBufferLen; | ||
89 | + } else if (szBufferLen.length === 3) { | ||
90 | + szBufferLen = "0" + szBufferLen; | ||
91 | + } | ||
92 | + var aData = [0, 0, parseInt(szBufferLen.substring(0, 2), 16), parseInt(szBufferLen.substring(2, 4), 16)]; | ||
93 | + for(var iIndex = 0, iDataLength = aFileData.length; iIndex < iDataLength; iIndex++) { | ||
94 | + aData[iIndex + 4] = aFileData[iIndex] | ||
95 | + } | ||
96 | + var dataUint8 = new Uint8Array(aData); | ||
97 | + postMessage({type: "outputData", buf: dataUint8.buffer, dType: 2}); | ||
98 | + } else { | ||
99 | + let pInputDataBuf = Module._malloc(data.len); | ||
100 | + var idataLen = data.len; | ||
101 | + self.writeArrayToMemory(new Uint8Array(data.buf), pInputDataBuf); | ||
102 | + // 输入数据,每次最多2m | ||
103 | + let pp = Module._SysTransInputData(0, pInputDataBuf, idataLen); | ||
104 | + if(pp != 0) { | ||
105 | + //console.log("InputData Failed:" + pp); | ||
106 | + } | ||
107 | + Module._free(pInputDataBuf); | ||
108 | + } | ||
109 | + } else if ("release" === data.type) { | ||
110 | + var iRet = Module._SysTransStop(); | ||
111 | + if (iRet != 0) { | ||
112 | + console.log("_SysTransStop Failed:", iRet); | ||
113 | + } | ||
114 | + Module._SysTransRelease(); | ||
115 | + if (iRet != 0) { | ||
116 | + console.log("_SysTransRelease Failed:", iRet); | ||
117 | + } | ||
118 | + close(); | ||
119 | + } | ||
120 | + }; |
-
请 注册 或 登录 后发表评论