Socket
Socket
Sign inDemoInstall

bonc-htmlplayer

Package Overview
Dependencies
Maintainers
5
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bonc-htmlplayer - npm Package Compare versions

Comparing version 1.0.35 to 1.0.36

src/h265canvasplayer/audio.js

2

package.json
{
"name": "bonc-htmlplayer",
"version": "1.0.35",
"version": "1.0.36",
"description": "东方国信的html播放器内核",

@@ -5,0 +5,0 @@ "main": "./dist/BoncH5Player.js",

@@ -15,3 +15,4 @@ import Event from './util/event';

import H264Mp4Player from './h264player/player';
import H265CanvasPlayer from './h264canvasplayer/player';
import H265CanvasPlayer from './h265canvasplayer/player';
// import worker_script from './h265canvasplayer/decodeData';

@@ -53,2 +54,3 @@ window.MediaSource = window.MediaSource || window.WebKitMediaSource;

//实例化WebsocketUtil类
if (this.configs.multiServer) {

@@ -92,3 +94,3 @@ this.webSocketController = new TimeSelector(this);

// 如果是单个回放服务器
if(this.webSocketController instanceof WebSocketUtil){
if(this.openVideo instanceof WebSocketUtil){
this.recordInfo = dealRecordSearchInfo(jsondata);

@@ -178,3 +180,2 @@ // this.recordStartTime = recordInfo.recordStartTime;

this.playback = true;
console.log(BLoadXML)
let playBody = BLoadXML(xmlPlayBackSearch);

@@ -194,5 +195,2 @@ // console.log(new Date(xmljson[index].endTime).getTime() / 1000)

xmljson[index].GBSServerPort && (playBody.getElementsByTagName('GBSServerPort')[0].firstChild.nodeValue = xmljson[index].GBSServerPort);
item.xmlPlayBody = Xml2String(playBody);

@@ -209,3 +207,3 @@ item.url = 'ws://' + playBody.getElementsByTagName('StreamServerIP')[0].firstChild.nodeValue + ':' + playBody.getElementsByTagName('StreamServerPort')[0].firstChild.nodeValue;

console.log(new Date(xmljson.endTime).getTime() / 1000)
// console.log(new Date(xmljson.endTime).getTime() / 1000)
playBody.getElementsByTagName('EndTime')[0].firstChild.nodeValue = new Date(xmljson.endTime).getTime() / 1000;

@@ -242,2 +240,3 @@ playBody.getElementsByTagName('StartTime')[0].firstChild.nodeValue = new Date(xmljson.startTime).getTime() / 1000;

openVideo(jsonbonc) {
if (!jsonbonc && !this.jsonbonc) {

@@ -274,2 +273,5 @@ console.warn('通道数据不存在,请确定是否完成通道信息的获取')

}
//wuyage add
// this.worker = new Worker(worker_script);
// console.log('开启解码线程');
var playBody = BLoadXML(xmlPlayBody);

@@ -383,3 +385,3 @@ playBody.getElementsByTagName('DeviceType')[0].firstChild.nodeValue = jsonbonc.DeviceType;

playRecord(param) {
console.log('playRecord')
// console.log('playRecord')
this.reverse = false;

@@ -416,3 +418,4 @@ var playRecodrBody = BLoadXML(xmlPlayRecord)

*/
closeVideo(reason = 'normal', ifnew = true) {
closeVideo(reason = 'normal', ifnew = true)
{
if (!this.webSocketController.boncws) return;

@@ -433,2 +436,4 @@ if(this.webSocketController instanceof TimeSelector){

this.node && (this.node.src = '');
// console.log('关闭解码线程')
// this.worker.terminate();
this._player && this._player.destroy();

@@ -445,3 +450,3 @@

case 'H265CanvasPlayer':
this._player = new H264CanvasPlayer(this);
this._player = new H265CanvasPlayer(this);
break;

@@ -632,2 +637,8 @@ default:

videoBufferAdd(videoBuffer) {
// console.log('开始进入死循环')
// while (true){
//
// }
// console.log('退出死循环')
// this.H264Mp4Player.playBuffer(videoBuffer);

@@ -641,3 +652,11 @@ // this.H264CanvasPlayer.playBuffer(videoBuffer);

if(this._player){
//let worker = new Worker(H265CanvasPlayer);
// this.worker.postMessage(videoBuffer,[videoBuffer]);
// this.worker.addEventListener("error", function(evt){
// console.log("workerErrorLine #" + evt.lineno + " - " + evt.message + " in " + evt.filename);
// }, false);
// let dataTeime=new Date().getTime();
this._player.playBuffer(videoBuffer);
// let jiange=new Date().getTime()-dataTeime;
// console.log('视频解码playBuffer耗时:'+jiange+'\n' )
}else{

@@ -647,3 +666,8 @@ // debugger

this.makePlayer(codeType)
this._player.playBuffer(videoBuffer);
// this.worker.postMessage(videoBuffer);
// this.worker.addEventListener("error", function(evt){
// console.log("Line #" + evt.lineno + " - " + evt.message + " in " + evt.filename);
// }, false);
this._player.playBuffer(videoBuffer);
}

@@ -650,0 +674,0 @@

@@ -57,3 +57,3 @@ export default class ByteArray

}
return result;

@@ -70,3 +70,3 @@ }

}
return result;

@@ -84,3 +84,3 @@ }

}
return result;

@@ -138,4 +138,6 @@ }

}

@@ -24,3 +24,3 @@ import ByteArray from './ByteArray';

this.packageNum = 0;
this.whole = new Uint8Array(1400000)//分配100*1400个字节的内存空间用于存储收到的数据
this.whole = new Uint8Array(1400000)//分配100*1400个字节的内存空间用于存储收到的数据.unit8Array:8位无符号整数值的类型化数组。内容将初始化为 0
this.wholeOffset = 0;

@@ -39,2 +39,3 @@ this.start = false;

this.ifDispatchAudioError = true;
// this.addBuffCount=0;
}

@@ -56,6 +57,6 @@ controlCalBitRate() {

addDataPackage(e, type) {
// console.log("this.wholeOffset:"+this.wholeOffset)
//判断当前状态是否异常,并且不是第一个包,
if (this.packageState) {
// console.log('yichang')
// 数据异常
if (this.ifFirstPackage(e.data)) {

@@ -69,23 +70,6 @@ this.packageState = 0;

///test code begin
// var socketBA = new ByteArray(this.whole.buffer,this.wholeOffset);
// if(socketBA.bytesAvailable >=28)
// {
// let verbonc=socketBA.ReadUint32();//verbonc
// let company=socketBA.ReadUint32();//company
// let imsgType=socketBA.ReadUint32();////消息类型
// let linType=socketBA.ReadUint32();//指令类型
// let iCmdLen=socketBA.ReadUint32();//指令长度
// let allDataLength = socketBA.ReadUint32();//数据全长
// let leftField = socketBA.ReadUint32();//保留字段
// /// day rizhi
// console.log(imsgType,iCmdLen,linType,allDataLength)
// }
/// test code end
//处理message,判断包是否满了
//处理message,判断包是否满了(判断的标准是收到长度等于包长度)
if (this.ifFull(type)) {
//如果满了
//this.packageNum = 0;
// var socketBA= new ByteArray(this.templateDataQueue);
//this.whole.buffer获取此数组引用的 ArrayBuffer
var socketBA = new ByteArray(this.whole.buffer, this.wholeOffset);

@@ -96,3 +80,3 @@ let verbonc = socketBA.ReadUint32();//verbonc

let linType = socketBA.ReadUint32();//指令类型
let iCmdLen = socketBA.ReadUint32();//指令长度
let iCmdLen = socketBA.ReadUint32();//指令长度(包体的长度)
let allDataLength = socketBA.ReadUint32();//数据全长

@@ -105,4 +89,2 @@ let leftField = socketBA.ReadUint32();//保留字段

timestamp = socketBA.ReadInt53();
// console.log(timestamp);
// let nFlag=socketBA.ReadUint32(true);
let nFlag = socketBA.ReadUint16(true);// 1603代表视频 1604代表音频

@@ -156,2 +138,3 @@ let videoParam = socketBA.ReadUint16(true) //i帧抽帧的参数

}
// 判断数据类型是否改变
if (this.ifDispatchVideoType || this.codeType!==biClrUsed ) {

@@ -167,3 +150,2 @@ console.log("biClrUsed:"+biClrUsed);

this.app.dispatch('onGetVideoCode','H265');
this.app.dispatch('h265Info',{

@@ -185,6 +167,11 @@ videoCanvasHeight:biHeight,

// }
// 删除私有头,取视频的裸数据(h264或者h265)
var videoBuf = socketBA.SliceNewAB(biSizeImage);
if (this.ifDispatchBuf && this.ifDispatchBuf_h265) {
// let dataTeime=new Date().getTime();
this.app.dispatch('videoBufferAdd', videoBuf);
// let jiange=new Date().getTime()-dataTeime;
// console.log('videoBufferAdd推送数据耗时:'+jiange+'\n' )
// this.addBuffCount++;
// console.log("videoBufferAdd数据计数:"+this.addBuffCount)
} else {

@@ -419,8 +406,10 @@ console.log('丢弃')

} else {
// console.log('包没满')
//包没满当接收长度小于包长度时,不断的接收合并数据,直到接收到长度等于包长度才开始走ifFull方法,去解码。
//如果没满,看当前状态,如果状态正常,合并,如果异常,丢弃
if (!this.packageState) {// 0状态正常 1异常
//如果没满又来了第一包
if (this.ifFirstPackage(e.data)) {
console.log('目前接收的长度:',this.wholeOffset,'总长度:',this.ifFirstPackage(e.data));
console.log('没满又出了一包,指针回原点==>丢弃上一包,收集新的一包')
if (this.ifFirstPackage(e.data)) { //包未满的情况下会出现company !== 1112757248,此时只需合并即可。如果包未满的情况下出现了company == 1112757248,说明包没有满的情况下,又出现了一个新包,此时指针回原点
// console.log('目前接收总长度:',this.wholeOffset,'新数据长度:',this.ifFirstPackage(e.data));
// console.log('数据包未收全,出现新包头,指针回原点==>丢弃上一包,收集新的一包')
this.wholeOffset = 0;

@@ -430,4 +419,5 @@ }

this.packageNum++;
// console.log("this.packageNum:"+ this.packageNum)
} else {
//如果状态异常,判断这个包是不是第一个包
//如果状态异常,判断这个包是不是合法包
if(this.ifFirstPackage(e.data)){

@@ -437,2 +427,4 @@ this.wholeOffset = 0;

this.MergeBuffer(this.whole, e.data);
}else{
console.log('数据粘包,存在数据丢失')
}

@@ -449,5 +441,2 @@ return;

ifFull(type) {
// if(!this.templateDataQueue || !this.templateDataQueue.byteLength){
// return false;
// }
if (!this.wholeOffset) {

@@ -461,3 +450,2 @@ return false;

}
// let socketBA = new ByteArray(this.templateDataQueue);
let socketBA = new ByteArray(this.whole.buffer, this.wholeOffset)

@@ -471,21 +459,18 @@ let verbonc = socketBA.ReadUint32();//verbonc

let leftField = socketBA.ReadUint32();//保留字段
if (company !== 1112757248) {//'BST '
console.log('丢失第一包')
//this.templateDataQueue = new ArrayBuffer(0);
this.packageState = 1;
return false
}
// console.log('包满时company:'+company)
if(verbonc == 256){
if (socketBA.bytesAvailable < iCmdLen) {
if (socketBA.bytesAvailable < iCmdLen) { // 如果长度小于包长度,代表包未满,但并未异常,继续合并数据
// console.log("有效长度:"+socketBA.bytesAvailable+"小于包长:"+iCmdLen)
return false;
} else if (socketBA.bytesAvailable === iCmdLen) {
} else if (socketBA.bytesAvailable === iCmdLen) { //如果长度等于包长度,代表包满了。
// console.log("有效长度:"+socketBA.bytesAvailable+"等于包长:"+iCmdLen)
return true;
} else if (socketBA.bytesAvailable > iCmdLen) {
//console.warn('中间有丢包',this.packageNum)
//console.log(socketBA)
// debugger
console.log('包长度超过iCmdLen')
} else if (socketBA.bytesAvailable > iCmdLen) { //如果长度大于包长度,则视为异常,异常的同时判断是正常包继续合并,否则丢弃
// console.log("有效长度:"+socketBA.bytesAvailable+"超过包长:"+iCmdLen)
// console.log('已收数据超过iCmdLen')
this.packageState = 1;

@@ -506,5 +491,2 @@ return false

} else if (socketBA.bytesAvailable > iCmdLen+4) {
//console.warn('中间有丢包',this.packageNum)
//console.log(socketBA)
// debugger
console.log('包长度超过iCmdLen')

@@ -517,9 +499,6 @@ this.packageState = 1;

}
}
/**
* 判断这包数据是不是第一包
* 判断这包数据是不是第一包,判断的是这个包是否有效
* @param {ArrayBuffer} data

@@ -529,3 +508,3 @@ */

if (data.byteLength < 28) {
// console.log('出现了小于28字节的包');
console.log('出现了小于28字节的包');
return false;

@@ -543,4 +522,4 @@ }

let leftField = socketBA.ReadUint32();//保留字段
if (company !== 1112757248) {//'BST '
if (company !== 1112757248) {//'BST ' 只有当包满的时候company== 1112757248
// console.log('包未满ifFirstPackage:'+company)
return false;

@@ -562,2 +541,3 @@ } else {

try {
//源数组中的所有值都会被拷贝到目标数组中去。第一个参数是源数据;第二个参数是偏移量
whole.set(new Uint8Array(arr1), this.wholeOffset);

@@ -586,10 +566,2 @@ this.wholeOffset += arr1.byteLength;

}
export default SocketDataMerge;

@@ -45,3 +45,3 @@ export function appendByteArray(buffer1, buffer2)

* xml dom 对象转成字符串
* @param {object} xmlObject
* @param {object} xmlObject
*/

@@ -107,3 +107,3 @@ export function Xml2String(xmlObject)

}
return whole.buffer;

@@ -127,3 +127,3 @@ }

}
// 退出全屏

@@ -156,6 +156,6 @@ export function exitFullscreen() {

})
.then((jsonbonc)=> {
.then((jsonbonc)=> {
if(!jsonbonc.StreamServerIP){
throw new Error('错误')
}
}
this.jsonbonc=jsonbonc;

@@ -165,3 +165,3 @@ if(callback){

}
}).catch((e)=>{

@@ -182,6 +182,6 @@ console.error(e,'服务器错误')

})
.then((jsonbonc)=> {
.then((jsonbonc)=> {
if(!jsonbonc.StreamServerIP){
throw new Error('错误')
}
}
this.jsonbonc=jsonbonc;

@@ -191,3 +191,3 @@ if(callback){

}
}).catch((e)=>{

@@ -235,3 +235,3 @@ console.error(e,'服务器错误')

* 处理回放服务返回的录像信息对象
* @param {*} jsondata
* @param {*} jsondata
*/

@@ -244,3 +244,3 @@ export function dealRecordSearchInfo(jsondata){

recordEndTime = new Date(jsondata.Response.RecordList.Item[0].EndTime).getTime();
for (var i = 1; i < jsondata.Response.RecordList.Item.length; i++) {

@@ -250,3 +250,3 @@ var time0 = new Date(jsondata.Response.RecordList.Item[i].StartTime).getTime();

if (recordStartTime > time0) {
recordStartTime = time0;
recordStartTime = time0;
}

@@ -268,2 +268,2 @@ if (recordEndTime < time1) {

}
}
}

@@ -5,4 +5,2 @@ //对于传进来的configs中的各个值进行校验

const { videoId } = configs;
console.log("videoId:");
console.log(videoId)
if (!videoId || typeof videoId !== 'string') {

@@ -9,0 +7,0 @@ throw new Error("videoId配置出错");

@@ -120,5 +120,3 @@ import { xmlHeader, xmlHeartBody, xmlCloseBody, xmlPlayControl ,xmlPlayRecord} from './orderList';

sendBA.WriteString(strxml);
this.boncws.send(sendBA.GetArrayBuffer());
this.startHeartLiveInterval();

@@ -128,2 +126,3 @@ }

webSocketPlayBackOpen() {
this.finishSearch = false;

@@ -151,3 +150,2 @@ if (this.closed === true) {

this.boncws.send(sendBA.GetArrayBuffer());
this.startHeartLiveInterval();

@@ -253,2 +251,3 @@ }

WebSocketMessage(evt) {
// console.log('窗格号'+ this.app.configs.videoId+"," + '收到包数量:'+ packagenum++)

@@ -275,2 +274,3 @@ //console.time("str") //开始

WebSocketPlayBackMessage(evt) {
if (this.finishSearch) {

@@ -309,3 +309,2 @@ this.socketDataMerge.addDataPackage(evt, 'playback');

this.finishSearch = true;
this.app.dispatch('onRecordInfo', jsonData);

@@ -363,2 +362,3 @@ }

// console.log(this.boncws.readyState)
//websocket发送心跳消息
this.boncws.send(sendBA.GetArrayBuffer());

@@ -365,0 +365,0 @@ } catch (err) {

const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const copyPlugin = new CopyWebpackPlugin({
patterns:[
// {
// from :'./src/h264canvasplayer/libffmpeg_264_265.wasm',
// },
// {
// from :'./src/h264canvasplayer/libffmpeg_264_265.js',
// },
{
from :'./src/h264canvasplayer/libffmpeg_264_265.wasm',
},
{
from :'./src/h264canvasplayer/libffmpeg_264_265.js',
},
{
from :'./src/h264canvasplayer/h265Page',
from :'./src/h265canvasplayer/h265Page',
to:'./h265Page'

@@ -30,2 +30,2 @@ }

plugins:[copyPlugin]
}
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc