Browse Source

体育馆监控完成

lite
‘daijinzheng@xingtongworld.com’ 3 years ago
parent
commit
5bf73584f0
  1. 1
      public/static/1.0升级至2.0+注意事项.txt
  2. 313
      public/static/h5player.min.js
  3. 74
      public/static/jquery-1.12.4.min.js
  4. 1
      public/static/jsencrypt.min.js
  5. 225
      public/static/playctrl1/AudioRenderer.js
  6. 621
      public/static/playctrl1/DecodeWorker.js
  7. 1
      public/static/playctrl1/Decoder.js
  8. 398
      public/static/playctrl1/SuperRender_10.js
  9. 225
      public/static/playctrl1simd/AudioRenderer.js
  10. 621
      public/static/playctrl1simd/DecodeWorker.js
  11. 1
      public/static/playctrl1simd/Decoder.js
  12. 398
      public/static/playctrl1simd/SuperRender_10.js
  13. 21
      public/static/playctrl2/Decoder.js
  14. BIN
      public/static/playctrl2/Decoder.wasm
  15. 1
      public/static/playctrl2/Decoder.worker.js
  16. 21
      public/static/playctrl3/Decoder.js
  17. BIN
      public/static/playctrl3/Decoder.wasm
  18. 1
      public/static/playctrl3/Decoder.worker.js
  19. 21
      public/static/talk/AudioInterCom.js
  20. BIN
      public/static/talk/AudioInterCom.wasm
  21. 21
      public/static/talkW/AudioInterCom.js
  22. BIN
      public/static/talkW/AudioInterCom.wasm
  23. 1
      public/static/talkW/AudioInterCom.worker.js
  24. 6525
      public/static/transform/libSystemTransform.js
  25. BIN
      public/static/transform/libSystemTransform.wasm
  26. 120
      public/static/transform/systemTransform-worker.js
  27. 2
      public/static/web-control_1.2.5.min.js
  28. 313
      src/utils/h5player.min.js
  29. 280
      src/views/ty/index.vue

1
public/static/1.0升级至2.0+注意事项.txt

@ -1 +0,0 @@
1、删除Decoder.js的外部引用,由于Decoder.js加载完全在笔记本耗时较久,很容易出现还没加载时完全出现的批量报错

313
public/static/h5player.min.js

File diff suppressed because one or more lines are too long

74
public/static/jquery-1.12.4.min.js

File diff suppressed because one or more lines are too long

1
public/static/jsencrypt.min.js

File diff suppressed because one or more lines are too long

225
public/static/playctrl1/AudioRenderer.js

@ -1,225 +0,0 @@
/**
* Created by wangweijie5 on 2016/12/16.
*/
"use strict";
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var __instance = function () {
var instance = void 0;
return function (newInstance) {
if (newInstance) instance = newInstance;
return instance;
};
}();
var AudioRenderer = function () {
function AudioRenderer() {
_classCallCheck(this, AudioRenderer);
if (__instance()) return __instance();
// 确保只有单例
if (AudioRenderer.unique !== undefined) {
return AudioRenderer.unique;
}
AudioRenderer.unique = this;
this.oAudioContext = null;
this.currentVolume = 80; // 初始音量
this.bSetVolume = false;
this.gainNode = null;
this.iWndNum = -1; // 窗口号
this.mVolumes = new Map(); // 用于存储所有音量
// Init AudioContext
var AudioContext = window.AudioContext || window.webkitAudioContext;
this.oAudioContext = new AudioContext();
this.writeString = function (view, offset, string) {
for (var i = 0; i < string.length; i++) {
view.setUint8(offset + i, string.charCodeAt(i));
}
};
this.setBufferToDataview = function (output, offset, input) {
for (var i = 0; i < input.length; i++, offset++) {
output.setUint8(offset, input[i]);
}
};
__instance(this);
}
/**
* @synopsis 音频播放
*
* @param dataBuf [IN] 音频缓存
* @param dataLen [IN] 缓存长度
* @param audioInfo [IN] 音频参数
*
* @returns 状态码
*/
_createClass(AudioRenderer, [{
key: 'Play',
value: function Play(dataBuf, dataLen, audioInfo) {
var bufferData = new ArrayBuffer(44 + dataLen);
var viewTalk = new DataView(bufferData);
var sampleRates = audioInfo.samplesPerSec;
var channels = audioInfo.channels;
var bitsPerSample = audioInfo.bitsPerSample;
//console.log("audiorender sampleRates"+sampleRates+"channels:"+channels+"bitsPerSample:"+bitsPerSample);
/* RIFF identifier */
this.writeString(viewTalk, 0, 'RIFF');
/* file length */
viewTalk.setUint32(4, 32 + dataLen * 2, true);
/* RIFF type */
this.writeString(viewTalk, 8, 'WAVE');
/* format chunk identifier */
this.writeString(viewTalk, 12, 'fmt ');
/* format chunk length */
viewTalk.setUint32(16, 16, true);
/* sample format (raw) */
viewTalk.setUint16(20, 1, true);
/* channel count */
viewTalk.setUint16(22, channels, true);
/* sample rate */
viewTalk.setUint32(24, sampleRates, true);
/* byte rate (sample rate * block align) */
viewTalk.setUint32(28, sampleRates * 2, true);
/* block align (channel count * bytes per sample)/8 */
viewTalk.setUint16(32, channels * bitsPerSample / 8, true);
/* bits per sample */
viewTalk.setUint16(34, bitsPerSample, true);
/* data chunk identifier */
this.writeString(viewTalk, 36, 'data');
/* data chunk length */
viewTalk.setUint32(40, dataLen, true);
this.setBufferToDataview(viewTalk, 44, dataBuf);
var self = this;
this.oAudioContext.decodeAudioData(viewTalk.buffer, function (buffer) {
var bufferSource = self.oAudioContext.createBufferSource();
if (bufferSource == null) {
return -1;
}
bufferSource.buffer = buffer;
bufferSource.start(0);
if (self.gainNode == null || self.bSetVolume) {
self.gainNode = self.oAudioContext.createGain();
// self.gainNode.gain.value = self.currentVolume;
// // self.currentVolume = self.gainNode.gain.value;
// self.gainNode.connect(self.oAudioContext.destination);
self.bSetVolume = false;
}
self.gainNode.gain.value = self.currentVolume/100;
// self.currentVolume = self.gainNode.gain.value;
self.gainNode.connect(self.oAudioContext.destination);
bufferSource.connect(self.gainNode);
}, function (e) {
console.log("decode error");
return -1;
});
return 0;
}
/**
* @synopsis 停止播放
*
* @returns 返回音量
*/
}, {
key: 'Stop',
value: function Stop() {
if (this.gainNode != null) {
this.gainNode.disconnect();
this.gainNode = null;
}
// this.oAudioContext.close();
// AudioRenderer.unique = undefined;
// __instance() = null;
return true;
}
/**
* @synopsis 设置音量
*
* @param iVolume [IN] 音量
*
* @returns 状态码
*/
}, {
key: 'SetVolume',
value: function SetVolume(iVolume) {
this.bSetVolume = true;
this.currentVolume = iVolume;
// 储存当前窗口设置音量值
this.mVolumes.set(this.iWndNum, this.currentVolume);
return true;
}
/**
* @synopsis 设置窗口号
*
* @param iWndNum [IN] 窗口号
*
* @returns 状态码
*/
}, {
key: 'SetWndNum',
value: function SetWndNum(iWndNum) {
this.iWndNum = iWndNum;
// 获取当前窗口设置音量值
var iVolume = this.mVolumes.get(iWndNum);
if (iVolume == undefined) {
iVolume = 80; // 默认音量
}
this.currentVolume = iVolume;
return true;
}
/**
* @synopsis 获取音量
*
* @returns 返回音量
*/
}, {
key: 'GetVolume',
value: function GetVolume() {
// 获取当前窗口设置音量值
var iVolume = this.mVolumes.get(this.iWndNum);
if (iVolume == undefined) {
iVolume = 80; // 默认音量
}
return iVolume;
}
}]);
return AudioRenderer;
}();
//# sourceMappingURL=AudioRenderer.js.map

621
public/static/playctrl1/DecodeWorker.js

@ -1,621 +0,0 @@
/**
* Created by wangweijie5 on 2016/12/5.
*/
(function (event) {
const AUDIO_TYPE = 0; // 音频
const VIDEO_TYPE = 1; // 视频
const PRIVT_TYPE = 2; // 私有帧
const PLAYM4_AUDIO_FRAME = 100; // 音频帧
const PLAYM4_VIDEO_FRAME = 101; // 视频帧
const PLAYM4_OK = 1;
const PLAYM4_ORDER_ERROR = 2;
const PLAYM4_DECODE_ERROR = 44 // 解码失败
const PLAYM4_NOT_KEYFRAME = 48; // 非关键帧
const PLAYM4_NEED_MORE_DATA = 31; // 需要更多数据才能解析
const PLAYM4_NEED_NEET_LOOP = 35; //丢帧需要下个循环
const PLAYM4_SYS_NOT_SUPPORT = 16; // 不支持
importScripts('Decoder.js');
Module.addOnPostRun(function () {
postMessage({'function': "loaded"});
});
var iStreamMode = 0; // 流模式
var bOpenMode = false;
var bOpenStream = false;
var funGetFrameData = null;
var funGetAudFrameData = null;
var bWorkerPrintLog=false;//worker层log开关
var g_nPort = -1;
onmessage = function (event)
{
var eventData = event.data;
var res = 0;
switch (eventData.command)
{
case "printLog":
let downloadFlag=eventData.data;
if(downloadFlag===true)
{
bWorkerPrintLog=true;
res = Module._SetPrintLogFlag(g_nPort,downloadFlag);
}
else
{
bWorkerPrintLog=false;
res = Module._SetPrintLogFlag(g_nPort,downloadFlag);
}
if (res !== PLAYM4_OK)
{
console.log("DecodeWorker.js: PlayerSDK print log failed,res"+res);
postMessage({'function': "printLog", 'errorCode': res});
}
break;
case "SetPlayPosition":
let nFrameNumOrTime=eventData.data;
let enPosType=eventData.type;
// res = Module._SetPlayPosition(nFrameNumOrTime,enPosType);
// if (res !== PLAYM4_OK)
// {
// postMessage({'function': "SetPlayPosition", 'errorCode': res});
// return;
// }
// //有没有buffer需要清除
break;
case "SetStreamOpenMode":
//获取端口号
g_nPort = Module._GetPort();
//设置流打开模式
iStreamMode = eventData.data;
res = Module._SetStreamOpenMode(g_nPort,iStreamMode);
if (res !== PLAYM4_OK)
{
postMessage({'function': "SetStreamOpenMode", 'errorCode': res});
return;
}
bOpenMode = true;
break;
case "OpenStream":
// 接收到的数据
var iHeadLen = eventData.dataSize;
var pHead = Module._malloc(iHeadLen + 4);
if (pHead === null)
{
return;
}
var aHead = Module.HEAPU8.subarray(pHead, pHead + iHeadLen);
aHead.set(eventData.data);
res = Module._OpenStream(g_nPort,pHead, iHeadLen, eventData.bufPoolSize);
postMessage({'function': "OpenStream", 'errorCode': res});
if (res !== PLAYM4_OK)
{
//释放内存
Module._free(pHead);
pHead = null;
return;
}
bOpenStream = true;
break;
case "Play":
let resP = Module._Play(g_nPort);
if (resP !== PLAYM4_OK)
{
return;
}
break;
case "InputData":
// 接收到的数据
var iLen = eventData.dataSize;
if (iLen > 0)
{
var pInputData = Module._malloc(iLen);
if (pInputData === null)
{
return;
}
var inputData = new Uint8Array(eventData.data);
// var aInputData = Module.HEAPU8.subarray(pInputData, pInputData + iLen);
// aInputData.set(inputData);
Module.writeArrayToMemory(inputData, pInputData);
inputData = null;
res = Module._InputData(g_nPort,pInputData, iLen);
if (res !== PLAYM4_OK)
{
let errorCode = Module._GetLastError(g_nPort);
let sourceRemain = Module._GetSourceBufferRemain(g_nPort);
postMessage({'function': "InputData", 'errorCode': errorCode,"sourceRemain":sourceRemain});
}
Module._free(pInputData);
pInputData = null;
}else{
let sourceRemain = Module._GetSourceBufferRemain(g_nPort);
if(sourceRemain == 0)
{
console.log("C buffer and JS buffer size is both 0");
postMessage({'function': "InputData", 'errorCode':PLAYM4_NEED_MORE_DATA});
return;
}
}
/////////////////////
if (funGetFrameData === null)
{
funGetFrameData = Module.cwrap('GetFrameData', 'number');
}
while (bOpenMode && bOpenStream)
{
var ret = getFrameData(funGetFrameData);
// 直到获取视频帧或数据不足为止
if (PLAYM4_VIDEO_FRAME === ret ||PLAYM4_NEED_MORE_DATA === ret || PLAYM4_ORDER_ERROR === ret || PLAYM4_NEED_NEET_LOOP ===ret)//PLAYM4_VIDEO_FRAME === ret ||
{
break;
}
}
break;
case "SetSecretKey":
var keyLen = eventData.nKeyLen;
var pKeyData = Module._malloc(keyLen);
if (pKeyData === null) {
return;
}
var nKeySize = eventData.data.length
var bufData = stringToBytes (eventData.data);
var aKeyData = Module.HEAPU8.subarray(pKeyData, pKeyData + keyLen);
aKeyData.set(new Uint8Array(bufData));
res = Module._SetSecretKey(g_nPort,eventData.nKeyType, pKeyData, keyLen);//, nKeySize
if (res !== PLAYM4_OK) {
postMessage({'function': "SetSecretKey", 'errorCode': res});
Module._free(pKeyData);
pKeyData = null;
return;
}
Module._free(pKeyData);
pKeyData = null;
break;
case "GetBMP":
var nBMPWidth = eventData.width;
var nBMPHeight = eventData.height;
var pYUVData = eventData.data;
var nYUVSize = nBMPWidth * nBMPHeight * 3 / 2;
var oBMPCropRect = eventData.rect;
var pDataYUV = Module._malloc(nYUVSize);
if (pDataYUV === null) {
return;
}
Module.writeArrayToMemory(new Uint8Array(pYUVData, 0, nYUVSize), pDataYUV);
// 分配BMP空间
var nBmpSize = nBMPWidth * nBMPHeight * 4 + 60;
var pBmpData = Module._malloc(nBmpSize);
var pBmpSize = Module._malloc(4);
if (pBmpData === null || pBmpSize === null) {
Module._free(pDataYUV);
pDataYUV = null;
if (pBmpData != null) {
Module._free(pBmpData);
pBmpData = null;
}
if (pBmpSize != null) {
Module._free(pBmpSize);
pBmpSize = null;
}
return;
}
//Module._memset(pBmpSize, nBmpSize, 4); // 防止bmp截图出现输入数据过大的错误码
Module.setValue(pBmpSize, nBmpSize, "i32");
res = Module._GetBMP(g_nPort,pDataYUV, nYUVSize, pBmpData, pBmpSize,
oBMPCropRect.left, oBMPCropRect.top, oBMPCropRect.right, oBMPCropRect.bottom);
if (res !== PLAYM4_OK) {
postMessage({'function': "GetBMP", 'errorCode': res});
Module._free(pDataYUV);
pDataYUV = null;
Module._free(pBmpData);
pBmpData = null;
Module._free(pBmpSize);
pBmpSize = null;
return;
}
// 获取BMP图片大小
var nBmpDataSize = Module.getValue(pBmpSize, "i32");
// 获取BMP图片数据
var aBmpData = new Uint8Array(nBmpDataSize);
aBmpData.set(Module.HEAPU8.subarray(pBmpData, pBmpData + nBmpDataSize));
postMessage({'function': "GetBMP", 'data': aBmpData, 'errorCode': res}, [aBmpData.buffer]);
aBmpData=null;
if (pDataYUV != null) {
Module._free(pDataYUV);
pDataYUV = null;
}
if (pBmpData != null) {
Module._free(pBmpData);
pBmpData = null;
}
if (pBmpSize != null) {
Module._free(pBmpSize);
pBmpSize = null;
}
break;
case "GetJPEG":
var nJpegWidth = eventData.width;
var nJpegHeight = eventData.height;
var pYUVData1 = eventData.data;
var nYUVSize1 = nJpegWidth * nJpegHeight * 3 / 2;
var oJpegCropRect = eventData.rect;
var pDataYUV1 = Module._malloc(nYUVSize1);
if (pDataYUV1 === null) {
return;
}
Module.writeArrayToMemory(new Uint8Array(pYUVData1, 0, nYUVSize1), pDataYUV1);
// 分配JPEG空间
var pJpegData = Module._malloc(nYUVSize1);
var pJpegSize = Module._malloc(4);
if (pJpegData === null || pJpegSize === null) {
if (pJpegData != null) {
Module._free(pJpegData);
pJpegData = null;
}
if (pJpegSize != null) {
Module._free(pJpegSize);
pJpegSize = null;
}
if (pDataYUV1 != null) {
Module._free(pDataYUV1);
pDataYUV1 = null;
}
return;
}
Module.setValue(pJpegSize, nJpegWidth * nJpegHeight * 2, "i32"); // JPEG抓图,输入缓冲长度不小于当前帧YUV大小
res = Module._GetJPEG(g_nPort,pDataYUV1, nYUVSize1, pJpegData, pJpegSize,
oJpegCropRect.left, oJpegCropRect.top, oJpegCropRect.right, oJpegCropRect.bottom);
if (res !== PLAYM4_OK) {
postMessage({'function': "GetJPEG", 'errorCode': res});
if (pJpegData != null) {
Module._free(pJpegData);
pJpegData = null;
}
if (pJpegSize != null) {
Module._free(pJpegSize);
pJpegSize = null;
}
if (pDataYUV1 != null) {
Module._free(pDataYUV1);
pDataYUV1 = null;
}
return;
}
// 获取JPEG图片大小
var nJpegSize = Module.getValue(pJpegSize, "i32");
// 获取JPEG图片数据
var aJpegData = new Uint8Array(nJpegSize);
aJpegData.set(Module.HEAPU8.subarray(pJpegData, pJpegData + nJpegSize));
postMessage({'function': "GetJPEG", 'data': aJpegData, 'errorCode': res}, [aJpegData.buffer]);
nJpegSize = null;
aJpegData = null;
if (pDataYUV1 != null) {
Module._free(pDataYUV1);
pDataYUV1 = null;
}
if (pJpegData != null) {
Module._free(pJpegData);
pJpegData = null;
}
if (pJpegSize != null) {
Module._free(pJpegSize);
pJpegSize = null;
}
break;
case "SetDecodeFrameType":
var nFrameType = eventData.data;
res = Module._SetDecodeFrameType(g_nPort,nFrameType);
if (res !== PLAYM4_OK) {
postMessage({'function': "SetDecodeFrameType", 'errorCode': res});
return;
}
break;
case "CloseStream":
//stop
let resS = Module._Stop(g_nPort);
if (resS !== PLAYM4_OK) {
postMessage({'function': "Stop", 'errorCode': res});
return;
}
//closeStream
res = Module._CloseStream(g_nPort);
if (res !== PLAYM4_OK) {
postMessage({'function': "CloseStream", 'errorCode': res});
return;
}
//freePort
let resF = Module._FreePort(g_nPort);
if (resF !== PLAYM4_OK) {
postMessage({'function': "FreePort", 'errorCode': res});
return;
}
break;
case "PlaySound":
let resPS = Module._PlaySound(g_nPort);
if (resPS !== PLAYM4_OK) {
console.log("PlaySound failed");
return;
}
break;
case "StopSound":
let resSS = Module._StopSound();
if (resSS !== PLAYM4_OK) {
console.log("StopSound failed");
return;
}
break;
case "SetVolume":
let resSV = Module._SetVolume(g_nPort,eventData.volume);
if (resSV !== PLAYM4_OK) {
console.log("Audio SetVolume failed");
return;
}
break;
case "GetVolume":
let volume = Module._GetVolume();
if(volume>0)
{
postMessage({'function': "GetVolume", 'volume': volume});
}
else{
console.log("Audio GetVolume failed");
return;
}
break;
case "OnlyPlaySound":
let resOPS = Module._OnlyPlaySound(g_nPort);
if (resOPS !== PLAYM4_OK) {
console.log("OnlyPlaySound failed");
return;
}
break;
case "Pause" :
let resPa = Module._Pause(g_nPort,eventData.bPlay);
if (resPa !== PLAYM4_OK) {
console.log("Pause failed");
return;
}
case "PlayRate":
Module._SetPlayRate(g_nPort,eventData.playRate);
break;
case "SetIFrameDecInterval":
Module._SetIFrameDecInterval(g_nPort,eventData.data);
break;
case "SetLostFrameMode":
Module._SetLostFrameMode(g_nPort,eventData.data);
break;
case "SetDemuxModel":
Module._SetDemuxModel(g_nPort,eventData.nIdemuxType,eventData.bTrue);
break;
case "SkipErrorData":
Module._SkipErrorData(g_nPort,eventData.bSkip);
break;
case "SetDecodeERC":
Module._SetDecodeERC(g_nPort,eventData.nLevel);
break;
case "SetANRParam":
Module._SetANRParam(g_nPort,eventData.nEnable,eventData.nANRLevel);
break;
case "SetResampleValue":
Module._SetResampleValue(g_nPort,eventData.nEnable,eventData.resampleValue);
break;
case "GetLastError":
let errorCode = Module._GetLastError(g_nPort);
postMessage({'function': "GetLastError", 'errorCode': errorCode});
break;
case "SetGlobalBaseTime":
Module._SetGlobalBaseTime(g_nPort,eventData.year,eventData.month,eventData.day,eventData.hour,eventData.min,eventData.sec,eventData.ms);
break;
default:
break;
}
};
function getOSDTime(oFrameInfo) {
var iYear = oFrameInfo.year;
var iMonth = oFrameInfo.month;
var iDay = oFrameInfo.day;
var iHour = oFrameInfo.hour;
var iMinute = oFrameInfo.minute;
var iSecond = oFrameInfo.second;
if (iMonth < 10) {
iMonth = "0" + iMonth;
}
if (iDay < 10) {
iDay = "0" + iDay;
}
if (iHour < 10) {
iHour = "0" + iHour;
}
if (iMinute < 10) {
iMinute = "0" + iMinute;
}
if (iSecond < 10) {
iSecond = "0" + iSecond;
}
return iYear + "-" + iMonth + "-" + iDay + " " + iHour + ":" + iMinute + ":" + iSecond;
}
// 获取帧数据
function getFrameData(fun)
{
// function getFrameData() {
// 获取帧数据
// var res = Module._GetFrameData();
var res = fun();
if (res === PLAYM4_OK)
{
var oFrameInfo = Module._GetFrameInfo();
switch (oFrameInfo.frameType)
{
case AUDIO_TYPE:
var iSize = oFrameInfo.frameSize;
if (0 === iSize)
{
return -1;
}
var pPCM = Module._GetFrameBuffer();
// var audioBuf = new ArrayBuffer(iSize);
var aPCMData = new Uint8Array(iSize);
aPCMData.set(Module.HEAPU8.subarray(pPCM, pPCM + iSize));
if(bWorkerPrintLog)
{
console.log("<<<Worker: audio media Info: nSise:"+ oFrameInfo.frameSize+",nSampleRate:"+oFrameInfo.samplesPerSec+',channel:'+oFrameInfo.channels+',bitsPerSample:'+oFrameInfo.bitsPerSample);
}
postMessage({
'function': "GetFrameData", 'type': "audioType", 'data': aPCMData.buffer,
'frameInfo': oFrameInfo, 'errorCode': res
}, [aPCMData.buffer]);
oFrameInfo = null;
pPCM = null;
aPCMData = null;
return PLAYM4_AUDIO_FRAME;
case VIDEO_TYPE:
var szOSDTime = getOSDTime(oFrameInfo);
var iWidth = oFrameInfo.width;
var iHeight = oFrameInfo.height;
var iYUVSize = iWidth * iHeight * 3 / 2;
if (0 === iYUVSize)
{
return -1;
}
var pYUV = Module._GetFrameBuffer();
// 图像数据渲染后压回,若从主码流切到子码流,存在数组大小与图像大小不匹配现象
var aYUVData = new Uint8Array(iYUVSize);
aYUVData.set(Module.HEAPU8.subarray(pYUV, pYUV + iYUVSize));
if(bWorkerPrintLog)
{
console.log("<<<Worker: video media Info: Width:"+ oFrameInfo.width+",Height:"+oFrameInfo.height+",timeStamp:"+oFrameInfo.timeStamp);
}
postMessage({
'function': "GetFrameData", 'type': "videoType", 'data': aYUVData.buffer,
'dataLen': aYUVData.length,'osd': szOSDTime, 'frameInfo': oFrameInfo, 'errorCode': res
}, [aYUVData.buffer]);
oFrameInfo = null;
pYUV = null;
aYUVData = null;
return PLAYM4_VIDEO_FRAME;
case PRIVT_TYPE:
postMessage({
'function': "GetFrameData", 'type': "", 'data': null,
'dataLen': -1, 'osd': 0, 'frameInfo': null, 'errorCode': PLAYM4_SYS_NOT_SUPPORT
});
return PLAYM4_SYS_NOT_SUPPORT;
default:
postMessage({
'function': "GetFrameData", 'type': "", 'data': null,
'dataLen': -1, 'osd': 0, 'frameInfo': null, 'errorCode': PLAYM4_SYS_NOT_SUPPORT
});
return PLAYM4_SYS_NOT_SUPPORT;
}
}
else {
let errorCode = Module._GetLastError(g_nPort);
//解码失败返回裸数据
if(PLAYM4_DECODE_ERROR===errorCode)
{
var rawInfo=Module._GetRawDataInfo();
var pRawData = Module._GetRawDataBuffer();
var aRawData = new Uint8Array(rawInfo.isize);
aRawData.set(Module.HEAPU8.subarray(pRawData, pRawData + rawInfo.isize));
postMessage({
'function': "GetRawData", 'type': "", 'data':aRawData.buffer,
'rawDataLen': rawInfo.isize, 'osd': 0, 'frameInfo': null, 'errorCode': errorCode
});
rawInfo=null;
pRawData=null;
aRawData=null;
}
//需要更多数据
if (PLAYM4_NEED_MORE_DATA === errorCode || PLAYM4_SYS_NOT_SUPPORT === errorCode || PLAYM4_NEED_NEET_LOOP === errorCode){
postMessage({
'function': "GetFrameData", 'type': "", 'data': null,
'dataLen': -1, 'osd': 0, 'frameInfo': null, 'errorCode': errorCode
});
}
return errorCode;
}
}
// 开始计算时间
function startTime() {
return new Date().getTime();
}
// 结束计算时间
function endTime() {
return new Date().getTime();
}
// 字母字符串转byte数组
function stringToBytes ( str ) {
var ch, st, re = [];
for (var i = 0; i < str.length; i++ ) {
ch = str.charCodeAt(i); // get char
st = []; // set up "stack"
do {
st.push( ch & 0xFF ); // push byte to stack
ch = ch >> 8; // shift value down by 1 byte
}
while ( ch );
// add stack contents to result
// done because chars have "wrong" endianness
re = re.concat( st.reverse() );
}
// return an array of bytes
return re;
}
})();

1
public/static/playctrl1/Decoder.js

File diff suppressed because one or more lines are too long

398
public/static/playctrl1/SuperRender_10.js

@ -1,398 +0,0 @@
"use strict";
//顶点着色器
//attribute修饰符用于声明由浏览器(javascript)传输给顶点着色器的变量值;
// vertexPos即我们定义的顶点坐标;
// gl_Position是一个内建的传出变量。
var vertexYUVShader = [
'attribute vec4 vertexPos;',
'attribute vec2 texturePos;',
'varying vec2 textureCoord;',
'void main()',
'{',
'gl_Position = vertexPos;',
'textureCoord = texturePos;',
'}'
].join('\n');
//像素着色器(yuv->rgb)
var fragmentYUVShader = [
'precision highp float;',
'varying highp vec2 textureCoord;',
'uniform sampler2D ySampler;',
'uniform sampler2D uSampler;',
'uniform sampler2D vSampler;',
'const mat4 YUV2RGB = mat4',
'(',
'1.1643828125, 0, 1.59602734375, -.87078515625,',
'1.1643828125, -.39176171875, -.81296875, .52959375,',
'1.1643828125, 2.017234375, 0, -1.081390625,',
'0, 0, 0, 1',
');',
'void main(void) {',
'highp float y = texture2D(ySampler, textureCoord).r;',
'highp float u = texture2D(uSampler, textureCoord).r;',
'highp float v = texture2D(vSampler, textureCoord).r;',
'gl_FragColor = vec4(y, u, v, 1) * YUV2RGB;',
'}'
].join('\n');
(function (root, factory) {
root.SuperRender = factory();
}(this, function () {
function RenderManager(canvas) {
this.canvasElement = document.getElementById(canvas);
this.initContextGL();
if(this.contextGL) {
this.YUVProgram = this.initProgram(vertexYUVShader, fragmentYUVShader);
this.initBuffers();
this.initTextures();
}
};
/**
* 初始化WebGL上下文
*/
RenderManager.prototype.initContextGL = function() {
var canvas = this.canvasElement;
var gl = null;
try {
gl = canvas.getContext("webgl") || canvas.getContext("experimental-webgl");
} catch (e) {
gl = null;
}
if(!gl || typeof gl.getParameter !== "function") {
gl = null;
}
this.contextGL = gl;
console.log("WebGL1.0");
};
/**
* 初始化着色器程序
* @param vertexShaderScript 顶点着色器脚本
* @param fragmentShaderScript 片段着色器脚本
*/
RenderManager.prototype.initProgram = function(vertexShaderScript, fragmentShaderScript) {
var gl = this.contextGL;
var vertexShader = gl.createShader(gl.VERTEX_SHADER); //创建定点着色器
gl.shaderSource(vertexShader, vertexShaderScript);
gl.compileShader(vertexShader);
if(!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {
console.log('Vertex shader failed to compile: ' + gl.getShaderInfoLog(vertexShader));
}
var fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);
gl.shaderSource(fragmentShader, fragmentShaderScript);
gl.compileShader(fragmentShader);
if(!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {
console.log('Fragment shader failed to compile: ' + gl.getShaderInfoLog(fragmentShader));
}
var program = gl.createProgram();
gl.attachShader(program, vertexShader);
gl.attachShader(program, fragmentShader);
gl.linkProgram(program);
if(!gl.getProgramParameter(program, gl.LINK_STATUS)) {
console.log('Program failed to compile: ' + gl.getProgramInfoLog(program));
}
gl.deleteShader(vertexShader);
gl.deleteShader(fragmentShader);
return program;
};
/**
* 初始化数据缓存
*/
RenderManager.prototype.initBuffers = function() {
var gl = this.contextGL;
var vertexPosBuffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, vertexPosBuffer);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([1, 1, -1, 1, 1, -1, -1, -1]), gl.STATIC_DRAW);
gl.bindBuffer(gl.ARRAY_BUFFER, null);
var texturePosBuffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, texturePosBuffer);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([1, 0, 0, 0, 1, 1, 0, 1]), gl.DYNAMIC_DRAW);
gl.bindBuffer(gl.ARRAY_BUFFER, null);
this.vertexPosBuffer = vertexPosBuffer;
this.texturePosBuffer = texturePosBuffer;
};
/**
* 创建纹理
*/
RenderManager.prototype.initTexture = function() {
var gl = this.contextGL;
var textureRef = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, textureRef);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
gl.bindTexture(gl.TEXTURE_2D, null);
return textureRef;
};
/**
* 初始化YUV纹理
*/
RenderManager.prototype.initTextures = function() {
var gl = this.contextGL;
var program = this.YUVProgram;
gl.useProgram(program);
var yTextureRef = this.initTexture();
var ySamplerRef = gl.getUniformLocation(program, 'ySampler');
gl.uniform1i(ySamplerRef, 0);
this.yTextureRef = yTextureRef;
var uTextureRef = this.initTexture();
var uSamplerRef = gl.getUniformLocation(program, 'uSampler');
gl.uniform1i(uSamplerRef, 1);
this.uTextureRef = uTextureRef;
var vTextureRef = this.initTexture();
var vSamplerRef = gl.getUniformLocation(program, 'vSampler');
gl.uniform1i(vSamplerRef, 2);
this.vTextureRef = vTextureRef;
gl.useProgram(null);
};
/**
* 显示帧数据
* @param nWidth 宽度
* @param nHeight 高度
* @param nHeight 帧数据
*/
RenderManager.prototype.SR_DisplayFrameData = function(nWidth, nHeight, pData,dWidth,dHeight) {
if(nWidth <= 0 || nHeight <= 0)
{
return;
}
var gl = this.contextGL;
if(null == pData)
{
gl.clearColor(0.0, 0.0, 0.0, 0.0);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
return;
}
var canvas = this.canvasElement;
this.nWindowWidth = canvas.width;
this.nWindowHeight = canvas.height;
var nWindowWidth = this.nWindowWidth;
var nWindowHeight = this.nWindowHeight;
gl.clearColor(0.8, 0.8, 1.0, 1.0);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
gl.viewport(0, 0, nWindowWidth, nWindowHeight);
this.updateFrameData(nWidth, nHeight, pData,dWidth,dHeight);
var program = this.YUVProgram;
gl.useProgram(program);
var vertexPosBuffer = this.vertexPosBuffer;
gl.bindBuffer(gl.ARRAY_BUFFER, vertexPosBuffer);
var vertexPosRef = gl.getAttribLocation(program, 'vertexPos');
gl.enableVertexAttribArray(vertexPosRef);
gl.vertexAttribPointer(vertexPosRef, 2, gl.FLOAT, false, 0, 0);
gl.bindBuffer(gl.ARRAY_BUFFER, null);
var texturePosBuffer = this.texturePosBuffer;
gl.bindBuffer(gl.ARRAY_BUFFER, texturePosBuffer);
var texturePosRef = gl.getAttribLocation(program, 'texturePos');
gl.enableVertexAttribArray(texturePosRef);
gl.vertexAttribPointer(texturePosRef, 2, gl.FLOAT, false, 0, 0);
gl.bindBuffer(gl.ARRAY_BUFFER, null);
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
gl.disableVertexAttribArray(vertexPosRef);
gl.disableVertexAttribArray(texturePosRef);
gl.useProgram(null);
};
/**
* 上传YUV数据到纹理
* @param nWidth 宽度
* @param nHeight 高度
* @param nHeight 帧数据
*/
RenderManager.prototype.updateFrameData = function(width, height, data,dWidth,dHeight) {
var gl = this.contextGL;
var yTextureRef = this.yTextureRef;
var uTextureRef = this.uTextureRef;
var vTextureRef = this.vTextureRef;
var i420Data = data;
// debugger;
if(width == dWidth && height == dHeight)
{
var yDataLength = width * height;
var yData = i420Data.subarray(0, yDataLength);
gl.activeTexture(gl.TEXTURE0);
gl.bindTexture(gl.TEXTURE_2D, yTextureRef);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE, width, height, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, yData);
var cbDataLength = width/2 * height/2;
var cbData = i420Data.subarray(width*height, width*height + cbDataLength);
gl.activeTexture(gl.TEXTURE2);
gl.bindTexture(gl.TEXTURE_2D, vTextureRef);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE, width/2, height/2, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, cbData);
var crDataLength = cbDataLength;
var crData = i420Data.subarray(width*height + width*height/4, width*height + width*height/4 + crDataLength);
gl.activeTexture(gl.TEXTURE1);
gl.bindTexture(gl.TEXTURE_2D, uTextureRef);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE, width/2, height/2, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, crData);
}
else
{
// //裁剪宽
var yDataLength = dWidth * dHeight;
var yData=new Uint8Array(yDataLength) ;
for(var i=0;i<dHeight;i++)
{
//var ySonData=new Uint8Array(dWidth) ;
var ySonData = i420Data.subarray(i*width, i*width+dWidth);
for (var j = 0; j < dWidth; j++) {
yData[i*dWidth + j] = ySonData[j];
}
}
gl.activeTexture(gl.TEXTURE0);
gl.bindTexture(gl.TEXTURE_2D, yTextureRef);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE, dWidth, dHeight, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, yData);
yData=null;
ySonData=null;
var cbDataLength = dWidth/2 * dHeight/2;
var cbData =new Uint8Array(cbDataLength);
//var cbSonData=new Uint8Array(dWidth/2) ;
for(var i=0;i<dHeight/2;i++)
{
var cbSonData = i420Data.subarray(width*height+i*width/2, width*height+i*width/2+dWidth/2);
for (var j = 0; j < dWidth/2; j++) {
cbData[i*dWidth/2 + j] = cbSonData[j];
}
}
gl.activeTexture(gl.TEXTURE2);
gl.bindTexture(gl.TEXTURE_2D, vTextureRef);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE, dWidth/2, dHeight/2, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, cbData);
cbData=null;
cbSonData=null;
var crDataLength = cbDataLength;
var crData = new Uint8Array(crDataLength);
for(var i=0;i<dHeight/2;i++)
{
var crSonData = i420Data.subarray(width*height*5/4+i*width/2, width*height*5/4+i*width/2+dWidth/2);
for (var j = 0; j < dWidth/2; j++) {
crData[i*dWidth/2 + j] = crSonData[j];
}
}
gl.activeTexture(gl.TEXTURE1);
gl.bindTexture(gl.TEXTURE_2D, uTextureRef);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE, dWidth/2, dHeight/2, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, crData);
crData=null;
crSonData=null;
}
};
/**
* 设置显示区域
* @param stDisplayRect 显示区域
*/
RenderManager.prototype.SR_SetDisplayRect = function(stDisplayRect) {
var gl = this.contextGL;
var oRect = this.canvasElement.getBoundingClientRect();//采用实际宽高,不然多窗口scale情况下放大异常
var nWindowWidth = oRect.width;
var nWindowHeight = oRect.height;
// var nWindowWidth = this.nWindowWidth;
// var nWindowHeight = this.nWindowHeight;
//console.log("this.nWindowWidth:"+this.nWindowWidth+", this.nWindowHeight:"+this.nWindowHeight)
var texturePosValues = null;
if(stDisplayRect && nWindowWidth > 0 && nWindowHeight > 0) {
var fLeft = stDisplayRect.left / nWindowWidth;
var fTop = stDisplayRect.top / nWindowHeight;
var fRight = stDisplayRect.right / nWindowWidth;
var fBottom = stDisplayRect.bottom / nWindowHeight;
texturePosValues = new Float32Array([fRight, fTop, fLeft, fTop, fRight, fBottom, fLeft, fBottom]);
}
else {
texturePosValues = new Float32Array([1, 0, 0, 0, 1, 1, 0, 1]);
}
var texturePosBuffer = this.texturePosBuffer;
gl.bindBuffer(gl.ARRAY_BUFFER, texturePosBuffer);
gl.bufferSubData(gl.ARRAY_BUFFER, 0, texturePosValues);
gl.bindBuffer(gl.ARRAY_BUFFER, null);
};
/**
* 释放显示资源
*/
RenderManager.prototype.SR_Destroy = function() {
var gl = this.contextGL;
var YUVProgram = this.YUVProgram;
gl.deleteProgram(YUVProgram);
var vertexPosBuffer = this.vertexPosBuffer;
var texturePosBuffer = this.texturePosBuffer;
gl.deleteBuffer(vertexPosBuffer);
gl.deleteBuffer(texturePosBuffer);
var yTextureRef = this.yTextureRef;
var uTextureRef = this.uTextureRef;
var vTextureRef = this.vTextureRef;
gl.deleteTexture(yTextureRef);
gl.deleteTexture(uTextureRef);
gl.deleteTexture(vTextureRef);
gl.getExtension('WEBGL_lose_context').loseContext();
};
return RenderManager;
}));

225
public/static/playctrl1simd/AudioRenderer.js

@ -1,225 +0,0 @@
/**
* Created by wangweijie5 on 2016/12/16.
*/
"use strict";
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var __instance = function () {
var instance = void 0;
return function (newInstance) {
if (newInstance) instance = newInstance;
return instance;
};
}();
var AudioRenderer = function () {
function AudioRenderer() {
_classCallCheck(this, AudioRenderer);
if (__instance()) return __instance();
// 确保只有单例
if (AudioRenderer.unique !== undefined) {
return AudioRenderer.unique;
}
AudioRenderer.unique = this;
this.oAudioContext = null;
this.currentVolume = 80; // 初始音量
this.bSetVolume = false;
this.gainNode = null;
this.iWndNum = -1; // 窗口号
this.mVolumes = new Map(); // 用于存储所有音量
// Init AudioContext
var AudioContext = window.AudioContext || window.webkitAudioContext;
this.oAudioContext = new AudioContext();
this.writeString = function (view, offset, string) {
for (var i = 0; i < string.length; i++) {
view.setUint8(offset + i, string.charCodeAt(i));
}
};
this.setBufferToDataview = function (output, offset, input) {
for (var i = 0; i < input.length; i++, offset++) {
output.setUint8(offset, input[i]);
}
};
__instance(this);
}
/**
* @synopsis 音频播放
*
* @param dataBuf [IN] 音频缓存
* @param dataLen [IN] 缓存长度
* @param audioInfo [IN] 音频参数
*
* @returns 状态码
*/
_createClass(AudioRenderer, [{
key: 'Play',
value: function Play(dataBuf, dataLen, audioInfo) {
var bufferData = new ArrayBuffer(44 + dataLen);
var viewTalk = new DataView(bufferData);
var sampleRates = audioInfo.samplesPerSec;
var channels = audioInfo.channels;
var bitsPerSample = audioInfo.bitsPerSample;
//console.log("audiorender sampleRates"+sampleRates+"channels:"+channels+"bitsPerSample:"+bitsPerSample);
/* RIFF identifier */
this.writeString(viewTalk, 0, 'RIFF');
/* file length */
viewTalk.setUint32(4, 32 + dataLen * 2, true);
/* RIFF type */
this.writeString(viewTalk, 8, 'WAVE');
/* format chunk identifier */
this.writeString(viewTalk, 12, 'fmt ');
/* format chunk length */
viewTalk.setUint32(16, 16, true);
/* sample format (raw) */
viewTalk.setUint16(20, 1, true);
/* channel count */
viewTalk.setUint16(22, channels, true);
/* sample rate */
viewTalk.setUint32(24, sampleRates, true);
/* byte rate (sample rate * block align) */
viewTalk.setUint32(28, sampleRates * 2, true);
/* block align (channel count * bytes per sample)/8 */
viewTalk.setUint16(32, channels * bitsPerSample / 8, true);
/* bits per sample */
viewTalk.setUint16(34, bitsPerSample, true);
/* data chunk identifier */
this.writeString(viewTalk, 36, 'data');
/* data chunk length */
viewTalk.setUint32(40, dataLen, true);
this.setBufferToDataview(viewTalk, 44, dataBuf);
var self = this;
this.oAudioContext.decodeAudioData(viewTalk.buffer, function (buffer) {
var bufferSource = self.oAudioContext.createBufferSource();
if (bufferSource == null) {
return -1;
}
bufferSource.buffer = buffer;
bufferSource.start(0);
if (self.gainNode == null || self.bSetVolume) {
self.gainNode = self.oAudioContext.createGain();
// self.gainNode.gain.value = self.currentVolume;
// // self.currentVolume = self.gainNode.gain.value;
// self.gainNode.connect(self.oAudioContext.destination);
self.bSetVolume = false;
}
self.gainNode.gain.value = self.currentVolume/100;
// self.currentVolume = self.gainNode.gain.value;
self.gainNode.connect(self.oAudioContext.destination);
bufferSource.connect(self.gainNode);
}, function (e) {
console.log("decode error");
return -1;
});
return 0;
}
/**
* @synopsis 停止播放
*
* @returns 返回音量
*/
}, {
key: 'Stop',
value: function Stop() {
if (this.gainNode != null) {
this.gainNode.disconnect();
this.gainNode = null;
}
// this.oAudioContext.close();
// AudioRenderer.unique = undefined;
// __instance() = null;
return true;
}
/**
* @synopsis 设置音量
*
* @param iVolume [IN] 音量
*
* @returns 状态码
*/
}, {
key: 'SetVolume',
value: function SetVolume(iVolume) {
this.bSetVolume = true;
this.currentVolume = iVolume;
// 储存当前窗口设置音量值
this.mVolumes.set(this.iWndNum, this.currentVolume);
return true;
}
/**
* @synopsis 设置窗口号
*
* @param iWndNum [IN] 窗口号
*
* @returns 状态码
*/
}, {
key: 'SetWndNum',
value: function SetWndNum(iWndNum) {
this.iWndNum = iWndNum;
// 获取当前窗口设置音量值
var iVolume = this.mVolumes.get(iWndNum);
if (iVolume == undefined) {
iVolume = 80; // 默认音量
}
this.currentVolume = iVolume;
return true;
}
/**
* @synopsis 获取音量
*
* @returns 返回音量
*/
}, {
key: 'GetVolume',
value: function GetVolume() {
// 获取当前窗口设置音量值
var iVolume = this.mVolumes.get(this.iWndNum);
if (iVolume == undefined) {
iVolume = 80; // 默认音量
}
return iVolume;
}
}]);
return AudioRenderer;
}();
//# sourceMappingURL=AudioRenderer.js.map

621
public/static/playctrl1simd/DecodeWorker.js

@ -1,621 +0,0 @@
/**
* Created by wangweijie5 on 2016/12/5.
*/
(function (event) {
const AUDIO_TYPE = 0; // 音频
const VIDEO_TYPE = 1; // 视频
const PRIVT_TYPE = 2; // 私有帧
const PLAYM4_AUDIO_FRAME = 100; // 音频帧
const PLAYM4_VIDEO_FRAME = 101; // 视频帧
const PLAYM4_OK = 1;
const PLAYM4_ORDER_ERROR = 2;
const PLAYM4_DECODE_ERROR = 44 // 解码失败
const PLAYM4_NOT_KEYFRAME = 48; // 非关键帧
const PLAYM4_NEED_MORE_DATA = 31; // 需要更多数据才能解析
const PLAYM4_NEED_NEET_LOOP = 35; //丢帧需要下个循环
const PLAYM4_SYS_NOT_SUPPORT = 16; // 不支持
importScripts('Decoder.js');
Module.addOnPostRun(function () {
postMessage({'function': "loaded"});
});
var iStreamMode = 0; // 流模式
var bOpenMode = false;
var bOpenStream = false;
var funGetFrameData = null;
var funGetAudFrameData = null;
var bWorkerPrintLog=false;//worker层log开关
var g_nPort = -1;
onmessage = function (event)
{
var eventData = event.data;
var res = 0;
switch (eventData.command)
{
case "printLog":
let downloadFlag=eventData.data;
if(downloadFlag===true)
{
bWorkerPrintLog=true;
res = Module._SetPrintLogFlag(g_nPort,downloadFlag);
}
else
{
bWorkerPrintLog=false;
res = Module._SetPrintLogFlag(g_nPort,downloadFlag);
}
if (res !== PLAYM4_OK)
{
console.log("DecodeWorker.js: PlayerSDK print log failed,res"+res);
postMessage({'function': "printLog", 'errorCode': res});
}
break;
case "SetPlayPosition":
let nFrameNumOrTime=eventData.data;
let enPosType=eventData.type;
// res = Module._SetPlayPosition(nFrameNumOrTime,enPosType);
// if (res !== PLAYM4_OK)
// {
// postMessage({'function': "SetPlayPosition", 'errorCode': res});
// return;
// }
// //有没有buffer需要清除
break;
case "SetStreamOpenMode":
//获取端口号
g_nPort = Module._GetPort();
//设置流打开模式
iStreamMode = eventData.data;
res = Module._SetStreamOpenMode(g_nPort,iStreamMode);
if (res !== PLAYM4_OK)
{
postMessage({'function': "SetStreamOpenMode", 'errorCode': res});
return;
}
bOpenMode = true;
break;
case "OpenStream":
// 接收到的数据
var iHeadLen = eventData.dataSize;
var pHead = Module._malloc(iHeadLen + 4);
if (pHead === null)
{
return;
}
var aHead = Module.HEAPU8.subarray(pHead, pHead + iHeadLen);
aHead.set(eventData.data);
res = Module._OpenStream(g_nPort,pHead, iHeadLen, eventData.bufPoolSize);
postMessage({'function': "OpenStream", 'errorCode': res});
if (res !== PLAYM4_OK)
{
//释放内存
Module._free(pHead);
pHead = null;
return;
}
bOpenStream = true;
break;
case "Play":
let resP = Module._Play(g_nPort);
if (resP !== PLAYM4_OK)
{
return;
}
break;
case "InputData":
// 接收到的数据
var iLen = eventData.dataSize;
if (iLen > 0)
{
var pInputData = Module._malloc(iLen);
if (pInputData === null)
{
return;
}
var inputData = new Uint8Array(eventData.data);
// var aInputData = Module.HEAPU8.subarray(pInputData, pInputData + iLen);
// aInputData.set(inputData);
Module.writeArrayToMemory(inputData, pInputData);
inputData = null;
res = Module._InputData(g_nPort,pInputData, iLen);
if (res !== PLAYM4_OK)
{
let errorCode = Module._GetLastError(g_nPort);
let sourceRemain = Module._GetSourceBufferRemain(g_nPort);
postMessage({'function': "InputData", 'errorCode': errorCode,"sourceRemain":sourceRemain});
}
Module._free(pInputData);
pInputData = null;
}else{
let sourceRemain = Module._GetSourceBufferRemain(g_nPort);
if(sourceRemain == 0)
{
console.log("C buffer and JS buffer size is both 0");
postMessage({'function': "InputData", 'errorCode':PLAYM4_NEED_MORE_DATA});
return;
}
}
/////////////////////
if (funGetFrameData === null)
{
funGetFrameData = Module.cwrap('GetFrameData', 'number');
}
while (bOpenMode && bOpenStream)
{
var ret = getFrameData(funGetFrameData);
// 直到获取视频帧或数据不足为止
if (PLAYM4_VIDEO_FRAME === ret ||PLAYM4_NEED_MORE_DATA === ret || PLAYM4_ORDER_ERROR === ret || PLAYM4_NEED_NEET_LOOP ===ret)//PLAYM4_VIDEO_FRAME === ret ||
{
break;
}
}
break;
case "SetSecretKey":
var keyLen = eventData.nKeyLen;
var pKeyData = Module._malloc(keyLen);
if (pKeyData === null) {
return;
}
var nKeySize = eventData.data.length
var bufData = stringToBytes (eventData.data);
var aKeyData = Module.HEAPU8.subarray(pKeyData, pKeyData + keyLen);
aKeyData.set(new Uint8Array(bufData));
res = Module._SetSecretKey(g_nPort,eventData.nKeyType, pKeyData, keyLen);//, nKeySize
if (res !== PLAYM4_OK) {
postMessage({'function': "SetSecretKey", 'errorCode': res});
Module._free(pKeyData);
pKeyData = null;
return;
}
Module._free(pKeyData);
pKeyData = null;
break;
case "GetBMP":
var nBMPWidth = eventData.width;
var nBMPHeight = eventData.height;
var pYUVData = eventData.data;
var nYUVSize = nBMPWidth * nBMPHeight * 3 / 2;
var oBMPCropRect = eventData.rect;
var pDataYUV = Module._malloc(nYUVSize);
if (pDataYUV === null) {
return;
}
Module.writeArrayToMemory(new Uint8Array(pYUVData, 0, nYUVSize), pDataYUV);
// 分配BMP空间
var nBmpSize = nBMPWidth * nBMPHeight * 4 + 60;
var pBmpData = Module._malloc(nBmpSize);
var pBmpSize = Module._malloc(4);
if (pBmpData === null || pBmpSize === null) {
Module._free(pDataYUV);
pDataYUV = null;
if (pBmpData != null) {
Module._free(pBmpData);
pBmpData = null;
}
if (pBmpSize != null) {
Module._free(pBmpSize);
pBmpSize = null;
}
return;
}
//Module._memset(pBmpSize, nBmpSize, 4); // 防止bmp截图出现输入数据过大的错误码
Module.setValue(pBmpSize, nBmpSize, "i32");
res = Module._GetBMP(g_nPort,pDataYUV, nYUVSize, pBmpData, pBmpSize,
oBMPCropRect.left, oBMPCropRect.top, oBMPCropRect.right, oBMPCropRect.bottom);
if (res !== PLAYM4_OK) {
postMessage({'function': "GetBMP", 'errorCode': res});
Module._free(pDataYUV);
pDataYUV = null;
Module._free(pBmpData);
pBmpData = null;
Module._free(pBmpSize);
pBmpSize = null;
return;
}
// 获取BMP图片大小
var nBmpDataSize = Module.getValue(pBmpSize, "i32");
// 获取BMP图片数据
var aBmpData = new Uint8Array(nBmpDataSize);
aBmpData.set(Module.HEAPU8.subarray(pBmpData, pBmpData + nBmpDataSize));
postMessage({'function': "GetBMP", 'data': aBmpData, 'errorCode': res}, [aBmpData.buffer]);
aBmpData=null;
if (pDataYUV != null) {
Module._free(pDataYUV);
pDataYUV = null;
}
if (pBmpData != null) {
Module._free(pBmpData);
pBmpData = null;
}
if (pBmpSize != null) {
Module._free(pBmpSize);
pBmpSize = null;
}
break;
case "GetJPEG":
var nJpegWidth = eventData.width;
var nJpegHeight = eventData.height;
var pYUVData1 = eventData.data;
var nYUVSize1 = nJpegWidth * nJpegHeight * 3 / 2;
var oJpegCropRect = eventData.rect;
var pDataYUV1 = Module._malloc(nYUVSize1);
if (pDataYUV1 === null) {
return;
}
Module.writeArrayToMemory(new Uint8Array(pYUVData1, 0, nYUVSize1), pDataYUV1);
// 分配JPEG空间
var pJpegData = Module._malloc(nYUVSize1);
var pJpegSize = Module._malloc(4);
if (pJpegData === null || pJpegSize === null) {
if (pJpegData != null) {
Module._free(pJpegData);
pJpegData = null;
}
if (pJpegSize != null) {
Module._free(pJpegSize);
pJpegSize = null;
}
if (pDataYUV1 != null) {
Module._free(pDataYUV1);
pDataYUV1 = null;
}
return;
}
Module.setValue(pJpegSize, nJpegWidth * nJpegHeight * 2, "i32"); // JPEG抓图,输入缓冲长度不小于当前帧YUV大小
res = Module._GetJPEG(g_nPort,pDataYUV1, nYUVSize1, pJpegData, pJpegSize,
oJpegCropRect.left, oJpegCropRect.top, oJpegCropRect.right, oJpegCropRect.bottom);
if (res !== PLAYM4_OK) {
postMessage({'function': "GetJPEG", 'errorCode': res});
if (pJpegData != null) {
Module._free(pJpegData);
pJpegData = null;
}
if (pJpegSize != null) {
Module._free(pJpegSize);
pJpegSize = null;
}
if (pDataYUV1 != null) {
Module._free(pDataYUV1);
pDataYUV1 = null;
}
return;
}
// 获取JPEG图片大小
var nJpegSize = Module.getValue(pJpegSize, "i32");
// 获取JPEG图片数据
var aJpegData = new Uint8Array(nJpegSize);
aJpegData.set(Module.HEAPU8.subarray(pJpegData, pJpegData + nJpegSize));
postMessage({'function': "GetJPEG", 'data': aJpegData, 'errorCode': res}, [aJpegData.buffer]);
nJpegSize = null;
aJpegData = null;
if (pDataYUV1 != null) {
Module._free(pDataYUV1);
pDataYUV1 = null;
}
if (pJpegData != null) {
Module._free(pJpegData);
pJpegData = null;
}
if (pJpegSize != null) {
Module._free(pJpegSize);
pJpegSize = null;
}
break;
case "SetDecodeFrameType":
var nFrameType = eventData.data;
res = Module._SetDecodeFrameType(g_nPort,nFrameType);
if (res !== PLAYM4_OK) {
postMessage({'function': "SetDecodeFrameType", 'errorCode': res});
return;
}
break;
case "CloseStream":
//stop
let resS = Module._Stop(g_nPort);
if (resS !== PLAYM4_OK) {
postMessage({'function': "Stop", 'errorCode': res});
return;
}
//closeStream
res = Module._CloseStream(g_nPort);
if (res !== PLAYM4_OK) {
postMessage({'function': "CloseStream", 'errorCode': res});
return;
}
//freePort
let resF = Module._FreePort(g_nPort);
if (resF !== PLAYM4_OK) {
postMessage({'function': "FreePort", 'errorCode': res});
return;
}
break;
case "PlaySound":
let resPS = Module._PlaySound(g_nPort);
if (resPS !== PLAYM4_OK) {
console.log("PlaySound failed");
return;
}
break;
case "StopSound":
let resSS = Module._StopSound();
if (resSS !== PLAYM4_OK) {
console.log("StopSound failed");
return;
}
break;
case "SetVolume":
let resSV = Module._SetVolume(g_nPort,eventData.volume);
if (resSV !== PLAYM4_OK) {
console.log("Audio SetVolume failed");
return;
}
break;
case "GetVolume":
let volume = Module._GetVolume();
if(volume>0)
{
postMessage({'function': "GetVolume", 'volume': volume});
}
else{
console.log("Audio GetVolume failed");
return;
}
break;
case "OnlyPlaySound":
let resOPS = Module._OnlyPlaySound(g_nPort);
if (resOPS !== PLAYM4_OK) {
console.log("OnlyPlaySound failed");
return;
}
break;
case "Pause" :
let resPa = Module._Pause(g_nPort,eventData.bPlay);
if (resPa !== PLAYM4_OK) {
console.log("Pause failed");
return;
}
case "PlayRate":
Module._SetPlayRate(g_nPort,eventData.playRate);
break;
case "SetIFrameDecInterval":
Module._SetIFrameDecInterval(g_nPort,eventData.data);
break;
case "SetLostFrameMode":
Module._SetLostFrameMode(g_nPort,eventData.data);
break;
case "SetDemuxModel":
Module._SetDemuxModel(g_nPort,eventData.nIdemuxType,eventData.bTrue);
break;
case "SkipErrorData":
Module._SkipErrorData(g_nPort,eventData.bSkip);
break;
case "SetDecodeERC":
Module._SetDecodeERC(g_nPort,eventData.nLevel);
break;
case "SetANRParam":
Module._SetANRParam(g_nPort,eventData.nEnable,eventData.nANRLevel);
break;
case "SetResampleValue":
Module._SetResampleValue(g_nPort,eventData.nEnable,eventData.resampleValue);
break;
case "GetLastError":
let errorCode = Module._GetLastError(g_nPort);
postMessage({'function': "GetLastError", 'errorCode': errorCode});
break;
case "SetGlobalBaseTime":
Module._SetGlobalBaseTime(g_nPort,eventData.year,eventData.month,eventData.day,eventData.hour,eventData.min,eventData.sec,eventData.ms);
break;
default:
break;
}
};
function getOSDTime(oFrameInfo) {
var iYear = oFrameInfo.year;
var iMonth = oFrameInfo.month;
var iDay = oFrameInfo.day;
var iHour = oFrameInfo.hour;
var iMinute = oFrameInfo.minute;
var iSecond = oFrameInfo.second;
if (iMonth < 10) {
iMonth = "0" + iMonth;
}
if (iDay < 10) {
iDay = "0" + iDay;
}
if (iHour < 10) {
iHour = "0" + iHour;
}
if (iMinute < 10) {
iMinute = "0" + iMinute;
}
if (iSecond < 10) {
iSecond = "0" + iSecond;
}
return iYear + "-" + iMonth + "-" + iDay + " " + iHour + ":" + iMinute + ":" + iSecond;
}
// 获取帧数据
function getFrameData(fun)
{
// function getFrameData() {
// 获取帧数据
// var res = Module._GetFrameData();
var res = fun();
if (res === PLAYM4_OK)
{
var oFrameInfo = Module._GetFrameInfo();
switch (oFrameInfo.frameType)
{
case AUDIO_TYPE:
var iSize = oFrameInfo.frameSize;
if (0 === iSize)
{
return -1;
}
var pPCM = Module._GetFrameBuffer();
// var audioBuf = new ArrayBuffer(iSize);
var aPCMData = new Uint8Array(iSize);
aPCMData.set(Module.HEAPU8.subarray(pPCM, pPCM + iSize));
if(bWorkerPrintLog)
{
console.log("<<<Worker: audio media Info: nSise:"+ oFrameInfo.frameSize+",nSampleRate:"+oFrameInfo.samplesPerSec+',channel:'+oFrameInfo.channels+',bitsPerSample:'+oFrameInfo.bitsPerSample);
}
postMessage({
'function': "GetFrameData", 'type': "audioType", 'data': aPCMData.buffer,
'frameInfo': oFrameInfo, 'errorCode': res
}, [aPCMData.buffer]);
oFrameInfo = null;
pPCM = null;
aPCMData = null;
return PLAYM4_AUDIO_FRAME;
case VIDEO_TYPE:
var szOSDTime = getOSDTime(oFrameInfo);
var iWidth = oFrameInfo.width;
var iHeight = oFrameInfo.height;
var iYUVSize = iWidth * iHeight * 3 / 2;
if (0 === iYUVSize)
{
return -1;
}
var pYUV = Module._GetFrameBuffer();
// 图像数据渲染后压回,若从主码流切到子码流,存在数组大小与图像大小不匹配现象
var aYUVData = new Uint8Array(iYUVSize);
aYUVData.set(Module.HEAPU8.subarray(pYUV, pYUV + iYUVSize));
if(bWorkerPrintLog)
{
console.log("<<<Worker: video media Info: Width:"+ oFrameInfo.width+",Height:"+oFrameInfo.height+",timeStamp:"+oFrameInfo.timeStamp);
}
postMessage({
'function': "GetFrameData", 'type': "videoType", 'data': aYUVData.buffer,
'dataLen': aYUVData.length,'osd': szOSDTime, 'frameInfo': oFrameInfo, 'errorCode': res
}, [aYUVData.buffer]);
oFrameInfo = null;
pYUV = null;
aYUVData = null;
return PLAYM4_VIDEO_FRAME;
case PRIVT_TYPE:
postMessage({
'function': "GetFrameData", 'type': "", 'data': null,
'dataLen': -1, 'osd': 0, 'frameInfo': null, 'errorCode': PLAYM4_SYS_NOT_SUPPORT
});
return PLAYM4_SYS_NOT_SUPPORT;
default:
postMessage({
'function': "GetFrameData", 'type': "", 'data': null,
'dataLen': -1, 'osd': 0, 'frameInfo': null, 'errorCode': PLAYM4_SYS_NOT_SUPPORT
});
return PLAYM4_SYS_NOT_SUPPORT;
}
}
else {
let errorCode = Module._GetLastError(g_nPort);
//解码失败返回裸数据
if(PLAYM4_DECODE_ERROR===errorCode)
{
var rawInfo=Module._GetRawDataInfo();
var pRawData = Module._GetRawDataBuffer();
var aRawData = new Uint8Array(rawInfo.isize);
aRawData.set(Module.HEAPU8.subarray(pRawData, pRawData + rawInfo.isize));
postMessage({
'function': "GetRawData", 'type': "", 'data':aRawData.buffer,
'rawDataLen': rawInfo.isize, 'osd': 0, 'frameInfo': null, 'errorCode': errorCode
});
rawInfo=null;
pRawData=null;
aRawData=null;
}
//需要更多数据
if (PLAYM4_NEED_MORE_DATA === errorCode || PLAYM4_SYS_NOT_SUPPORT === errorCode || PLAYM4_NEED_NEET_LOOP === errorCode){
postMessage({
'function': "GetFrameData", 'type': "", 'data': null,
'dataLen': -1, 'osd': 0, 'frameInfo': null, 'errorCode': errorCode
});
}
return errorCode;
}
}
// 开始计算时间
function startTime() {
return new Date().getTime();
}
// 结束计算时间
function endTime() {
return new Date().getTime();
}
// 字母字符串转byte数组
function stringToBytes ( str ) {
var ch, st, re = [];
for (var i = 0; i < str.length; i++ ) {
ch = str.charCodeAt(i); // get char
st = []; // set up "stack"
do {
st.push( ch & 0xFF ); // push byte to stack
ch = ch >> 8; // shift value down by 1 byte
}
while ( ch );
// add stack contents to result
// done because chars have "wrong" endianness
re = re.concat( st.reverse() );
}
// return an array of bytes
return re;
}
})();

1
public/static/playctrl1simd/Decoder.js

File diff suppressed because one or more lines are too long

398
public/static/playctrl1simd/SuperRender_10.js

@ -1,398 +0,0 @@
"use strict";
//顶点着色器
//attribute修饰符用于声明由浏览器(javascript)传输给顶点着色器的变量值;
// vertexPos即我们定义的顶点坐标;
// gl_Position是一个内建的传出变量。
var vertexYUVShader = [
'attribute vec4 vertexPos;',
'attribute vec2 texturePos;',
'varying vec2 textureCoord;',
'void main()',
'{',
'gl_Position = vertexPos;',
'textureCoord = texturePos;',
'}'
].join('\n');
//像素着色器(yuv->rgb)
var fragmentYUVShader = [
'precision highp float;',
'varying highp vec2 textureCoord;',
'uniform sampler2D ySampler;',
'uniform sampler2D uSampler;',
'uniform sampler2D vSampler;',
'const mat4 YUV2RGB = mat4',
'(',
'1.1643828125, 0, 1.59602734375, -.87078515625,',
'1.1643828125, -.39176171875, -.81296875, .52959375,',
'1.1643828125, 2.017234375, 0, -1.081390625,',
'0, 0, 0, 1',
');',
'void main(void) {',
'highp float y = texture2D(ySampler, textureCoord).r;',
'highp float u = texture2D(uSampler, textureCoord).r;',
'highp float v = texture2D(vSampler, textureCoord).r;',
'gl_FragColor = vec4(y, u, v, 1) * YUV2RGB;',
'}'
].join('\n');
(function (root, factory) {
root.SuperRender = factory();
}(this, function () {
function RenderManager(canvas) {
this.canvasElement = document.getElementById(canvas);
this.initContextGL();
if(this.contextGL) {
this.YUVProgram = this.initProgram(vertexYUVShader, fragmentYUVShader);
this.initBuffers();
this.initTextures();
}
};
/**
* 初始化WebGL上下文
*/
RenderManager.prototype.initContextGL = function() {
var canvas = this.canvasElement;
var gl = null;
try {
gl = canvas.getContext("webgl") || canvas.getContext("experimental-webgl");
} catch (e) {
gl = null;
}
if(!gl || typeof gl.getParameter !== "function") {
gl = null;
}
this.contextGL = gl;
console.log("WebGL1.0");
};
/**
* 初始化着色器程序
* @param vertexShaderScript 顶点着色器脚本
* @param fragmentShaderScript 片段着色器脚本
*/
RenderManager.prototype.initProgram = function(vertexShaderScript, fragmentShaderScript) {
var gl = this.contextGL;
var vertexShader = gl.createShader(gl.VERTEX_SHADER); //创建定点着色器
gl.shaderSource(vertexShader, vertexShaderScript);
gl.compileShader(vertexShader);
if(!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {
console.log('Vertex shader failed to compile: ' + gl.getShaderInfoLog(vertexShader));
}
var fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);
gl.shaderSource(fragmentShader, fragmentShaderScript);
gl.compileShader(fragmentShader);
if(!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {
console.log('Fragment shader failed to compile: ' + gl.getShaderInfoLog(fragmentShader));
}
var program = gl.createProgram();
gl.attachShader(program, vertexShader);
gl.attachShader(program, fragmentShader);
gl.linkProgram(program);
if(!gl.getProgramParameter(program, gl.LINK_STATUS)) {
console.log('Program failed to compile: ' + gl.getProgramInfoLog(program));
}
gl.deleteShader(vertexShader);
gl.deleteShader(fragmentShader);
return program;
};
/**
* 初始化数据缓存
*/
RenderManager.prototype.initBuffers = function() {
var gl = this.contextGL;
var vertexPosBuffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, vertexPosBuffer);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([1, 1, -1, 1, 1, -1, -1, -1]), gl.STATIC_DRAW);
gl.bindBuffer(gl.ARRAY_BUFFER, null);
var texturePosBuffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, texturePosBuffer);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([1, 0, 0, 0, 1, 1, 0, 1]), gl.DYNAMIC_DRAW);
gl.bindBuffer(gl.ARRAY_BUFFER, null);
this.vertexPosBuffer = vertexPosBuffer;
this.texturePosBuffer = texturePosBuffer;
};
/**
* 创建纹理
*/
RenderManager.prototype.initTexture = function() {
var gl = this.contextGL;
var textureRef = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, textureRef);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
gl.bindTexture(gl.TEXTURE_2D, null);
return textureRef;
};
/**
* 初始化YUV纹理
*/
RenderManager.prototype.initTextures = function() {
var gl = this.contextGL;
var program = this.YUVProgram;
gl.useProgram(program);
var yTextureRef = this.initTexture();
var ySamplerRef = gl.getUniformLocation(program, 'ySampler');
gl.uniform1i(ySamplerRef, 0);
this.yTextureRef = yTextureRef;
var uTextureRef = this.initTexture();
var uSamplerRef = gl.getUniformLocation(program, 'uSampler');
gl.uniform1i(uSamplerRef, 1);
this.uTextureRef = uTextureRef;
var vTextureRef = this.initTexture();
var vSamplerRef = gl.getUniformLocation(program, 'vSampler');
gl.uniform1i(vSamplerRef, 2);
this.vTextureRef = vTextureRef;
gl.useProgram(null);
};
/**
* 显示帧数据
* @param nWidth 宽度
* @param nHeight 高度
* @param nHeight 帧数据
*/
RenderManager.prototype.SR_DisplayFrameData = function(nWidth, nHeight, pData,dWidth,dHeight) {
if(nWidth <= 0 || nHeight <= 0)
{
return;
}
var gl = this.contextGL;
if(null == pData)
{
gl.clearColor(0.0, 0.0, 0.0, 0.0);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
return;
}
var canvas = this.canvasElement;
this.nWindowWidth = canvas.width;
this.nWindowHeight = canvas.height;
var nWindowWidth = this.nWindowWidth;
var nWindowHeight = this.nWindowHeight;
gl.clearColor(0.8, 0.8, 1.0, 1.0);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
gl.viewport(0, 0, nWindowWidth, nWindowHeight);
this.updateFrameData(nWidth, nHeight, pData,dWidth,dHeight);
var program = this.YUVProgram;
gl.useProgram(program);
var vertexPosBuffer = this.vertexPosBuffer;
gl.bindBuffer(gl.ARRAY_BUFFER, vertexPosBuffer);
var vertexPosRef = gl.getAttribLocation(program, 'vertexPos');
gl.enableVertexAttribArray(vertexPosRef);
gl.vertexAttribPointer(vertexPosRef, 2, gl.FLOAT, false, 0, 0);
gl.bindBuffer(gl.ARRAY_BUFFER, null);
var texturePosBuffer = this.texturePosBuffer;
gl.bindBuffer(gl.ARRAY_BUFFER, texturePosBuffer);
var texturePosRef = gl.getAttribLocation(program, 'texturePos');
gl.enableVertexAttribArray(texturePosRef);
gl.vertexAttribPointer(texturePosRef, 2, gl.FLOAT, false, 0, 0);
gl.bindBuffer(gl.ARRAY_BUFFER, null);
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
gl.disableVertexAttribArray(vertexPosRef);
gl.disableVertexAttribArray(texturePosRef);
gl.useProgram(null);
};
/**
* 上传YUV数据到纹理
* @param nWidth 宽度
* @param nHeight 高度
* @param nHeight 帧数据
*/
RenderManager.prototype.updateFrameData = function(width, height, data,dWidth,dHeight) {
var gl = this.contextGL;
var yTextureRef = this.yTextureRef;
var uTextureRef = this.uTextureRef;
var vTextureRef = this.vTextureRef;
var i420Data = data;
// debugger;
if(width == dWidth && height == dHeight)
{
var yDataLength = width * height;
var yData = i420Data.subarray(0, yDataLength);
gl.activeTexture(gl.TEXTURE0);
gl.bindTexture(gl.TEXTURE_2D, yTextureRef);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE, width, height, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, yData);
var cbDataLength = width/2 * height/2;
var cbData = i420Data.subarray(width*height, width*height + cbDataLength);
gl.activeTexture(gl.TEXTURE2);
gl.bindTexture(gl.TEXTURE_2D, vTextureRef);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE, width/2, height/2, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, cbData);
var crDataLength = cbDataLength;
var crData = i420Data.subarray(width*height + width*height/4, width*height + width*height/4 + crDataLength);
gl.activeTexture(gl.TEXTURE1);
gl.bindTexture(gl.TEXTURE_2D, uTextureRef);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE, width/2, height/2, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, crData);
}
else
{
// //裁剪宽
var yDataLength = dWidth * dHeight;
var yData=new Uint8Array(yDataLength) ;
for(var i=0;i<dHeight;i++)
{
//var ySonData=new Uint8Array(dWidth) ;
var ySonData = i420Data.subarray(i*width, i*width+dWidth);
for (var j = 0; j < dWidth; j++) {
yData[i*dWidth + j] = ySonData[j];
}
}
gl.activeTexture(gl.TEXTURE0);
gl.bindTexture(gl.TEXTURE_2D, yTextureRef);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE, dWidth, dHeight, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, yData);
yData=null;
ySonData=null;
var cbDataLength = dWidth/2 * dHeight/2;
var cbData =new Uint8Array(cbDataLength);
//var cbSonData=new Uint8Array(dWidth/2) ;
for(var i=0;i<dHeight/2;i++)
{
var cbSonData = i420Data.subarray(width*height+i*width/2, width*height+i*width/2+dWidth/2);
for (var j = 0; j < dWidth/2; j++) {
cbData[i*dWidth/2 + j] = cbSonData[j];
}
}
gl.activeTexture(gl.TEXTURE2);
gl.bindTexture(gl.TEXTURE_2D, vTextureRef);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE, dWidth/2, dHeight/2, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, cbData);
cbData=null;
cbSonData=null;
var crDataLength = cbDataLength;
var crData = new Uint8Array(crDataLength);
for(var i=0;i<dHeight/2;i++)
{
var crSonData = i420Data.subarray(width*height*5/4+i*width/2, width*height*5/4+i*width/2+dWidth/2);
for (var j = 0; j < dWidth/2; j++) {
crData[i*dWidth/2 + j] = crSonData[j];
}
}
gl.activeTexture(gl.TEXTURE1);
gl.bindTexture(gl.TEXTURE_2D, uTextureRef);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE, dWidth/2, dHeight/2, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, crData);
crData=null;
crSonData=null;
}
};
/**
* 设置显示区域
* @param stDisplayRect 显示区域
*/
RenderManager.prototype.SR_SetDisplayRect = function(stDisplayRect) {
var gl = this.contextGL;
var oRect = this.canvasElement.getBoundingClientRect();//采用实际宽高,不然多窗口scale情况下放大异常
var nWindowWidth = oRect.width;
var nWindowHeight = oRect.height;
// var nWindowWidth = this.nWindowWidth;
// var nWindowHeight = this.nWindowHeight;
//console.log("this.nWindowWidth:"+this.nWindowWidth+", this.nWindowHeight:"+this.nWindowHeight)
var texturePosValues = null;
if(stDisplayRect && nWindowWidth > 0 && nWindowHeight > 0) {
var fLeft = stDisplayRect.left / nWindowWidth;
var fTop = stDisplayRect.top / nWindowHeight;
var fRight = stDisplayRect.right / nWindowWidth;
var fBottom = stDisplayRect.bottom / nWindowHeight;
texturePosValues = new Float32Array([fRight, fTop, fLeft, fTop, fRight, fBottom, fLeft, fBottom]);
}
else {
texturePosValues = new Float32Array([1, 0, 0, 0, 1, 1, 0, 1]);
}
var texturePosBuffer = this.texturePosBuffer;
gl.bindBuffer(gl.ARRAY_BUFFER, texturePosBuffer);
gl.bufferSubData(gl.ARRAY_BUFFER, 0, texturePosValues);
gl.bindBuffer(gl.ARRAY_BUFFER, null);
};
/**
* 释放显示资源
*/
RenderManager.prototype.SR_Destroy = function() {
var gl = this.contextGL;
var YUVProgram = this.YUVProgram;
gl.deleteProgram(YUVProgram);
var vertexPosBuffer = this.vertexPosBuffer;
var texturePosBuffer = this.texturePosBuffer;
gl.deleteBuffer(vertexPosBuffer);
gl.deleteBuffer(texturePosBuffer);
var yTextureRef = this.yTextureRef;
var uTextureRef = this.uTextureRef;
var vTextureRef = this.vTextureRef;
gl.deleteTexture(yTextureRef);
gl.deleteTexture(uTextureRef);
gl.deleteTexture(vTextureRef);
gl.getExtension('WEBGL_lose_context').loseContext();
};
return RenderManager;
}));

21
public/static/playctrl2/Decoder.js

File diff suppressed because one or more lines are too long

BIN
public/static/playctrl2/Decoder.wasm

Binary file not shown.

1
public/static/playctrl2/Decoder.worker.js

@ -1 +0,0 @@
"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}};

21
public/static/playctrl3/Decoder.js

File diff suppressed because one or more lines are too long

BIN
public/static/playctrl3/Decoder.wasm

Binary file not shown.

1
public/static/playctrl3/Decoder.worker.js

@ -1 +0,0 @@
"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}};

21
public/static/talk/AudioInterCom.js

File diff suppressed because one or more lines are too long

BIN
public/static/talk/AudioInterCom.wasm

Binary file not shown.

21
public/static/talkW/AudioInterCom.js

File diff suppressed because one or more lines are too long

BIN
public/static/talkW/AudioInterCom.wasm

Binary file not shown.

1
public/static/talkW/AudioInterCom.worker.js

@ -1 +0,0 @@
"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}};

6525
public/static/transform/libSystemTransform.js

File diff suppressed because it is too large

BIN
public/static/transform/libSystemTransform.wasm

Binary file not shown.

120
public/static/transform/systemTransform-worker.js

@ -1,120 +0,0 @@
importScripts('libSystemTransform.js');
const RECORDRTP = 0; //录制一份未经过转封装的码流原始数据,用于定位问题
let dataType = 1;
// 转封装库回调函数
self.STCallBack = function (fileIndex,indexLen, data, dataLen)
{
//stFrameInfo的类型见DETAIL_FRAME_INFO
let stFrameInfo = Module._GetDetialFrameInfo();
let nIsMp4Index = stFrameInfo.nIsMp4Index;
//console.log("FrameType is " , stFrameInfo);
//console.log("nIsMp4Index is " + nIsMp4Index);
//debugger
var pData = null;
pData = new Uint8Array(dataLen);
pData.set(Module.HEAPU8.subarray(data, data + dataLen));
if (dataType === 1) {
if (pData[0] == 0x49 && pData[1] == 0x4d && pData[2] == 0x4b && pData[3] == 0x48) {//码流头丢掉
return;
}
postMessage({type: "outputData", buf: pData, dType: 1});
dataType = 2;
} else {
if (nIsMp4Index) {
postMessage({type: "outputData", buf: pData, dType: 6}); //6:索引类型
} else {
postMessage({type: "outputData", buf: pData, dType: 2}); //2:码流
}
}
//stFrameInfo的类型见DETAIL_FRAME_INFO
//let stFrameInfo = Module._GetDetialFrameInfo();
//let stFrameType = stFrameInfo.nFrameType;
//let nFrameNum = stFrameInfo.nFrameNum;
//let nTimeStamp = stFrameInfo.nTimeStamp;
//let nIsMp4Index = stFrameInfo.nIsMp4Index;
//console.log("FrameType is " + stFrameType);
//console.log("nIsMp4Index is " + nIsMp4Index);
}
// self.Module = { memoryInitializerRequest: loadMemInitFile(), TOTAL_MEMORY: 128*1024*1024 };
// importScripts('SystemTransform.js');
self.Module['onRuntimeInitialized'] = function (){
postMessage({type: "loaded"});
}
onmessage = function (e) {
var data = e.data;
if ("create" === data.type) {
if (RECORDRTP) {
postMessage({type: "created"});
postMessage({type: "outputData", buf: data.buf, dType: 1});
} else {
var iHeadLen = data.len;
var pHead = Module._malloc(iHeadLen);
self.writeArrayToMemory(new Uint8Array(data.buf), pHead);
var iTransType = data.packType;//目标格式
var iRet = Module._CreatHandle(pHead, iTransType, 4096);
if (iRet != 0) {
console.log("_CreatHandle failed!" + iRet);
} else {
iRet = Module._SysTransRegisterDataCallBack();
if(iRet != 0)
{
console.log("_SysTransRegisterDataCallBack Failed:" + iRet);
}
iRet = Module._SysTransStart(null, null);
if(iRet != 0)
{
console.log("_SysTransStart Failed:" + iRet);
}
postMessage({type: "created"});
}
}
} else if ("inputData" === data.type) {
if (RECORDRTP) {
var aFileData = new Uint8Array(data.buf); // 拷贝一份
var iBufferLen = aFileData.length;
var szBufferLen = iBufferLen.toString(16);
if (szBufferLen.length === 1) {
szBufferLen = "000" + szBufferLen;
} else if (szBufferLen.length === 2) {
szBufferLen = "00" + szBufferLen;
} else if (szBufferLen.length === 3) {
szBufferLen = "0" + szBufferLen;
}
var aData = [0, 0, parseInt(szBufferLen.substring(0, 2), 16), parseInt(szBufferLen.substring(2, 4), 16)];
for(var iIndex = 0, iDataLength = aFileData.length; iIndex < iDataLength; iIndex++) {
aData[iIndex + 4] = aFileData[iIndex]
}
var dataUint8 = new Uint8Array(aData);
postMessage({type: "outputData", buf: dataUint8.buffer, dType: 2});
} else {
let pInputDataBuf = Module._malloc(data.len);
var idataLen = data.len;
self.writeArrayToMemory(new Uint8Array(data.buf), pInputDataBuf);
// 输入数据,每次最多2m
let pp = Module._SysTransInputData(0, pInputDataBuf, idataLen);
if(pp != 0) {
//console.log("InputData Failed:" + pp);
}
Module._free(pInputDataBuf);
}
} else if ("release" === data.type) {
var iRet = Module._SysTransStop();
if (iRet != 0) {
console.log("_SysTransStop Failed:", iRet);
}
Module._SysTransRelease();
if (iRet != 0) {
console.log("_SysTransRelease Failed:", iRet);
}
close();
}
};

2
public/static/web-control_1.2.5.min.js

File diff suppressed because one or more lines are too long

313
src/utils/h5player.min.js

File diff suppressed because one or more lines are too long

280
src/views/ty/index.vue

@ -41,14 +41,18 @@
</div>
<div class="center">
<div class="item">
<video style="width: 68%;margin-top: 0.3rem;height: 70%;margin-left: 0.3rem;" id="playWnd" autoplay></video>
<!-- v-for=" item in videoData" :key="item.key" -->
<!-- <div class="item" v-for=" item in videoData" :key="item.key">
<video style="width: 68%;margin-top: 0.3rem;height: 70%;margin-left: 0.3rem;" :id="item.key" autoplay></video>
</div> -->
<div class="item" style="position: relative;">
<video style="width: 68%;height: 70%;position: absolute;top: 0.3rem;left: 0.3rem;" id="camera0" autoplay></video>
</div>
<div class="item">
<video style="width: 68%;margin-top: 0.3rem;height: 70%;margin-left: 0.3rem;" id="playWnd2" autoplay></video>
<video style="width: 68%;margin-top: 0.3rem;height: 70%;margin-left: 0.3rem;" id="camera1" autoplay></video>
</div>
<div class="item">
<video style="width: 68%;margin-top: 0.3rem;height: 70%;margin-left: 0.3rem;" id="playWnd3" autoplay></video>
<video style="width: 68%;margin-top: 0.3rem;height: 70%;margin-left: 0.3rem;" id="camera2" autoplay></video>
</div>
</div>
@ -119,8 +123,13 @@ export default {
player: '',
videoUrl: 'rtmp://192.168.66.13:1935/live/openUrl/1OSHzLa/',
initCount: 0,
pubKey: '',
pubKey0: '',
pubKey1: '',
pubKey2: '',
oWebControl0: '',
oWebControl1: '',
oWebControl2: '',
videoData: []
};
},
@ -130,6 +139,8 @@ export default {
this.initPlugin();
this.initPlugin2();
this.initPlugin3();
// setTimeout(this.initPlugin2(), 1000);
// setTimeout(this.initPlugin3(), 1000);
});
@ -151,6 +162,7 @@ export default {
this.addNumber(0, 234098, 'insv3')
this.getVideo()
// if (flvjs.isSupported()) {
// let video = this.$refs.player
@ -711,6 +723,7 @@ export default {
let baseviodejson = this.decode2(baseviode)
var jsonParseJson = JSON.parse(baseviodejson);
console.log(jsonParseJson);
this.videoData = jsonParseJson
// this.day_num = tmpdata.day.noRepeatInNum
// this.week_num_num = tmpdata.week.noRepeatInNum
// this.mon_num = tmpdata.month.noRepeatInNum
@ -747,27 +760,28 @@ export default {
//
initPlugin() {
let _that = this;
const oWebControl = new window.WebControl({
szPluginContainer: 'playWnd', // id
const oWebControl0 = new window.WebControl({
szPluginContainer: 'camera0', // id
iServicePortStart: 15900, // 使
iServicePortEnd: 15900,
szClassId: '23BF3B0A-2C56-4D97-9C03-0CB103AA8F11', // IE10使ActiveXclsid
cbConnectSuccess() {
console.log('创建WebControl实例成功');
oWebControl.JS_StartService('window', {
oWebControl0.JS_StartService('window', {
// WebControl
dllPath: './VideoPluginConnect.dll', // "./VideoPluginConnect.dll"
})
.then(
() => {
// //
oWebControl.JS_SetWindowControlCallback({
//
cbIntegrationCallBack: _that.cbIntegrationCallBack,
});
oWebControl.JS_CreateWnd('playWnd').then(() => {
// oWebControl0.JS_SetWindowControlCallback({
// //
// cbIntegrationCallBack: _that.cbIntegrationCallBack,
// });
oWebControl0.JS_CreateWnd('camera0').then(() => {
//JS_CreateWnd
_that.init(); //
console.log('111111111');
});
},
@ -783,8 +797,8 @@ export default {
cbConnectError() {
// WebControl
console.log('xxx');
oWebControl = null;
$('#playWnd').html('插件未启动,正在尝试启动,请稍候...');
oWebControl0 = null;
$('#camera0').html('插件未启动,正在尝试启动,请稍候...');
window.WebControl.JS_WakeUp('VideoWebPlugin://'); // errorwakeup
this.initCount++;
if (this.initCount < 3) {
@ -792,43 +806,46 @@ export default {
this.initPlugin();
}, 3000);
} else {
$('#playWnd').html('插件启动失败,请检查插件是否安装!');
$('#camera0').html('插件启动失败,请检查插件是否安装!');
}
},
cbConnectClose(bNormalClose) {
// bNormalClose = false
// JS_DisconnectbNormalClose = true
console.log('cbConnectClose');
oWebControl = null;
oWebControl0 = null;
},
});
this.oWebControl2 = oWebControl;
this.oWebControl0 = oWebControl0;
},
initPlugin2() {
let _that = this;
const oWebControl = new window.WebControl({
szPluginContainer: 'playWnd2', // id
const oWebControl1 = new window.WebControl({
szPluginContainer: 'camera1', // id
iServicePortStart: 15900, // 使
iServicePortEnd: 15900,
szClassId: '23BF3B0A-2C56-4D97-9C03-0CB103AA8F11', // IE10使ActiveXclsid
cbConnectSuccess() {
console.log('创建WebControl实例成功');
oWebControl.JS_StartService('window', {
oWebControl1.JS_StartService('window', {
// WebControl
dllPath: './VideoPluginConnect.dll', // "./VideoPluginConnect.dll"
})
.then(
() => {
// //
oWebControl.JS_SetWindowControlCallback({
//
cbIntegrationCallBack: _that.cbIntegrationCallBack,
});
oWebControl.JS_CreateWnd('playWnd2').then(() => {
// oWebControl1.JS_SetWindowControlCallback({
// //
// cbIntegrationCallBack: _that.cbIntegrationCallBack,
// });
oWebControl1.JS_CreateWnd('camera1').then(() => {
//JS_CreateWnd
_that.init2(); //
console.log('22222222222');
});
}).catch((err) => {
console.log(err);
});;
},
() => {
//
@ -842,52 +859,55 @@ export default {
cbConnectError() {
// WebControl
console.log('xxx');
oWebControl = null;
$('#playWnd2').html('插件未启动,正在尝试启动,请稍候...');
oWebControl1 = null;
$('#camera1').html('插件未启动,正在尝试启动,请稍候...');
window.WebControl.JS_WakeUp('VideoWebPlugin://'); // errorwakeup
this.initCount++;
if (this.initCount < 3) {
setTimeout(function () {
this.initPlugin();
this.initPlugin2();
}, 3000);
} else {
$('#playWnd2').html('插件启动失败,请检查插件是否安装!');
$('#camera1').html('插件启动失败,请检查插件是否安装!');
}
},
cbConnectClose(bNormalClose) {
// bNormalClose = false
// JS_DisconnectbNormalClose = true
console.log('cbConnectClose');
oWebControl = null;
oWebControl1 = null;
},
});
this.oWebControl2 = oWebControl;
this.oWebControl1 = oWebControl1;
},
initPlugin3() {
let _that = this;
const oWebControl = new window.WebControl({
szPluginContainer: 'playWnd3', // id
const oWebControl2 = new window.WebControl({
szPluginContainer: 'camera2', // id
iServicePortStart: 15900, // 使
iServicePortEnd: 15900,
szClassId: '23BF3B0A-2C56-4D97-9C03-0CB103AA8F11', // IE10使ActiveXclsid
cbConnectSuccess() {
console.log('创建WebControl实例成功');
oWebControl.JS_StartService('window', {
oWebControl2.JS_StartService('window', {
// WebControl
dllPath: './VideoPluginConnect.dll', // "./VideoPluginConnect.dll"
})
.then(
() => {
// //
oWebControl.JS_SetWindowControlCallback({
//
cbIntegrationCallBack: _that.cbIntegrationCallBack,
});
oWebControl.JS_CreateWnd('playWnd3').then(() => {
// oWebControl2.JS_SetWindowControlCallback({
// //
// cbIntegrationCallBack: _that.cbIntegrationCallBack,
// });
oWebControl2.JS_CreateWnd('camera2').then(() => {
//JS_CreateWnd
_that.init3(); //
console.log('3333333333');
});
}).catch((err) => {
console.log(err);
});;
},
() => {
//
@ -901,31 +921,31 @@ export default {
cbConnectError() {
// WebControl
console.log('xxx');
oWebControl = null;
$('#playWnd3').html('插件未启动,正在尝试启动,请稍候...');
oWebControl2 = null;
$('#camera2').html('插件未启动,正在尝试启动,请稍候...');
window.WebControl.JS_WakeUp('VideoWebPlugin://'); // errorwakeup
this.initCount++;
if (this.initCount < 3) {
setTimeout(function () {
this.initPlugin();
this.initPlugin3();
}, 3000);
} else {
$('#playWnd3').html('插件启动失败,请检查插件是否安装!');
$('#camera2').html('插件启动失败,请检查插件是否安装!');
}
},
cbConnectClose(bNormalClose) {
// bNormalClose = false
// JS_DisconnectbNormalClose = true
console.log('cbConnectClose');
oWebControl = null;
oWebControl2 = null;
},
});
this.oWebControl2 = oWebControl;
this.oWebControl2 = oWebControl2;
},
//
init() {
let _that = this;
this.getPubKey(function () {
_that.getPubKey(function () {
//
var appkey = "29940726"; //appkey
var secret = _that.setEncrypt("SkTCnQdFbNW4Z2suNj8P"); //secret
@ -941,7 +961,7 @@ export default {
var showSmart = 1; //线0-0-
var buttonIDs = "0,16,256,257,258,259,260,512,513,514,515,516,517,768,769"; //
//
_that.oWebControl2.JS_RequestInterface({
_that.oWebControl0.JS_RequestInterface({
funcName: "init",
argument: JSON.stringify({
appkey: appkey, //APIappkey
@ -960,20 +980,21 @@ export default {
}),
})
.then((oData) => {
let width = document.querySelector("#playWnd").offsetWidth;
let height = document.querySelector("#playWnd").offsetHeight;
_that.oWebControl2.JS_Resize(width, height); // resize
let width = document.querySelector("#camera0").offsetWidth;
let height = document.querySelector("#camera0").offsetHeight;
_that.oWebControl0.JS_Resize(width, height); // resize
console.log(oData);
console.log(width,height);
_that.getVideoFun('05edddc148b141c5930301af43154942')
});
});
},
init2() {
let _that = this;
this.getPubKey(function () {
this.getPubKey2(function () {
//
var appkey = "29940726"; //appkey
var secret = _that.setEncrypt("SkTCnQdFbNW4Z2suNj8P"); //secret
var secret = _that.setEncrypt2("SkTCnQdFbNW4Z2suNj8P"); //secret
var ip = "192.168.66.13"; //IP
var playMode = 0; //0-1-
var port = 443; //HTTPS443
@ -986,8 +1007,8 @@ export default {
var showSmart = 1; //线0-0-
var buttonIDs = "0,16,256,257,258,259,260,512,513,514,515,516,517,768,769"; //
//
_that.oWebControl2.JS_RequestInterface({
funcName: "init2",
_that.oWebControl1.JS_RequestInterface({
funcName: "init",
argument: JSON.stringify({
appkey: appkey, //APIappkey
secret: secret, //APIsecret
@ -1005,20 +1026,21 @@ export default {
}),
})
.then((oData) => {
let width = document.querySelector("#playWnd2").offsetWidth;
let height = document.querySelector("#playWnd2").offsetHeight;
_that.oWebControl2.JS_Resize(width, height); // resize
let width2 = document.querySelector("#camera1").offsetWidth;
let height2 = document.querySelector("#camera1").offsetHeight;
_that.oWebControl1.JS_Resize(width2, height2); // resize
console.log(oData);
_that.getVideoFun('05edddc148b141c5930301af43154942')
console.log(width2,height2);
_that.getVideoFun2('05edddc148b141c5930301af43154942')
});
});
},
init3() {
let _that = this;
this.getPubKey(function () {
this.getPubKey3(function () {
//
var appkey = "29940726"; //appkey
var secret = _that.setEncrypt("SkTCnQdFbNW4Z2suNj8P"); //secret
var secret = _that.setEncrypt3("SkTCnQdFbNW4Z2suNj8P"); //secret
var ip = "192.168.66.13"; //IP
var playMode = 0; //0-1-
var port = 443; //HTTPS443
@ -1032,7 +1054,7 @@ export default {
var buttonIDs = "0,16,256,257,258,259,260,512,513,514,515,516,517,768,769"; //
//
_that.oWebControl2.JS_RequestInterface({
funcName: "init3",
funcName: "init",
argument: JSON.stringify({
appkey: appkey, //APIappkey
secret: secret, //APIsecret
@ -1050,16 +1072,18 @@ export default {
}),
})
.then((oData) => {
let width = document.querySelector("#playWnd3").offsetWidth;
let height = document.querySelector("#playWnd3").offsetHeight;
_that.oWebControl2.JS_Resize(width, height); // resize
let width3 = document.querySelector("#camera2").offsetWidth;
let height3 = document.querySelector("#camera2").offsetHeight;
_that.oWebControl2.JS_Resize(width3, height3); // resize
console.log(oData);
_that.getVideoFun('05edddc148b141c5930301af43154942')
console.log(width3,height3);
_that.getVideoFun3('05edddc148b141c5930301af43154942')
});
});
},
//
setCallbacks() {
console.log(this.oWebControl);
this.oWebControl.JS_SetWindowControlCallback({
cbIntegrationCallBack: this.cbIntegrationCallBack,
});
@ -1071,6 +1095,36 @@ export default {
},
//
getPubKey(callback) {
this.oWebControl0.JS_RequestInterface({
funcName: "getRSAPubKey",
argument: JSON.stringify({
keyLength: 1024,
}),
})
.then((oData) => {
if (oData.responseMsg.data) {
this.pubKey0 = oData.responseMsg.data;
console.log(this.pubKey0);
callback();
}
});
},
getPubKey2(callback) {
this.oWebControl1.JS_RequestInterface({
funcName: "getRSAPubKey",
argument: JSON.stringify({
keyLength: 1024,
}),
})
.then((oData) => {
if (oData.responseMsg.data) {
this.pubKey1 = oData.responseMsg.data;
console.log(this.pubKey1);
callback();
}
});
},
getPubKey3(callback) {
this.oWebControl2.JS_RequestInterface({
funcName: "getRSAPubKey",
argument: JSON.stringify({
@ -1079,8 +1133,8 @@ export default {
})
.then((oData) => {
if (oData.responseMsg.data) {
this.pubKey = oData.responseMsg.data;
console.log(this.pubKey);
this.pubKey2 = oData.responseMsg.data;
console.log(this.pubKey2);
callback();
}
});
@ -1088,9 +1142,19 @@ export default {
//RSA
setEncrypt(value) {
var encrypt = new window.JSEncrypt();
encrypt.setPublicKey(this.pubKey);
encrypt.setPublicKey(this.pubKey0);
return encrypt.encrypt(value);
},
setEncrypt2(value) {
var encrypt2 = new window.JSEncrypt();
encrypt2.setPublicKey(this.pubKey1);
return encrypt2.encrypt(value);
},
setEncrypt3(value) {
var encrypt3 = new window.JSEncrypt();
encrypt3.setPublicKey(this.pubKey2);
return encrypt3.encrypt(value);
},
//
getVideoFun(Code) {
//
@ -1102,7 +1166,7 @@ export default {
cameraIndexCode = cameraIndexCode.replace(/(^\s*)/g, "");
cameraIndexCode = cameraIndexCode.replace(/(\s*$)/g, "");
console.log(cameraIndexCode);
this.oWebControl2.JS_RequestInterface({
this.oWebControl0.JS_RequestInterface({
funcName: "startPreview",
argument: JSON.stringify({
cameraIndexCode: cameraIndexCode, //
@ -1124,9 +1188,73 @@ export default {
console.info(err)
});
},
getVideoFun2(Code) {
//
var cameraIndexCode = Code; //
var streamMode = 1; //0-1-
var transMode = 1; //0-UDP1-TCP
var gpuMode = 1; //GPU0-1-
var wndId = -1; //2x2
cameraIndexCode = cameraIndexCode.replace(/(^\s*)/g, "");
cameraIndexCode = cameraIndexCode.replace(/(\s*$)/g, "");
console.log(cameraIndexCode);
this.oWebControl1.JS_RequestInterface({
funcName: "startPreview",
argument: JSON.stringify({
cameraIndexCode: cameraIndexCode, //
streamMode: streamMode, //
transMode: transMode, //
gpuMode: gpuMode, //GPU
wndId: wndId, //
}),
})
.then((res) => {
//
console.log('播放成功111111111')
console.log(res);
},
err => {
console.log('播放失败')
console.log(preUrl);
// console.info('JS_Play failed:', err)
console.info(err)
});
},
getVideoFun3(Code) {
//
var cameraIndexCode = Code; //
var streamMode = 1; //0-1-
var transMode = 1; //0-UDP1-TCP
var gpuMode = 1; //GPU0-1-
var wndId = -1; //2x2
cameraIndexCode = cameraIndexCode.replace(/(^\s*)/g, "");
cameraIndexCode = cameraIndexCode.replace(/(\s*$)/g, "");
console.log(cameraIndexCode);
this.oWebControl2.JS_RequestInterface({
funcName: "startPreview",
argument: JSON.stringify({
cameraIndexCode: cameraIndexCode, //
streamMode: streamMode, //
transMode: transMode, //
gpuMode: gpuMode, //GPU
wndId: wndId, //
}),
})
.then((res) => {
//
console.log('播放成功22222222222')
console.log(res);
},
err => {
console.log('播放失败')
console.log(preUrl);
// console.info('JS_Play failed:', err)
console.info(err)
});
},
//
stopVideoFun() {
this.oWebControl2.JS_RequestInterface({
this.oWebControl0.JS_RequestInterface({
funcName: "stopAllPreview",
});
},
@ -1153,9 +1281,9 @@ export default {
},
},
beforeDestroy() {
this.player.destory();
}
// beforeDestroy() {
// this.player.destory();
// }
// },
};

Loading…
Cancel
Save