screenShare.js 13.0 KB
!function(e,_){"object"==typeof exports&&"object"==typeof module?module.exports=_():"function"==typeof define&&define.amd?define([],_):"object"==typeof exports?exports.share=_():e.share=_()}(this,function(){return function(e){function _(n){if(r[n])return r[n].exports;var t=r[n]={exports:{},id:n,loaded:!1};return e[n].call(t.exports,t,t.exports,_),t.loaded=!0,t.exports}var r={};return _.m=e,_.c=r,_.p="",_(0)}([function(e,_,r){e.exports=r(2)},function(e,_){"use strict";function r(e,_){if(!(e instanceof _))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(_,"__esModule",{value:!0});var n=function(){function e(e,_){for(var r=0;r<_.length;r++){var n=_[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(_,r,n){return r&&e(_.prototype,r),n&&e(_,n),_}}(),t=function(){function e(){r(this,e),this.MAPS={}}return n(e,[{key:"on",value:function(e,_){if(e&&_){var r=this.MAPS[e];if(!r)return this.MAPS[e]=[_];r.push(_)}}},{key:"off",value:function(e,_){if(e){var r=this.MAPS[e];if(r){if(_)return r.splice(r.indexOf(_),1);r.length=0}}}},{key:"emit",value:function(e,_){if(e){var r=this.MAPS["*"];r&&r.length&&r.forEach(function(r){r(e,_)});var n=this.MAPS[e];n&&n.length&&n.forEach(function(e){e(_)})}}}]),e}(),a=t;_.default=a;(function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(t,"Emiter","E:/WorkGround/xuedianyun/h5Project/screenshare/src/Emiter.js"),__REACT_HOT_LOADER__.register(a,"default","E:/WorkGround/xuedianyun/h5Project/screenshare/src/Emiter.js"))})()},function(e,_,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function t(e){var _,r,n,t;n=e.length,_=new Uint8Array(3*n);var a=0;for(r=0;r<n;r++)t=e.charCodeAt(r),t>=1&&t<=127?_[a++]=t:t>2047?(_[a++]=224|t>>12&15,_[a++]=128|t>>6&63,_[a++]=128|t>>0&63):(_[a++]=192|t>>6&31,_[a++]=128|t>>0&63);return new Uint8Array(_.buffer,0,a)}function a(e){var _,r,n,t,a,s;for(_="",n=e.length,r=0;r<n;)switch(t=e[r++],t>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:_+=String.fromCharCode(t);break;case 12:case 13:a=e[r++],_+=String.fromCharCode((31&t)<<6|63&a);break;case 14:a=e[r++],s=e[r++],_+=String.fromCharCode((15&t)<<12|(63&a)<<6|(63&s)<<0)}return _}function s(e){var _=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";console.log("sendCommand->",e);var r=new Object;if(r.data_len=0,r.data="",r.name=e,"mov_start"==e)r.type=1;else if("mov_stop"==e)r.type=2;else if("mov_pause"==e){if(r.type=3,pos=_,pos.length>0){r.data_len=4;var n=new ArrayBuffer(r.data_len),a=new Uint32Array(n,0,1);a[0]=parseInt(pos),r.data=new Uint8Array(n,0,4)}}else if("mov_resume"==e)r.type=4;else if("mov_seek"==e){if(r.type=5,pos=_,pos.length>0){r.data_len=4;var n=new ArrayBuffer(r.data_len),a=new Uint32Array(n,0,1);a[0]=parseInt(pos),r.data=new Uint8Array(n,0,4)}}else if("ss_start"==e)r.type=6,r.data=t(_),r.data_len=r.data.length;else if("ss_stop"==e)r.type=7;else if("ss_version"==e)r.type=14;else if("get_mic"==e)r.type=26;else{if("ds_start"==e){r.type=27,r.data_len=536;var n=new ArrayBuffer(r.data_len),s=new Uint32Array(n,0,6);coordstr=_;var i=coordstr.split(",");if(4!=i.length)return;s[0]=parseInt(i[0]),s[1]=parseInt(i[1]),s[2]=parseInt(i[2]),s[3]=parseInt(i[3]);var A=new Uint8Array(n,24,256);window_name=_;for(var E=t(window_name),c=0;c<E.length;c++)A[c]=E[c];s[4]=E.length,s[5]=0;new Uint8Array(n,280,256);return r.data=new Uint8Array(n,0,r.data_len),void o(r)}if("ds_stop"==e)r.type=28;else{if("aud_start"==e){r.type=29,r.data_len=520;var n=new ArrayBuffer(r.data_len),u=new Uint32Array(n,0,1),O=_;console.log("sel_mic_name",_),u[0]=O.length;var C=new Uint32Array(n,4,1);C[0]=0;for(var l=new Uint8Array(n,8,256),S=t(O),c=0;c<S.length;c++)l[c]=S[c];new Uint8Array(n,264,256);return r.data=new Uint8Array(n,0,r.data_len),void o(r)}if("aud_stop"==e)r.type=30;else if("get_cam"==e)r.type=41;else{if("cam_start"==e){r.type=42,r.data_len=520;var n=new ArrayBuffer(r.data_len),T=new Uint32Array(n,0,1),d=_;T[0]=d.length;var C=new Uint32Array(n,4,1);C[0]=0;for(var f=new Uint8Array(n,8,256),R=t(d),c=0;c<R.length;c++)f[c]=R[c];new Uint8Array(n,264,256);return r.data=new Uint8Array(n,0,r.data_len),void o(r)}if("cam_stop"==e)r.type=43;else if("set_videoparam"==e)r.type=46,r.data=t(_),r.data_len=r.data.length;else if("get_videoparam"==e)r.type=47,r.data=t(_),r.data_len=r.data.length;else if("start_record"==e)r.type=48,r.data=t(_),r.data_len=r.data.length;else if("stop_record"==e)r.type=49,r.data=t(_),r.data_len=r.data.length;else if("start_push"==e){r.type=50;document.getElementById("start_push_input");console.log("start_push","video=scr audio=mic "+_),r.data=t("video=scr audio=mic "+_),r.data_len=r.data.length}else"stop_push"==e?(r.type=51,r.data=t(_),r.data_len=r.data.length):"get_rtmp_port"==e?r.type=52:"set_mic_vol"==e?(r.type=53,r.data=t(_),r.data_len=r.data.length):"get_mic_vol"==e&&(r.type=54)}}}o(r)}function o(e){var _=8+e.data_len,r=new ArrayBuffer(_),n=new Uint16Array(r,0,1),t=new Uint8Array(r,2,1),a=new Uint32Array(r,4,1);if(n[0]=e.type,t[0]=0,a[0]=e.data_len,e.data_len>0)for(var s=new Uint8Array(r,8,e.data_len),o=0;o<e.data_len;o++)s[o]=e.data[o];L&&L.send(r)}function i(){try{L&&(L.close(),L=L.onopen=L.onclose=L.onerror=L.onmessage=null,O.emit(O.CLOSE))}catch(e){console.log(e)}}function A(){i()}function E(){L&&i(),L=new WebSocket(y),clearTimeout(m),m=setTimeout(function(){clearTimeout(m),i()},1500),L&&(L.timeout=1500,L.binaryType="arraybuffer",L.onopen=function(){clearTimeout(m),s("get_rtmp_port"),s("get_mic"),s("get_cam"),s("get_mic_vol"),O.emit(O.OPEN)},L.onclose=function(){i()},L.onerror=function(){i()},L.onmessage=function(e){var _=e.data;if("string"==typeof e.data)console.log("on message [string] ignore.");else{var r=new DataView(_),n=r.getUint16(0,!0);console.log("onmessage code->",n);var t=(r.getUint8(2,!0),r.getUint32(4,!0));if(n>=0&&n<l.length){l[n]}if(0==n||6==n||8==n)console.log("mov_start,mov_pause,mov_seek success");else if(10==n){if(t>36){var s=new Uint32Array(_,8,8),o="width:"+s[0]+" height:"+s[1];o="framerate:"+s[2]+" duration:"+s[3],o="playpos:"+s[4]+" filesize:"+s[5],S=o;var i=s[6],A=new Uint8Array(_,40,i),E=a(A);S.filename=E,O.emit(O.MOVIE_INFO_CHANGE,S)}}else if(11==n)console.log("ss_start success"),O.emit(O.SS_START);else if(24<=n&&26>=n){if(t>=4){var c=r.getUint32(8,!0);T=c.toString(),O.emit(O.VERSION_INFO_CHANGE,T)}}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"),t>4){var u=r.getUint32(8,!0),C=12;d.length=0;for(var L=0;L<u;L++){var g=r.getUint32(C,!0);C+=4;var h=new Uint8Array(_,C,g-1);C+=g;var y=a(h);d.push(y)}O.emit(O.CAMERA_INFO_CHANGE,d)}}else if(53==n){if(t>4){var m=r.getUint32(8,!0),C=12;f.length=0;for(var L=0;L<m;L++){var P=r.getUint32(C,!0);C+=4;var p=new Uint8Array(_,C,P-1);C+=P;var y=a(p);f.push(y)}O.emit(O.MIC_INFO_CHANGE,f)}}else if(85==n)console.log("cam_share success");else if(95==n){console.log("get_videoparam success");var v=new Uint8Array(_,8,_.byteLength-8-1),y=a(v);R=y,O.emit(O.VIDEO_INFO_CHANGE,R)}else if(105==n){console.log("get_rtmp_port_success");var v=new Uint8Array(_,8,_.byteLength-8-1),y=a(v);I=y,O.emit(O.RTMP_PORT_CHANGE,I)}else if(109==n){console.log("get_mic_vol success");var v=new Uint8Array(_,8,_.byteLength-8-1),y=a(v);U=y,O.emit(O.MIC_VOL_CHANGE,U)}else if(111<=n&&114>=n){var v=new Uint8Array(_,8,_.byteLength-8),M=a(v);console.log("url->",M)}else if(13==n)O.emit(O.SS_STOP);else{var v=new Uint8Array(_,8,_.byteLength-8),y=a(v);console.log("data ->",y)}}})}Object.defineProperty(_,"__esModule",{value:!0});var c=r(1),u=n(c),O=new u.default,C="v1.2.2.20180309",l=["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"],S=null,T="",d=[],f=[],R="",I="",U="",L=null,g="127.0.0.1",h=8090,y="ws://127.0.0.1:8090",m=0;O.infos={movieInfo:S,versionInfo:T,cameraInfo:d,micInfo:f,videoInfo:R,rtmpPort:I,micVol:U},O.MOVIE_INFO_CHANGE="MOVIE_INFO_CHANGE",O.VERSION_INFO_CHANGE="VERSION_INFO_CHANGE",O.CAMERA_INFO_CHANGE="CAMERA_INFO_CHANGE",O.MIC_INFO_CHANGE="MIC_INFO_CHANGE",O.VIDEO_INFO_CHANGE="VIDEO_INFO_CHANGE",O.RTMP_PORT_CHANGE="RTMP_PORT_CHANGE",O.MIC_VOL_CHANGE="MIC_VOL_CHANGE",O.SS_START="SS_START",O.SS_STOP="SS_STOP",O.OPEN="OPEN",O.CLOSE="CLOSE",O.ERROR="ERROR",O.getRTMPPort=function(){s("get_rtmp_port")},O.getMicInfo=function(){s("get_mic")},O.getCamInfo=function(){s("get_cam")},O.getMicVol=function(){s("get_mic_vol")},O.start=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"127.0.0.1",_=arguments[1];g=e,h=_,E()},O.startConnect=function(e){y=e,E()},O.openAudio=function(e){s("aud_start",e)},O.closeAudio=function(){s("aud_stop")},O.stop=function(){A()},O.startShareScreen=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";s("start_push",e),s("ss_start",e)},O.stopShareScreen=function(){s("ss_stop")};var P=O;_.default=P;(function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(O,"e","E:/WorkGround/xuedianyun/h5Project/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(C,"shareVersion","E:/WorkGround/xuedianyun/h5Project/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(t,"utf16to8","E:/WorkGround/xuedianyun/h5Project/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(a,"utf8to16","E:/WorkGround/xuedianyun/h5Project/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(l,"CODE","E:/WorkGround/xuedianyun/h5Project/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(s,"sendCommand","E:/WorkGround/xuedianyun/h5Project/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(o,"_sendCommand","E:/WorkGround/xuedianyun/h5Project/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(S,"movieInfo","E:/WorkGround/xuedianyun/h5Project/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(T,"versionInfo","E:/WorkGround/xuedianyun/h5Project/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(d,"cameraInfo","E:/WorkGround/xuedianyun/h5Project/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(f,"micInfo","E:/WorkGround/xuedianyun/h5Project/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(R,"videoInfo","E:/WorkGround/xuedianyun/h5Project/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(I,"rtmpPort","E:/WorkGround/xuedianyun/h5Project/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(U,"micVol","E:/WorkGround/xuedianyun/h5Project/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(L,"ws","E:/WorkGround/xuedianyun/h5Project/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(g,"host","E:/WorkGround/xuedianyun/h5Project/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(h,"port","E:/WorkGround/xuedianyun/h5Project/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(y,"fullUrl","E:/WorkGround/xuedianyun/h5Project/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(m,"wstimer","E:/WorkGround/xuedianyun/h5Project/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(i,"clear","E:/WorkGround/xuedianyun/h5Project/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(A,"stop","E:/WorkGround/xuedianyun/h5Project/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(E,"start","E:/WorkGround/xuedianyun/h5Project/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(P,"default","E:/WorkGround/xuedianyun/h5Project/screenshare/src/main.js"))})()}])});