ss.js
10.0 KB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.share=t():e.share=t()}(this,function(){return function(e){function t(n){if(_[n])return _[n].exports;var a=_[n]={exports:{},id:n,loaded:!1};return e[n].call(a.exports,a,a.exports,t),a.loaded=!0,a.exports}var _={};return t.m=e,t.c=_,t.p="",t(0)}([function(e,t,_){e.exports=_(2)},function(e,t){"use strict";function _(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var _=0;_<t.length;_++){var n=t[_];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,_,n){return _&&e(t.prototype,_),n&&e(t,n),t}}(),a=function(){function e(){_(this,e),this.MAPS={}}return n(e,[{key:"on",value:function(e,t){if(e&&t){var _=this.MAPS[e];if(!_)return this.MAPS[e]=[t];_.push(t)}}},{key:"off",value:function(e,t){if(e){var _=this.MAPS[e];if(_){if(t)return _.splice(_.indexOf(t),1);_.length=0}}}},{key:"emit",value:function(e,t){if(e){var _=this.MAPS["*"];_&&_.length&&_.forEach(function(_){_(e,t)});var n=this.MAPS[e];n&&n.length&&n.forEach(function(e){e(t)})}}}]),e}();t.default=a},function(e,t,_){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function a(e){var t,_,n,a;n=e.length,t=new Uint8Array(3*n);var r=0;for(_=0;_<n;_++)a=e.charCodeAt(_),a>=1&&a<=127?t[r++]=a:a>2047?(t[r++]=224|a>>12&15,t[r++]=128|a>>6&63,t[r++]=128|a>>0&63):(t[r++]=192|a>>6&31,t[r++]=128|a>>0&63);return new Uint8Array(t.buffer,0,r)}function r(e){var t,_,n,a,r,o;for(t="",n=e.length,_=0;_<n;)switch(a=e[_++],a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:t+=String.fromCharCode(a);break;case 12:case 13:r=e[_++],t+=String.fromCharCode((31&a)<<6|63&r);break;case 14:r=e[_++],o=e[_++],t+=String.fromCharCode((15&a)<<12|(63&r)<<6|(63&o)<<0)}return t}function o(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",_=new Object;if(_.data_len=0,_.data="",_.name=e,"mov_start"==e)_.type=1;else if("mov_stop"==e)_.type=2;else if("mov_pause"==e){if(_.type=3,pos=t,pos.length>0){_.data_len=4;var n=new ArrayBuffer(_.data_len),r=new Uint32Array(n,0,1);r[0]=parseInt(pos),_.data=new Uint8Array(n,0,4)}}else if("mov_resume"==e)_.type=4;else if("mov_seek"==e){if(_.type=5,pos=t,pos.length>0){_.data_len=4;var n=new ArrayBuffer(_.data_len),r=new Uint32Array(n,0,1);r[0]=parseInt(pos),_.data=new Uint8Array(n,0,4)}}else if("ss_start"==e)_.type=6,_.data=a(t),_.data_len=_.data.length;else if("ss_stop"==e)_.type=7;else if("ss_version"==e)_.type=14;else if("get_mic"==e)_.type=26;else{if("ds_start"==e){_.type=27,_.data_len=536;var n=new ArrayBuffer(_.data_len),o=new Uint32Array(n,0,6);coordstr=t;var i=coordstr.split(",");if(4!=i.length)return;o[0]=parseInt(i[0]),o[1]=parseInt(i[1]),o[2]=parseInt(i[2]),o[3]=parseInt(i[3]);var s=new Uint8Array(n,24,256);window_name=t;for(var S=a(window_name),E=0;E<S.length;E++)s[E]=S[E];o[4]=S.length,o[5]=0;new Uint8Array(n,280,256);return _.data=new Uint8Array(n,0,_.data_len),void A(_)}if("ds_stop"==e)_.type=28;else{if("aud_start"==e){_.type=29,_.data_len=520;var n=new ArrayBuffer(_.data_len),l=new Uint32Array(n,0,1),C=t;l[0]=C.length;var f=new Uint32Array(n,4,1);f[0]=0;for(var c=new Uint8Array(n,8,256),O=a(C),E=0;E<O.length;E++)c[E]=O[E];new Uint8Array(n,264,256);return _.data=new Uint8Array(n,0,_.data_len),void A(_)}if("aud_stop"==e)_.type=30;else if("get_cam"==e)_.type=41;else{if("cam_start"==e){_.type=42,_.data_len=520;var n=new ArrayBuffer(_.data_len),I=new Uint32Array(n,0,1),T=t;I[0]=T.length;var f=new Uint32Array(n,4,1);f[0]=0;for(var U=new Uint8Array(n,8,256),u=a(T),E=0;E<u.length;E++)U[E]=u[E];new Uint8Array(n,264,256);return _.data=new Uint8Array(n,0,_.data_len),void A(_)}"cam_stop"==e?_.type=43:"set_videoparam"==e?(_.type=46,_.data=a(t),_.data_len=_.data.length):"get_videoparam"==e?(_.type=47,_.data=a(t),_.data_len=_.data.length):"start_record"==e?(_.type=48,_.data=a(t),_.data_len=_.data.length):"stop_record"==e?(_.type=49,_.data=a(t),_.data_len=_.data.length):"start_push"==e?(_.type=50,_.data=a(t),_.data_len=_.data.length):"stop_push"==e?(_.type=51,_.data=a(t),_.data_len=_.data.length):"get_rtmp_port"==e?_.type=52:"set_mic_vol"==e?(_.type=53,_.data=a(t),_.data_len=_.data.length):"get_mic_vol"==e&&(_.type=54)}}}A(_)}function A(e){var t=8+e.data_len,_=new ArrayBuffer(t),n=new Uint16Array(_,0,1),a=new Uint8Array(_,2,1),r=new Uint32Array(_,4,1);if(n[0]=e.type,a[0]=0,r[0]=e.data_len,e.data_len>0)for(var o=new Uint8Array(_,8,e.data_len),A=0;A<e.data_len;A++)o[A]=e.data[A];R&&R.send(_)}function i(){try{R&&(R.close(),R=R.onopen=R.onclose=R.onerror=R.onmessage=null,C.emit(C.CLOSE))}catch(e){console.log(e)}}function s(){i()}function S(){R&&i(),R=new WebSocket("ws://"+p+":"+L),g=setTimeout(function(){clearTimeout(g),i()},1500),R.timeout=1500,R.binaryType="arraybuffer",R.onopen=function(){clearTimeout(g),o("get_rtmp_port"),o("get_mic"),o("get_cam"),o("get_mic_vol"),C.emit(C.OPEN)},R.onclose=function(){i()},R.onerror=function(){i()},R.onmessage=function(e){var t=e.data;if("string"==typeof e.data)console.log("on message [string] ignore.");else{var _=new DataView(t),n=_.getUint16(0,!0);console.log("onmessage code->",n);var a=(_.getUint8(2,!0),_.getUint32(4,!0));if(n>=0&&n<f.length){f[n]}if(0==n||6==n||8==n)console.log("mov_start,mov_pause,mov_seek success");else if(10==n){if(a>36){var o=new Uint32Array(t,8,8),A="width:"+o[0]+" height:"+o[1];A="framerate:"+o[2]+" duration:"+o[3],A="playpos:"+o[4]+" filesize:"+o[5],c=A;var i=o[6],s=new Uint8Array(t,40,i),S=r(s);c.filename=S,C.emit(C.MOVIE_INFO_CHANGE,c)}}else if(11==n)console.log("ss_start success"),C.emit(C.SS_START);else if(24<=n&&26>=n){if(a>=4){var E=_.getUint32(8,!0);O=E.toString(),C.emit(C.VERSION_INFO_CHANGE,O)}}else if(55==n)console.log("ds_start success");else if(59==n)console.log("as start success");else if(83==n){if(console.log("get camera sucess"),a>4){var l=_.getUint32(8,!0),R=12;I.length=0;for(var p=0;p<l;p++){var L=_.getUint32(R,!0);R+=4;var g=new Uint8Array(t,R,L-1);R+=L;var y=r(g);I.push(y)}C.emit(C.CAMERA_INFO_CHANGE,I)}}else if(53==n){if(a>4){var v=_.getUint32(8,!0),R=12;T.length=0;for(var p=0;p<v;p++){var M=_.getUint32(R,!0);R+=4;var P=new Uint8Array(t,R,M-1);R+=M;var y=r(P);T.push(y)}C.emit(C.MIC_INFO_CHANGE,T)}}else if(85==n)console.log("cam_share success");else if(95==n){console.log("get_videoparam success");var N=new Uint8Array(t,8,t.byteLength-8-1),y=r(N);U=y,C.emit(C.VIDEO_INFO_CHANGE,U)}else if(105==n){console.log("get_rtmp_port_success");var N=new Uint8Array(t,8,t.byteLength-8-1),y=r(N);u=y,C.emit(C.RTMP_PORT_CHANGE,u)}else if(109==n){console.log("get_mic_vol success");var N=new Uint8Array(t,8,t.byteLength-8-1),y=r(N);d=y,C.emit(C.MIC_VOL_CHANGE,d)}else if(111<=n&&114>=n){var N=new Uint8Array(t,8,t.byteLength-8),V=r(N);console.log("url->",V)}else if(13==n)C.emit(C.SS_STOP);else{var N=new Uint8Array(t,8,t.byteLength-8),y=r(N);console.log("data ->",y)}}}}Object.defineProperty(t,"__esModule",{value:!0});var E=_(1),l=n(E),C=new l.default,f=["MOV_START_SUC","MOV_START_FAIL","MOV_STOP_SUC","MOV_STOP_FAIL","MOV_PAUSE_SUC","MOV_PAUSE_FAIL","MOV_RESUME_SUC","MOV_RESUME_FAIL","MOV_SEEK_SUC","MOV_SEEK_FAIL","MOV_PROPERTY","SS_START_SUC","SS_START_FAIL","SS_STOP_SUC","SS_STOP_FAIL","REC_START_SUC","REC_START_FAIL","REC_STOP_SUC","REC_STOP_FAIL","REC_PAUSE_SUC","REC_PAUSE_FAIL","REC_RESUME_SUC","REC_RESUME_FAIL","MOV_PLAY_FINISH","MOV_VERSION","SS_VERSION","REC_VERSION","MOV_SELECT_FILE_CANCEL","QAV_LOGIN_SUC","QAV_LOGIN_FAIL","QAV_LOGOUT_SUC","QAV_LOGOUT_FAIL","QAV_ENTERROOM_SUC","QAV_ENTERROOM_FAIL","QAV_LEAVEROOM_SUC","QAV_LEAVEROOM_FAIL","QAV_OPEN_MIC_SUC","QAV_OPEN_MIC_FAIL","QAV_OPEN_MIC_NODEV","QAV_CLOSE_MIC_SUC","QAV_CLOSE_MIC_FAIL","QAV_CLOSE_MIC_NODEV","QAV_OPEN_PLAYER_SUC","QAV_OPEN_PLAYER_FAIL","QAV_OPEN_PLAYER_NODEV","QAV_CLOSE_PLAYER_SUC","QAV_CLOSE_PLAYER_FAIL","QAV_CLOSE_PLAYER_NODEV","QAV_MUTE_AUDIO_SUC","QAV_MUTE_AUDIO_FAIL","QAV_UNMUTE_AUDIO_SUC","QAV_UNMUTE_AUDIO_FAIL","REC_SAVE_FILE_CANCEL","GET_MIC_SUC","GET_MIC_FAIL","DS_START_SUC","DS_START_FAIL","DS_STOP_SUC","DS_STOP_FAIL","AUD_START_SUC","AUD_START_FAIL","AUD_STOP_SUC","AUD_STOP_FAIL","AUD_DATA","SS_DATA","MOV_DATA","PEN_START_SUC","PEN_START_FAIL","PEN_STOP_SUC","PEN_STOP_FAIL","PEN_VERSION","QAV_DEVICE_SUC","QAV_DEVICE_FAIL","CBD_QUERY_SUC","CBD_QUERY_FAIL","CBD_GET_SUC","CBD_GET_FAIL","FILE_GET_SUC","FILE_GET_FAIL","FILE_SET_SUC","FILE_SET_FAIL","RESTART_SUC","RESTART_FAIL","GET_CAM_SUC","GET_CAM_FAIL","CAM_START_SUC","CAM_START_FAIL","CAM_STOP_SUC","CAM_STOP_FAIL","SWITCH_SCENE_SUC","SWITCH_SCENE_FAIL","PUSH_STREAM_FAIL","SHOW_UI_SUC","SET_VIDEO_PARAM_SUC","SET_VIDEO_PARAM_FAIL","GET_VIDEO_PARAM_SUC","GET_VIDEO_PARAM_FAIL","START_RECORD_SUC","START_RECORD_FAIL","STOP_RECORD_SUC","STOP_RECORD_FAIL","START_PUSH_SUC","START_PUSH_FAIL","STOP_PUSH_SUC","STOP_PUSH_FAIL","GET_RTMP_PORT_SUC","GET_RTMP_PORT_FAIL","SET_MIC_VOL_SUC","SET_MIC_VOL_FAIL","GET_MIC_VOL_SUC","GET_MIC_VOL_FAIL","RTMP_CONNECTING","RTMP_CONNECT_SUC","RTMP_CONNECT_FAIL","RTMP_CONNECT_CLOSED"],c=null,O="",I=[],T=[],U="",u="",d="",R=null,p="127.0.0.1",L=8090,g=0;C.infos={movieInfo:c,versionInfo:O,cameraInfo:I,micInfo:T,videoInfo:U,rtmpPort:u,micVol:d},C.MOVIE_INFO_CHANGE="MOVIE_INFO_CHANGE",C.VERSION_INFO_CHANGE="VERSION_INFO_CHANGE",C.CAMERA_INFO_CHANGE="CAMERA_INFO_CHANGE",C.MIC_INFO_CHANGE="MIC_INFO_CHANGE",C.VIDEO_INFO_CHANGE="VIDEO_INFO_CHANGE",C.RTMP_PORT_CHANGE="RTMP_PORT_CHANGE",C.MIC_VOL_CHANGE="MIC_VOL_CHANGE",C.SS_START="SS_START",C.SS_STOP="SS_STOP",C.OPEN="OPEN",C.CLOSE="CLOSE",C.ERROR="ERROR",C.getRTMPPort=function(){o("get_rtmp_port")},C.getMicInfo=function(){o("get_mic")},C.getCamInfo=function(){o("get_cam")},C.getMicVol=function(){o("get_mic_vol")},C.start=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"127.0.0.1",t=arguments[1];p=e,L=t,S()},C.stop=function(){s()},C.startShareScreen=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";o("ss_start",e)},C.stopShareScreen=function(){o("ss_stop")},t.default=C}])});