All Downloads are FREE. Search and download functionalities are using the official Maven repository.

static.lib.kurento-test.min.js Maven / Gradle / Ivy

Go to download

This project contains test cases for testing Kurento Java Client and Kurento Media Server.

There is a newer version: 6.18.0
Show newest version
function KurentoTest(){window.requestAnimationFrame=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame,this.x=0,this.y=0,this.colorInfo={},this.maxColorDistance=60,this.colorCheckRate=10,this.latencyVideoTagsId=null,this.latencyTime={},this.latency=0,this.firstLatency=!0,this.rtcStats={},this.rtcStatsRate=100,this.rtcStatsIntervalId={},this.initTime=new Date,this.sync=!1,this.syncTime=null,this.ocrActive=!1,this.ocrMap={},this.recordRTC=null,this.recordingData,this.videoEventValue=null}KurentoTest.prototype.syncTimeForOcr=function(e,t){var o=(new Date).getTime();this.syncTime=new Date(o+6e4),this.syncTime.setSeconds(0),this.syncTime.setMilliseconds(0);var n=this.syncTime.getTime()-o;console.info("Time wait for next exact minute: "+n+" ms");var r=this;setTimeout(function(){console.info("Sync finished"),r.sync=!0;var o=(new Date).getTime();r.getVideoTime(e,o),r.getStats(t,o),setInterval(function(){var o=(new Date).getTime();r.getVideoTime(e,o),r.getStats(t,o)},1e3)},n)},KurentoTest.prototype.startOcr=function(){console.info("Starting OCR"),this.ocrActive=!0},KurentoTest.prototype.endOcr=function(){console.info("Ending OCR"),this.ocrActive=!1},KurentoTest.prototype.getStats=function(peerConnectionId,time){if(this.ocrActive){var peerConnection=eval(peerConnectionId);eval("var localStream = peerConnection.getLocalStreams()[0];"),eval("var remoteStream = peerConnection.getRemoteStreams()[0];");var localVideoTrack=localStream?localStream.getVideoTracks()[0]:null,localAudioTrack=localStream?localStream.getAudioTracks()[0]:null,remoteVideoTrack=remoteStream?remoteStream.getVideoTracks()[0]:null,remoteAudioTrack=remoteStream?remoteStream.getAudioTracks()[0]:null;localStream?(kurentoTest.updateStats(peerConnection,localAudioTrack,"localAudio"),kurentoTest.updateStats(peerConnection,localVideoTrack,"localVideo")):remoteStream&&(kurentoTest.updateStats(peerConnection,remoteAudioTrack,"remoteAudio"),kurentoTest.updateStats(peerConnection,remoteVideoTrack,"remoteVideo"));for(var key in this.rtcStats)this.ocrMap[time][key]=this.rtcStats[key]}},KurentoTest.prototype.capitalize=function(e){return e.charAt(0).toUpperCase()+e.slice(1)},KurentoTest.prototype.getVideoTime=function(e,t){if(this.ocrActive){var o=document.getElementById(e),n=document.createElement("canvas"),r=n.getContext("2d");n.width=440,n.height=61,r.drawImage(o,40,15,440,61,0,0,440,61);var a=n.toDataURL("image/png").replace("image/png","image/octet-stream");this.ocrMap[t]={E2ELatencyMs:a}}},KurentoTest.prototype.checkColor=function(){for(var e=0;ethis.maxColorDistance}return!1},KurentoTest.prototype.activateOutboundRtcStats=function(e){this.activateRtcStats(e,"getLocalStreams","_outbound_")},KurentoTest.prototype.activateInboundRtcStats=function(e){this.activateRtcStats(e,"getRemoteStreams","_inbound_")},KurentoTest.prototype.activateRtcStats=function(peerConnection,streamFunction,suffix){var rate=this.rtcStatsRate;arguments.length&&(rate=arguments[0]),kurentoTest.rtcStatsIntervalId[peerConnection+streamFunction+suffix]=setInterval(this.updateRtcStats,rate,eval(peerConnection),streamFunction,suffix)},KurentoTest.prototype.updateRtcStats=function(peerConnection,streamFunction,suffix){eval("var remoteStream = peerConnection."+streamFunction+"()[0];");var videoTrack=remoteStream.getVideoTracks()[0],audioTrack=remoteStream.getAudioTracks()[0];kurentoTest.updateStats(peerConnection,videoTrack,"video_peerconnection"+suffix),kurentoTest.updateStats(peerConnection,audioTrack,"audio_peerconnection"+suffix)},KurentoTest.prototype.updateStats=function(e,t,o){e.getStats(function(e){var t=e.result()[2];t&&(kurentoTest.rtcStats[o+"timestamp"]=t.timestamp.getTime(),t.names().forEach(function(e){kurentoTest.rtcStats[o+e]=t.stat(e)}))},t)},KurentoTest.prototype.stopOutboundRtcStats=function(e){this.clearRtcStatsInterval(e,"getLocalStreams","_outbound_")},KurentoTest.prototype.stopInboundRtcStats=function(e){this.clearRtcStatsInterval(e,"getRemoteStreams","_inbound_")},KurentoTest.prototype.clearRtcStatsInterval=function(e,t,o){clearInterval(kurentoTest.rtcStatsIntervalId[e+t+o]),this.rtcStats={}},KurentoTest.prototype.setMaxColorDistance=function(e){this.maxColorDistance=e},KurentoTest.prototype.setColorCoordinates=function(e,t){this.x=e,this.y=t},KurentoTest.prototype.setColorCheckRate=function(e){this.colorCheckRate=e},KurentoTest.prototype.startRecording=function(e,t,o){var n="video/webm";"mp4"===o&&(n="video/mp4");var r="record-audio-and-video";if(t&&(r=t),"record-video"===r){var a={type:"video",mimeType:isChrome?null:n,disableLogs:!1,canvas:{width:320,height:240},frameInterval:20};this.recordRTC=RecordRTC(e,a),this.recordRTC.startRecording()}if("record-audio"===r){a={type:"audio",mimeType:n,bufferSize:0,sampleRate:44100,leftChannel:!1,disableLogs:!1,recorderType:StereoAudioRecorder};this.recordRTC=RecordRTC(e,a),this.recordRTC.startRecording()}if("record-audio-and-video"===r){if("undefined"==typeof MediaRecorder){this.recordRTC=[];var i={type:"audio",bufferSize:16384,sampleRate:44100,leftChannel:!1,disableLogs:!1,recorderType:StereoAudioRecorder},c=RecordRTC(e,i),s=RecordRTC(e,{type:"video",disableLogs:!1,canvas:{width:320,height:240},frameInterval:20});return s.initRecorder(function(){c.initRecorder(function(){c.startRecording(),s.startRecording()})}),void this.recordRTC.push(c,s)}a={type:"video",mimeType:isChrome?null:n,disableLogs:!1,getNativeBlob:!0};this.recordRTC=RecordRTC(e,a),this.recordRTC.startRecording()}},KurentoTest.prototype.stopRecording=function(){this.recordRTC?this.recordRTC.length?this.recordRTC[0].stopRecording(function(e){this.recordRTC[1]?this.recordRTC[1].stopRecording(function(e){console.info("[1] Recorded track: "+e)}):console.info("[0] Recorded track: "+e)}):this.recordRTC.stopRecording(function(e){console.info("Recorded track: "+e)}):console.warn("No recording found.")},KurentoTest.prototype.saveRecordingToDisk=function(e){if(this.recordRTC){var t=this.recordRTC.save(e);console.info(t)}else console.warn("No recording found.")},KurentoTest.prototype.openRecordingInNewTab=function(){this.recordRTC?window.open(this.recordRTC.toURL()):console.warn("No recording found.")},KurentoTest.prototype.recordingToData=function(){var e=this;if(e.recordRTC){var t=e.recordRTC.getBlob(),o=new window.FileReader;o.readAsDataURL(t),o.onloadend=function(){e.recordingData=o.result}}else console.warn("No recording found.")},KurentoTest.prototype.videoEvent=function(e){e||(e=window.event),kurentoTest.videoEventValue=e.type,console.info("videoEvent "+kurentoTest.videoEventValue);var t=document.getElementById("status");t&&(t.value=e.type)};var kurentoTest=new KurentoTest;




© 2015 - 2025 Weber Informatics LLC | Privacy Policy