1、调整图门web sdk版本
This commit is contained in:
parent
a02392e3b6
commit
5d2efa1512
|
|
@ -28,5 +28,6 @@
|
||||||
</div>
|
</div>
|
||||||
<script type="module" src="/src/main.ts"></script>
|
<script type="module" src="/src/main.ts"></script>
|
||||||
<script src="<%= basePublicPath %>/static/tums-player/tums-player.umd.min.js"></script>
|
<script src="<%= basePublicPath %>/static/tums-player/tums-player.umd.min.js"></script>
|
||||||
|
<script src="<%= basePublicPath %>/static/tums-player/hd_plugin_control_1.0.4.min.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -21,16 +21,19 @@ var Module = {};
|
||||||
postMessage({ hasInstalled: true });
|
postMessage({ hasInstalled: true });
|
||||||
|
|
||||||
const initVideoDecoder = () => {
|
const initVideoDecoder = () => {
|
||||||
|
if (videoDecoder && videoDecoder.state === 'configured') {
|
||||||
|
videoDecoder.close();
|
||||||
|
}
|
||||||
videoDecoder = new VideoDecoder({
|
videoDecoder = new VideoDecoder({
|
||||||
output: async (frame) => {
|
output: async (frame) => {
|
||||||
let { timestamp, format, codedWidth, codedHeight } = frame;
|
let { timestamp, format, codedWidth, codedHeight } = frame;
|
||||||
let param = dataParams[timestamp] || {};
|
let param = dataParams[timestamp] || {};
|
||||||
postMessage({ data: frame, width: codedWidth, height: codedHeight, timestamp, seq: param.seq, format }, [frame]);
|
postMessage({ data: frame, type: 'webcodecs', width: codedWidth, height: codedHeight, timestamp, seq: param.seq, pts: param.pts, format }, [frame]);
|
||||||
frame.close();
|
frame.close();
|
||||||
delete dataParams[timestamp];
|
delete dataParams[timestamp];
|
||||||
},
|
},
|
||||||
error: (err) => {
|
error: (err) => {
|
||||||
console.log('video decoder error: ', err);
|
console.log('video decoder error: ', err, videoDecoder.state);
|
||||||
postMessage({ decodeError: err, state: videoDecoder.state });
|
postMessage({ decodeError: err, state: videoDecoder.state });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -42,7 +45,7 @@ const initWasmDecoder = (scripts = [], wasmBinary) => {
|
||||||
self.importScripts(...scripts);
|
self.importScripts(...scripts);
|
||||||
|
|
||||||
Module.onRuntimeInitialized = function () {
|
Module.onRuntimeInitialized = function () {
|
||||||
Module._hevc_decoder_init();
|
Module._decoder_init();
|
||||||
this.bufferLen = 2304 * 1296 * 8;
|
this.bufferLen = 2304 * 1296 * 8;
|
||||||
inputBuffer = Module._malloc(this.bufferLen);
|
inputBuffer = Module._malloc(this.bufferLen);
|
||||||
outputBuffer = Module._malloc(this.bufferLen);
|
outputBuffer = Module._malloc(this.bufferLen);
|
||||||
|
|
@ -86,7 +89,7 @@ this.onmessage = async function (event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
let chunk = new Uint8Array(event.data.data);
|
let chunk = new Uint8Array(event.data.data);
|
||||||
let { code_type, pts, timestamp, seq, type } = event.data;
|
let { code_type, timestamp, seq, type, pts } = event.data;
|
||||||
|
|
||||||
if (decoderType === 'webcodecs') {
|
if (decoderType === 'webcodecs') {
|
||||||
if (videoDecoder.state === 'unconfigured' || videoDecoder.state === 'closed') return;
|
if (videoDecoder.state === 'unconfigured' || videoDecoder.state === 'closed') return;
|
||||||
|
|
@ -97,27 +100,33 @@ this.onmessage = async function (event) {
|
||||||
data: chunk
|
data: chunk
|
||||||
});
|
});
|
||||||
videoDecoder.decode(encodedVideoChunk);
|
videoDecoder.decode(encodedVideoChunk);
|
||||||
dataParams[timestamp] = { timestamp, seq, type };
|
dataParams[timestamp] = { timestamp, seq, type, pts };
|
||||||
} else {
|
} else {
|
||||||
Module.HEAP8.set(chunk, inputBuffer);
|
Module.HEAP8.set(chunk, inputBuffer);
|
||||||
if (seq) {
|
if (seq) {
|
||||||
dataSeq = seq;
|
dataSeq = seq;
|
||||||
}
|
}
|
||||||
|
|
||||||
let len = Module._hevc_to_yuv(code_type, inputBuffer, chunk.length, outputBuffer, width, height);
|
let len = Module._decoder_to_yuv(code_type, inputBuffer, chunk.length, outputBuffer, width, height);
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
let data1 = Module.HEAPU8.subarray(width, width + 4);
|
let data1 = Module.HEAPU8.subarray(width, width + 4);
|
||||||
let result_width = data1[0] + data1[1] * 256;
|
let result_width = data1[0] + data1[1] * 256;
|
||||||
let data2 = Module.HEAPU8.subarray(height, height + 4);
|
let data2 = Module.HEAPU8.subarray(height, height + 4);
|
||||||
let result_height = data2[0] + data2[1] * 256;
|
let result_height = data2[0] + data2[1] * 256;
|
||||||
|
|
||||||
let outArray = Module.HEAPU8.subarray(outputBuffer, outputBuffer + len);
|
try {
|
||||||
let outputData = new Uint8Array(outArray);
|
let outArray = Module.HEAPU8.subarray(outputBuffer, outputBuffer + len);
|
||||||
if (dataSeq) {
|
let outputData = new Uint8Array(outArray);
|
||||||
seq = dataSeq;
|
if (dataSeq) {
|
||||||
dataSeq = 0;
|
seq = dataSeq;
|
||||||
|
dataSeq = 0;
|
||||||
|
}
|
||||||
|
postMessage({ data: outputData, type: 'wasm', pts: pts, width: result_width, height: result_height, timestamp, seq }, [outputData.buffer]);
|
||||||
|
} catch (error) {
|
||||||
|
postMessage({ wasm_error: 1 });
|
||||||
}
|
}
|
||||||
postMessage({ data: outputData, pts: pts, width: result_width, height: result_height, timestamp, seq }, [outputData.buffer]);
|
} else if (len < 0) {
|
||||||
|
postMessage({ wasm_error: len});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (cmd === 'close') {
|
} else if (cmd === 'close') {
|
||||||
|
|
@ -125,5 +134,7 @@ this.onmessage = async function (event) {
|
||||||
videoDecoder.close();
|
videoDecoder.close();
|
||||||
}
|
}
|
||||||
close();
|
close();
|
||||||
|
} else if (cmd === 'flush') {
|
||||||
|
postMessage({ flushed: true });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
|
|
@ -14,11 +14,24 @@ let finalOutputBuffer;
|
||||||
let has_init = 0;
|
let has_init = 0;
|
||||||
let isG726 = true;
|
let isG726 = true;
|
||||||
var Module = {};
|
var Module = {};
|
||||||
|
let audioDeviceDataBuffer;
|
||||||
|
let sendDeviceBuffer;
|
||||||
|
let has_audio_init = 0;
|
||||||
|
let lastAACSampleRate = 0;
|
||||||
|
let has_post_audio_process_init = 0;
|
||||||
|
let lastAudioDecodeSampleRate = 0;
|
||||||
|
|
||||||
postMessage({ hasInstalled: true });
|
postMessage({ hasInstalled: true });
|
||||||
|
|
||||||
this.onmessage = function (event) {
|
this.onmessage = function (event) {
|
||||||
let { cmd } = event.data;
|
let { cmd } = event.data;
|
||||||
|
let { isStop, decoderType } = event.data;
|
||||||
|
if (isStop) {
|
||||||
|
if (has_post_audio_process_init || has_audio_init) {
|
||||||
|
Module._tp_audio_deinit();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (cmd === 'init') {
|
if (cmd === 'init') {
|
||||||
let { scripts, wasmBinary } = event.data;
|
let { scripts, wasmBinary } = event.data;
|
||||||
Module.wasmBinary = wasmBinary;
|
Module.wasmBinary = wasmBinary;
|
||||||
|
|
@ -28,15 +41,41 @@ this.onmessage = function (event) {
|
||||||
if (!Module['asm']) return;
|
if (!Module['asm']) return;
|
||||||
|
|
||||||
if (!has_init) {
|
if (!has_init) {
|
||||||
Module._tp_ns2_init(event.data.samplerate || 8000);
|
|
||||||
has_init = 1;
|
has_init = 1;
|
||||||
inputBuffer = Module._malloc(1024 * 2);
|
audioDeviceDataBuffer = Module._malloc(1024 * 2);
|
||||||
outputBuffer = Module._malloc(1024 * 2);
|
inputBuffer = Module._malloc(1024 * 4);
|
||||||
finalOutputBuffer = Module._malloc(1024 * 2);
|
outputBuffer = Module._malloc(1024 * 4);
|
||||||
|
finalOutputBuffer = Module._malloc(1024 * 4);
|
||||||
postMessage({ hasInit: true });
|
postMessage({ hasInit: true });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let { dts, pts, timestamp, seq, type, samplerate, bitCount, decoderType } = event.data;
|
if (cmd === 'flush') {
|
||||||
|
postMessage({ flushed: true });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let { dts, pts, timestamp, seq, type, samplerate, bitCount, mode } = event.data;
|
||||||
|
if (decoderType !== '_decodePCM') {
|
||||||
|
let newSampleRate = samplerate || 8000;
|
||||||
|
if (lastAudioDecodeSampleRate != newSampleRate) {
|
||||||
|
if (has_post_audio_process_init) {
|
||||||
|
Module._tp_audio_deinit();
|
||||||
|
}
|
||||||
|
has_post_audio_process_init = 1;
|
||||||
|
// _tp_audio_init(sample_rate,
|
||||||
|
// ns_enable, ns_mode, ns_intensity, ns_threshold, ns_twice_process_enable, ns_gain,
|
||||||
|
// echo_intensity, aec_gain,
|
||||||
|
// tp_ao_agc_enable, ao_target_level, ao_none_motor_compression_gain)
|
||||||
|
let initRet = Module._tp_audio_init(newSampleRate,
|
||||||
|
1, 1, 10, 30000, 0, 1,
|
||||||
|
4, 1,
|
||||||
|
0, -1, 12);
|
||||||
|
if (initRet !== 0) {
|
||||||
|
has_post_audio_process_init = 0;
|
||||||
|
Module._tp_audio_deinit();
|
||||||
|
}
|
||||||
|
lastAudioDecodeSampleRate = newSampleRate;
|
||||||
|
}
|
||||||
|
}
|
||||||
let param = {
|
let param = {
|
||||||
pts: pts,
|
pts: pts,
|
||||||
dts: dts,
|
dts: dts,
|
||||||
|
|
@ -57,8 +96,12 @@ this.onmessage = function (event) {
|
||||||
chunk_num = Module._decodeG726(0, inputBuffer, chunk.length, outputBuffer);
|
chunk_num = Module._decodeG726(0, inputBuffer, chunk.length, outputBuffer);
|
||||||
if (chunk_num === 1) {
|
if (chunk_num === 1) {
|
||||||
let getLength = ((chunk.length << 4) / bitCount) >>> 1;
|
let getLength = ((chunk.length << 4) / bitCount) >>> 1;
|
||||||
Module._tp_ns2_process(outputBuffer, getLength, finalOutputBuffer);
|
let procRet = -1;
|
||||||
let finalOutArray = Module.HEAP16.subarray(finalOutputBuffer >> 1, (finalOutputBuffer + getLength * 2) >> 1);
|
if (has_post_audio_process_init) {
|
||||||
|
procRet = Module._tp_audio_process(outputBuffer, null, inputBuffer, getLength * 2);
|
||||||
|
}
|
||||||
|
let resultPCM = procRet !== 0 ? outputBuffer : inputBuffer;
|
||||||
|
let finalOutArray = Module.HEAP16.subarray(resultPCM >> 1, (resultPCM + getLength * 2) >> 1);
|
||||||
finalOutArray = new Int16Array(finalOutArray);
|
finalOutArray = new Int16Array(finalOutArray);
|
||||||
postMessage({
|
postMessage({
|
||||||
data: finalOutArray.buffer,
|
data: finalOutArray.buffer,
|
||||||
|
|
@ -66,22 +109,61 @@ this.onmessage = function (event) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if (decoderType === '_decodeAAC') {
|
} else if (decoderType === '_decodeAAC') {
|
||||||
|
if (lastAACSampleRate <= 0) {
|
||||||
|
lastAACSampleRate = samplerate;
|
||||||
|
}
|
||||||
|
if (lastAACSampleRate != samplerate) {
|
||||||
|
Module._destroy_AAC_decoder();
|
||||||
|
}
|
||||||
|
lastAACSampleRate = samplerate;
|
||||||
var pcmLen = Module._decodeAAC(outputBuffer, inputBuffer, chunk.length);
|
var pcmLen = Module._decodeAAC(outputBuffer, inputBuffer, chunk.length);
|
||||||
|
|
||||||
if (pcmLen >= 0) {
|
if (pcmLen >= 0) {
|
||||||
Module._tp_ns2_process(outputBuffer, pcmLen, finalOutputBuffer);
|
let procRet = -1;
|
||||||
let finalOutArray = Module.HEAP16.subarray(finalOutputBuffer >> 1, (finalOutputBuffer + pcmLen * 2) >> 1);
|
if (has_post_audio_process_init) {
|
||||||
|
procRet = Module._tp_audio_process(outputBuffer, null, inputBuffer, pcmLen * 2);
|
||||||
|
}
|
||||||
|
let resultPCM = procRet !== 0 ? outputBuffer : inputBuffer;
|
||||||
|
let finalOutArray = Module.HEAP16.subarray(resultPCM >> 1, (resultPCM + pcmLen * 2) >> 1);
|
||||||
finalOutArray = new Int16Array(finalOutArray);
|
finalOutArray = new Int16Array(finalOutArray);
|
||||||
postMessage({
|
postMessage({
|
||||||
data: finalOutArray.buffer,
|
data: finalOutArray.buffer,
|
||||||
...param
|
...param
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
} else if (decoderType === '_decodePCM') {
|
||||||
|
if (!has_audio_init) {
|
||||||
|
has_audio_init = 1;
|
||||||
|
// _tp_audio_init(sample_rate,
|
||||||
|
// ns_enable, ns_mode, ns_intensity, ns_threshold, ns_twice_process_enable, ns_gain,
|
||||||
|
// echo_intensity, aec_gain,
|
||||||
|
// tp_ao_agc_enable, ao_target_level, ao_none_motor_compression_gain)
|
||||||
|
Module._tp_audio_init(samplerate || 8000,
|
||||||
|
1, 1, 35, 30000, 0, 1,
|
||||||
|
4, 1,
|
||||||
|
0, -1, 12);
|
||||||
|
}
|
||||||
|
Module._tp_audio_process(inputBuffer, null, outputBuffer, chunk.length, 0);
|
||||||
|
chunk_num = Module._encodeG711a(inputBuffer, outputBuffer, chunk.length / 2);
|
||||||
|
if (chunk_num === 1) {
|
||||||
|
// 播放数据
|
||||||
|
let finalOutArray = Module.HEAPU8.subarray(inputBuffer, inputBuffer + chunk.length / 2);
|
||||||
|
finalOutArray = new Uint8Array(finalOutArray);
|
||||||
|
postMessage({
|
||||||
|
data: finalOutArray.buffer,
|
||||||
|
...param
|
||||||
|
});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
chunk_num = Module[decoderType](outputBuffer, inputBuffer, chunk.length);
|
chunk_num = Module[decoderType](outputBuffer, inputBuffer, chunk.length);
|
||||||
if (chunk_num === 1) {
|
if (chunk_num === 1) {
|
||||||
Module._tp_ns2_process(outputBuffer, chunk.length, finalOutputBuffer);
|
let procRet = -1;
|
||||||
let finalOutArray = Module.HEAP16.subarray(finalOutputBuffer >> 1, (finalOutputBuffer + chunk.length * 2) >> 1);
|
if (has_post_audio_process_init) {
|
||||||
|
procRet = Module._tp_audio_process(outputBuffer, null, inputBuffer, chunk.length * 2);
|
||||||
|
}
|
||||||
|
let resultPCM = procRet !== 0 ? outputBuffer : inputBuffer;
|
||||||
|
// 播放数据
|
||||||
|
let finalOutArray = Module.HEAP16.subarray(resultPCM >> 1, (resultPCM + chunk.length * 2) >> 1);
|
||||||
finalOutArray = new Int16Array(finalOutArray);
|
finalOutArray = new Int16Array(finalOutArray);
|
||||||
postMessage({
|
postMessage({
|
||||||
data: finalOutArray.buffer,
|
data: finalOutArray.buffer,
|
||||||
|
|
@ -89,4 +171,4 @@ this.onmessage = function (event) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -2,7 +2,6 @@ postMessage({ hasInstalled: true });
|
||||||
|
|
||||||
let offscreenCanvas;
|
let offscreenCanvas;
|
||||||
let webgl;
|
let webgl;
|
||||||
let decoderType;
|
|
||||||
|
|
||||||
this.onmessage = (event) => {
|
this.onmessage = (event) => {
|
||||||
const { data } = event;
|
const { data } = event;
|
||||||
|
|
@ -16,22 +15,35 @@ this.onmessage = (event) => {
|
||||||
|
|
||||||
offscreenCanvas = canvas;
|
offscreenCanvas = canvas;
|
||||||
webgl = new WebGL(canvas, options);
|
webgl = new WebGL(canvas, options);
|
||||||
decoderType = options.decoderType;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmd === 'render') {
|
if (cmd === 'render') {
|
||||||
const { frame, width, height, yLength, uvLength } = data;
|
const { frame, type, width, height, yLength, uvLength } = data;
|
||||||
|
|
||||||
offscreenCanvas.width = width;
|
offscreenCanvas.width = width;
|
||||||
offscreenCanvas.height = height;
|
offscreenCanvas.height = height;
|
||||||
|
|
||||||
if (decoderType === 'webcodecs') {
|
let error;
|
||||||
webgl && webgl.renderFrame(frame, width, height);
|
if (type === 'webcodecs') {
|
||||||
if (!webgl) frame.close();
|
if (webgl) {
|
||||||
|
webgl.setFrameType('VIDEO_FRAME');
|
||||||
|
error = webgl.renderFrame(frame, width, height);
|
||||||
|
} else {
|
||||||
|
frame.close();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
webgl && webgl.renderFrame(frame, width, height, yLength, uvLength);
|
if (webgl) {
|
||||||
|
webgl.setFrameType('YUV_FRAME');
|
||||||
|
error = webgl.renderFrame(frame, width, height, yLength, uvLength);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (error) {
|
||||||
|
postMessage({renderError: error});
|
||||||
|
webgl && webgl.dispose();
|
||||||
|
this.close();
|
||||||
|
}
|
||||||
|
|
||||||
} else if (cmd === 'display') {
|
} else if (cmd === 'display') {
|
||||||
const { options } = data;
|
const { options } = data;
|
||||||
webgl && webgl.setDisplayInfo(options);
|
webgl && webgl.setDisplayInfo(options);
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ async function edit(record) {
|
||||||
let endTime = item.endTime * 1000;
|
let endTime = item.endTime * 1000;
|
||||||
player.value = new TumsPlayer('video-container-playback', {
|
player.value = new TumsPlayer('video-container-playback', {
|
||||||
"autoplay": true,
|
"autoplay": true,
|
||||||
"resolution": "VB",
|
"resolution": "VGA",
|
||||||
"streamType": "sdvod", // 回放类型
|
"streamType": "sdvod", // 回放类型
|
||||||
"url": item.url, // 该url为一次性 需要通过接口实时获取
|
"url": item.url, // 该url为一次性 需要通过接口实时获取
|
||||||
"socket": item.wssUrl,
|
"socket": item.wssUrl,
|
||||||
|
|
@ -125,6 +125,7 @@ async function edit(record) {
|
||||||
"queryAddress": item.queryAddress,
|
"queryAddress": item.queryAddress,
|
||||||
"videoSessionId": item.sessionId,
|
"videoSessionId": item.sessionId,
|
||||||
"videoDevId": item.videoDevId, // 设备id
|
"videoDevId": item.videoDevId, // 设备id
|
||||||
|
"pluginPath": '/devops/static',
|
||||||
// "useMultitrans": true,
|
// "useMultitrans": true,
|
||||||
"storageDevId": item.storageDevId,
|
"storageDevId": item.storageDevId,
|
||||||
"startTime": startTime, // 回放开始时间 13位
|
"startTime": startTime, // 回放开始时间 13位
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue