绍兴公厕前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

0 lines
5.6 KiB

3 years ago
  1. "use strict";function receiveMessage(a){var b=a.data;switch(channelId=a.data.channelId,b.type){case"sdpInfo":sdpInfo=b.data,framerate=0,setVideoRtpSession(sdpInfo);break;case"MediaData":if(isStepPlay===!0){buffering(b);break}videoCHID=b.data.rtspInterleave[1],"undefined"!=typeof videoRtpSessionsArray[videoCHID]&&videoRtpSessionsArray[videoCHID].parseRTPData(b.data.rtspInterleave,b.data.payload,isBackupCommand,dropout,b.info);break;case"initStartTime":videoRtpSessionsArray[videoCHID].initStartTime()}}function setVideoRtpSession(a){videoRtpSessionsArray=[],isStepPlay=!1;for(var b=0;b<a.sdpInfo.length;b++)rtpSession=null,decodeMode=a.decodeMode,"H264"===a.sdpInfo[b].codecName?(null===h264Session&&(h264Session=H264Session()),rtpSession=h264Session,rtpSession.init(a.decodeMode),rtpSession.setFramerate(a.sdpInfo[b].Framerate),rtpSession.setGovLength(a.govLength),rtpSession.setCheckDelay(a.checkDelay)):"H265"===a.sdpInfo[b].codecName?(null===h265Session&&(h265Session=H265Session()),rtpSession=h265Session,rtpSession.init(),rtpSession.setFramerate(a.sdpInfo[b].Framerate),rtpSession.setGovLength(a.govLength),rtpSession.setCheckDelay(a.checkDelay)):"JPEG"===a.sdpInfo[b].codecName?(null===mjpegSession&&(mjpegSession=MjpegSession()),rtpSession=mjpegSession,rtpSession.init(),rtpSession.setFramerate(a.sdpInfo[b].Framerate)):"stream-assist-frame"===a.sdpInfo[b].codecName&&(debug.log(a.sdpInfo[b]),null===ivsSession&&(ivsSession=IvsSession()),rtpSession=ivsSession,rtpSession.init()),"undefined"!=typeof a.sdpInfo[b].Framerate&&(framerate=a.sdpInfo[b].Framerate),null!==rtpSession&&(rtpSession.setBufferfullCallback(BufferFullCallback),rtpSession.setReturnCallback(RtpReturnCallback),videoCHID=a.sdpInfo[b].RtpInterlevedID,videoRtpSessionsArray[videoCHID]=rtpSession)}function buffering(a){videoCHID=a.data.rtspInterleave[1],"undefined"!=typeof videoRtpSessionsArray[videoCHID]&&videoRtpSessionsArray[videoCHID].bufferingRtpData(a.data.rtspInterleave,a.data.header,a.data.payload)}function BufferFullCallback(){videoRtpSessionsArray[videoCHID].findCurrent(),sendMessage("stepPlay","BufferFull")}function RtpReturnCallback(a){var b=null,c=null;if(null===a||"undefined"==typeof a)return b=null,void(c=null);if("undefined"!=typeof a.error?(sendMessage("error",a.error),b=a.decodedData):(b=a.decodedData,null!==a.decodeMode&&"undefined"!=typeof a.decodeMode&&(decodeMode=a.decodeMode,sendMessage("setVideoTagMode",a.decodeMode))),null!=a.decodeStart&&(sendMessage("DecodeStart",a.decodeStart),decodeMode=a.decodeStart.decodeMode),null!==b&&"undefined"!=typeof b)if(null!==b.frameData&&"canvas"===decodeMode){b.frameData.firstFrame===!0&&sendMessage("firstFrame",b.frameData.firstFrame);var d={bufferIdx:b.frameData.bufferIdx,width:b.frameData.width,height:b.frameData.height,codecType:b.frameData.codecType,frameType:b.frameData.frameType,timeStamp:null};null!==b.timeStamp&&"undefined"!=typeof b.timeStamp&&(d.timeStamp=b.timeStamp),sendMessage("videoInfo",d),"undefined"!=typeof b.frameData.data&&null!==b.frameData.data&&sendMessage("canvasRender",b.frameData.data)}else if(null!==b.frameData&&"video"===decodeMode){null!==b.initSegmentData&&(sendMessage("codecInfo",b.codecInfo),sendMessage("initSegment",b.initSegmentData));var d={codecType:b.frameData.codecType};"undefined"!=typeof b.frameData.width&&(d.width=b.frameData.width,d.height=b.frameData.height),sendMessage("videoInfo",d),sendMessage("videoTimeStamp",b.timeStamp),b.frameData.length>0&&(sendMessage("mediaSample",b.mediaSample),sendMessage("videoRender",b.frameData))}else sendMessage("drop",a.decodedData);null!=a.resolution&&sendMessage("MSEResolutionChanged",a.resolution),null!=a.ivsDraw&&sendMessage("ivsDraw",a)}function sendMessage(a,b){var c={type:a,data:b,channelId:channelId};"canvasRender"===a?postMessage(c,[b.buffer]):postMessage(c)}function VideoBufferList(){function a(){b=360,c=240,d=null,this._length=0,this.head=null,this.tail=null,this.curIdx=0}var b=0,c=0,d=null;return a.prototype={push:function(a,b,e,f,g,h){var i=new VideoBufferNode(a,b,e,f,g,h);return this._length>0?(this.tail.next=i,i.previous=this