正在显示
4 个修改的文件
包含
133 行增加
和
122 行删除
1 | -<!DOCTYPE html><html><head><meta charset="UTF-8"><title>UMD PLAYGROUND</title></head><body><div id="stage"></div><script type="text/javascript" src="test.js?8c5b5e6f30a1691a0b96"></script><script type="text/javascript" src="screenShare.js?8c5b5e6f30a1691a0b96"></script></body></html> | ||
1 | +<!DOCTYPE html><html><head><meta charset="UTF-8"><title>UMD PLAYGROUND</title></head><body><div id="stage"></div><script type="text/javascript" src="test.js?28427e809b69cbbbd3de"></script><script type="text/javascript" src="screenShare.js?28427e809b69cbbbd3de"></script></body></html> |
1 | -!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 _(t){if(r[t])return r[t].exports;var n=r[t]={exports:{},id:t,loaded:!1};return e[t].call(n.exports,n,n.exports,_),n.loaded=!0,n.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 t=function(){function e(e,_){for(var r=0;r<_.length;r++){var t=_[r];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(e,t.key,t)}}return function(_,r,t){return r&&e(_.prototype,r),t&&e(_,t),_}}(),n=function(){function e(){r(this,e),this.MAPS={}}return t(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 t=this.MAPS[e];t&&t.length&&t.forEach(function(e){e(_)})}}}]),e}(),a=n;_.default=a;(function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(n,"Emiter","D:/work/screenshare/src/Emiter.js"),__REACT_HOT_LOADER__.register(a,"default","D:/work/screenshare/src/Emiter.js"))})()},function(e,_,r){"use strict";function t(e){return e&&e.__esModule?e:{default:e}}function n(e){var _,r,t,n;t=e.length,_=new Uint8Array(3*t);var a=0;for(r=0;r<t;r++)n=e.charCodeAt(r),n>=1&&n<=127?_[a++]=n:n>2047?(_[a++]=224|n>>12&15,_[a++]=128|n>>6&63,_[a++]=128|n>>0&63):(_[a++]=192|n>>6&31,_[a++]=128|n>>0&63);return new Uint8Array(_.buffer,0,a)}function a(e){var _,r,t,n,a,s;for(_="",t=e.length,r=0;r<t;)switch(n=e[r++],n>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:_+=String.fromCharCode(n);break;case 12:case 13:a=e[r++],_+=String.fromCharCode((31&n)<<6|63&a);break;case 14:a=e[r++],s=e[r++],_+=String.fromCharCode((15&n)<<12|(63&a)<<6|(63&s)<<0)}return _}function s(e){var _=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",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 t=new ArrayBuffer(r.data_len),a=new Uint32Array(t,0,1);a[0]=parseInt(pos),r.data=new Uint8Array(t,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 t=new ArrayBuffer(r.data_len),a=new Uint32Array(t,0,1);a[0]=parseInt(pos),r.data=new Uint8Array(t,0,4)}}else if("ss_start"==e)r.type=6,r.data=n(_),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 t=new ArrayBuffer(r.data_len),s=new Uint32Array(t,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(t,24,256);window_name=_;for(var E=n(window_name),c=0;c<E.length;c++)A[c]=E[c];s[4]=E.length,s[5]=0;new Uint8Array(t,280,256);return r.data=new Uint8Array(t,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 t=new ArrayBuffer(r.data_len),O=new Uint32Array(t,0,1),C=_;O[0]=C.length;var S=new Uint32Array(t,4,1);S[0]=0;for(var T=new Uint8Array(t,8,256),l=n(C),c=0;c<l.length;c++)T[c]=l[c];new Uint8Array(t,264,256);return r.data=new Uint8Array(t,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 t=new ArrayBuffer(r.data_len),f=new Uint32Array(t,0,1),R=_;f[0]=R.length;var S=new Uint32Array(t,4,1);S[0]=0;for(var I=new Uint8Array(t,8,256),U=n(R),c=0;c<U.length;c++)I[c]=U[c];new Uint8Array(t,264,256);return r.data=new Uint8Array(t,0,r.data_len),void o(r)}"cam_stop"==e?r.type=43:"set_videoparam"==e?(r.type=46,r.data=n(_),r.data_len=r.data.length):"get_videoparam"==e?(r.type=47,r.data=n(_),r.data_len=r.data.length):"start_record"==e?(r.type=48,r.data=n(_),r.data_len=r.data.length):"stop_record"==e?(r.type=49,r.data=n(_),r.data_len=r.data.length):"start_push"==e?(r.type=50,r.data=n(_),r.data_len=r.data.length):"stop_push"==e?(r.type=51,r.data=n(_),r.data_len=r.data.length):"get_rtmp_port"==e?r.type=52:"set_mic_vol"==e?(r.type=53,r.data=n(_),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(_),t=new Uint16Array(r,0,1),n=new Uint8Array(r,2,1),a=new Uint32Array(r,4,1);if(t[0]=e.type,n[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,C.emit(C.CLOSE))}catch(e){console.log(e)}}function A(){i()}function E(){L&&i(),L=new WebSocket(m),p=setTimeout(function(){clearTimeout(p),i()},1500),L.timeout=1500,L.binaryType="arraybuffer",L.onopen=function(){clearTimeout(p),s("get_rtmp_port"),s("get_mic"),s("get_cam"),s("get_mic_vol"),C.emit(C.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(_),t=r.getUint16(0,!0);console.log("onmessage code->",t);var n=(r.getUint8(2,!0),r.getUint32(4,!0));if(t>=0&&t<S.length){S[t]}if(0==t||6==t||8==t)console.log("mov_start,mov_pause,mov_seek success");else if(10==t){if(n>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],T=o;var i=s[6],A=new Uint8Array(_,40,i),E=a(A);T.filename=E,C.emit(C.MOVIE_INFO_CHANGE,T)}}else if(11==t)console.log("ss_start success"),C.emit(C.SS_START);else if(24<=t&&26>=t){if(n>=4){var c=r.getUint32(8,!0);l=c.toString(),C.emit(C.VERSION_INFO_CHANGE,l)}}else if(55==t)console.log("ds_start success");else if(59==t)console.log("as start success");else if(83==t){if(console.log("get camera sucess"),n>4){var O=r.getUint32(8,!0),L=12;f.length=0;for(var d=0;d<O;d++){var g=r.getUint32(L,!0);L+=4;var m=new Uint8Array(_,L,g-1);L+=g;var p=a(m);f.push(p)}C.emit(C.CAMERA_INFO_CHANGE,f)}}else if(53==t){if(n>4){var y=r.getUint32(8,!0),L=12;R.length=0;for(var d=0;d<y;d++){var D=r.getUint32(L,!0);L+=4;var h=new Uint8Array(_,L,D-1);L+=D;var p=a(h);R.push(p)}C.emit(C.MIC_INFO_CHANGE,R)}}else if(85==t)console.log("cam_share success");else if(95==t){console.log("get_videoparam success");var v=new Uint8Array(_,8,_.byteLength-8-1),p=a(v);I=p,C.emit(C.VIDEO_INFO_CHANGE,I)}else if(105==t){console.log("get_rtmp_port_success");var v=new Uint8Array(_,8,_.byteLength-8-1),p=a(v);U=p,C.emit(C.RTMP_PORT_CHANGE,U)}else if(109==t){console.log("get_mic_vol success");var v=new Uint8Array(_,8,_.byteLength-8-1),p=a(v);u=p,C.emit(C.MIC_VOL_CHANGE,u)}else if(111<=t&&114>=t){var v=new Uint8Array(_,8,_.byteLength-8),P=a(v);console.log("url->",P)}else if(13==t)C.emit(C.SS_STOP);else{var v=new Uint8Array(_,8,_.byteLength-8),p=a(v);console.log("data ->",p)}}}}Object.defineProperty(_,"__esModule",{value:!0});var c=r(1),O=t(c),C=new O.default,S=["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"],T=null,l="",f=[],R=[],I="",U="",u="",L=null,d="127.0.0.1",g=8090,m="ws://127.0.0.1:8090",p=0;C.infos={movieInfo:T,versionInfo:l,cameraInfo:f,micInfo:R,videoInfo:I,rtmpPort:U,micVol:u},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(){s("get_rtmp_port")},C.getMicInfo=function(){s("get_mic")},C.getCamInfo=function(){s("get_cam")},C.getMicVol=function(){s("get_mic_vol")},C.start=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"127.0.0.1",_=arguments[1];d=e,g=_,E()},C.startConnect=function(e){m=e,E()},C.stop=function(){A()},C.startShareScreen=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";s("ss_start",e)},C.stopShareScreen=function(){s("ss_stop")};var y=C;_.default=y;(function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(C,"e","D:/work/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(n,"utf16to8","D:/work/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(a,"utf8to16","D:/work/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(S,"CODE","D:/work/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(s,"sendCommand","D:/work/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(o,"_sendCommand","D:/work/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(T,"movieInfo","D:/work/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(l,"versionInfo","D:/work/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(f,"cameraInfo","D:/work/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(R,"micInfo","D:/work/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(I,"videoInfo","D:/work/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(U,"rtmpPort","D:/work/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(u,"micVol","D:/work/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(L,"ws","D:/work/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(d,"host","D:/work/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(g,"port","D:/work/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(m,"fullUrl","D:/work/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(p,"wstimer","D:/work/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(i,"clear","D:/work/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(A,"stop","D:/work/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(E,"start","D:/work/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(y,"default","D:/work/screenshare/src/main.js"))})()}])}); | ||
1 | +!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 _(t){if(r[t])return r[t].exports;var n=r[t]={exports:{},id:t,loaded:!1};return e[t].call(n.exports,n,n.exports,_),n.loaded=!0,n.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 t=function(){function e(e,_){for(var r=0;r<_.length;r++){var t=_[r];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(e,t.key,t)}}return function(_,r,t){return r&&e(_.prototype,r),t&&e(_,t),_}}(),n=function(){function e(){r(this,e),this.MAPS={}}return t(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 t=this.MAPS[e];t&&t.length&&t.forEach(function(e){e(_)})}}}]),e}(),a=n;_.default=a;(function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(n,"Emiter","D:/work/screenshare/src/Emiter.js"),__REACT_HOT_LOADER__.register(a,"default","D:/work/screenshare/src/Emiter.js"))})()},function(e,_,r){"use strict";function t(e){return e&&e.__esModule?e:{default:e}}function n(e){var _,r,t,n;t=e.length,_=new Uint8Array(3*t);var a=0;for(r=0;r<t;r++)n=e.charCodeAt(r),n>=1&&n<=127?_[a++]=n:n>2047?(_[a++]=224|n>>12&15,_[a++]=128|n>>6&63,_[a++]=128|n>>0&63):(_[a++]=192|n>>6&31,_[a++]=128|n>>0&63);return new Uint8Array(_.buffer,0,a)}function a(e){var _,r,t,n,a,s;for(_="",t=e.length,r=0;r<t;)switch(n=e[r++],n>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:_+=String.fromCharCode(n);break;case 12:case 13:a=e[r++],_+=String.fromCharCode((31&n)<<6|63&a);break;case 14:a=e[r++],s=e[r++],_+=String.fromCharCode((15&n)<<12|(63&a)<<6|(63&s)<<0)}return _}function s(e){var _=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",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 t=new ArrayBuffer(r.data_len),a=new Uint32Array(t,0,1);a[0]=parseInt(pos),r.data=new Uint8Array(t,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 t=new ArrayBuffer(r.data_len),a=new Uint32Array(t,0,1);a[0]=parseInt(pos),r.data=new Uint8Array(t,0,4)}}else if("ss_start"==e)r.type=6,r.data=n(_),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 t=new ArrayBuffer(r.data_len),s=new Uint32Array(t,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(t,24,256);window_name=_;for(var E=n(window_name),c=0;c<E.length;c++)A[c]=E[c];s[4]=E.length,s[5]=0;new Uint8Array(t,280,256);return r.data=new Uint8Array(t,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 t=new ArrayBuffer(r.data_len),O=new Uint32Array(t,0,1),C=_;O[0]=C.length;var S=new Uint32Array(t,4,1);S[0]=0;for(var T=new Uint8Array(t,8,256),l=n(C),c=0;c<l.length;c++)T[c]=l[c];new Uint8Array(t,264,256);return r.data=new Uint8Array(t,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 t=new ArrayBuffer(r.data_len),f=new Uint32Array(t,0,1),R=_;f[0]=R.length;var S=new Uint32Array(t,4,1);S[0]=0;for(var I=new Uint8Array(t,8,256),u=n(R),c=0;c<u.length;c++)I[c]=u[c];new Uint8Array(t,264,256);return r.data=new Uint8Array(t,0,r.data_len),void o(r)}"cam_stop"==e?r.type=43:"set_videoparam"==e?(r.type=46,r.data=n(_),r.data_len=r.data.length):"get_videoparam"==e?(r.type=47,r.data=n(_),r.data_len=r.data.length):"start_record"==e?(r.type=48,r.data=n(_),r.data_len=r.data.length):"stop_record"==e?(r.type=49,r.data=n(_),r.data_len=r.data.length):"start_push"==e?(r.type=50,r.data=n(_),r.data_len=r.data.length):"stop_push"==e?(r.type=51,r.data=n(_),r.data_len=r.data.length):"get_rtmp_port"==e?r.type=52:"set_mic_vol"==e?(r.type=53,r.data=n(_),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(_),t=new Uint16Array(r,0,1),n=new Uint8Array(r,2,1),a=new Uint32Array(r,4,1);if(t[0]=e.type,n[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];d&&d.send(r)}function i(){try{d&&(d.close(),d=d.onopen=d.onclose=d.onerror=d.onmessage=null,C.emit(C.CLOSE))}catch(e){console.log(e)}}function A(){i()}function E(){d&&i(),d=new WebSocket(p),clearTimeout(D),D=setTimeout(function(){clearTimeout(D),i()},1500),d&&(d.timeout=1500,d.binaryType="arraybuffer",d.onopen=function(){clearTimeout(D),s("get_rtmp_port"),s("get_mic"),s("get_cam"),s("get_mic_vol"),C.emit(C.OPEN)},d.onclose=function(){i()},d.onerror=function(){i()},d.onmessage=function(e){var _=e.data;if("string"==typeof e.data)console.log("on message [string] ignore.");else{var r=new DataView(_),t=r.getUint16(0,!0);console.log("onmessage code->",t);var n=(r.getUint8(2,!0),r.getUint32(4,!0));if(t>=0&&t<T.length){T[t]}if(0==t||6==t||8==t)console.log("mov_start,mov_pause,mov_seek success");else if(10==t){if(n>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],l=o;var i=s[6],A=new Uint8Array(_,40,i),E=a(A);l.filename=E,C.emit(C.MOVIE_INFO_CHANGE,l)}}else if(11==t)console.log("ss_start success"),C.emit(C.SS_START);else if(24<=t&&26>=t){if(n>=4){var c=r.getUint32(8,!0);f=c.toString(),C.emit(C.VERSION_INFO_CHANGE,f)}}else if(55==t)console.log("ds_start success");else if(59==t)console.log("as start success");else if(83==t){if(console.log("get camera sucess"),n>4){var O=r.getUint32(8,!0),S=12;R.length=0;for(var d=0;d<O;d++){var g=r.getUint32(S,!0);S+=4;var m=new Uint8Array(_,S,g-1);S+=g;var p=a(m);R.push(p)}C.emit(C.CAMERA_INFO_CHANGE,R)}}else if(53==t){if(n>4){var D=r.getUint32(8,!0),S=12;I.length=0;for(var d=0;d<D;d++){var h=r.getUint32(S,!0);S+=4;var y=new Uint8Array(_,S,h-1);S+=h;var p=a(y);I.push(p)}C.emit(C.MIC_INFO_CHANGE,I)}}else if(85==t)console.log("cam_share success");else if(95==t){console.log("get_videoparam success");var v=new Uint8Array(_,8,_.byteLength-8-1),p=a(v);u=p,C.emit(C.VIDEO_INFO_CHANGE,u)}else if(105==t){console.log("get_rtmp_port_success");var v=new Uint8Array(_,8,_.byteLength-8-1),p=a(v);U=p,C.emit(C.RTMP_PORT_CHANGE,U)}else if(109==t){console.log("get_mic_vol success");var v=new Uint8Array(_,8,_.byteLength-8-1),p=a(v);L=p,C.emit(C.MIC_VOL_CHANGE,L)}else if(111<=t&&114>=t){var v=new Uint8Array(_,8,_.byteLength-8),P=a(v);console.log("url->",P)}else if(13==t)C.emit(C.SS_STOP);else{var v=new Uint8Array(_,8,_.byteLength-8),p=a(v);console.log("data ->",p)}}})}Object.defineProperty(_,"__esModule",{value:!0});var c=r(1),O=t(c),C=new O.default,S="v1.1.0.20170825",T=["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"],l=null,f="",R=[],I=[],u="",U="",L="",d=null,g="127.0.0.1",m=8090,p="ws://127.0.0.1:8090",D=0;C.infos={movieInfo:l,versionInfo:f,cameraInfo:R,micInfo:I,videoInfo:u,rtmpPort:U,micVol:L},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(){s("get_rtmp_port")},C.getMicInfo=function(){s("get_mic")},C.getCamInfo=function(){s("get_cam")},C.getMicVol=function(){s("get_mic_vol")},C.start=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"127.0.0.1",_=arguments[1];g=e,m=_,E()},C.startConnect=function(e){p=e,E()},C.stop=function(){A()},C.startShareScreen=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";s("ss_start",e)},C.stopShareScreen=function(){s("ss_stop")};var h=C;_.default=h;(function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(C,"e","D:/work/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(S,"shareVersion","D:/work/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(n,"utf16to8","D:/work/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(a,"utf8to16","D:/work/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(T,"CODE","D:/work/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(s,"sendCommand","D:/work/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(o,"_sendCommand","D:/work/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(l,"movieInfo","D:/work/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(f,"versionInfo","D:/work/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(R,"cameraInfo","D:/work/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(I,"micInfo","D:/work/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(u,"videoInfo","D:/work/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(U,"rtmpPort","D:/work/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(L,"micVol","D:/work/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(d,"ws","D:/work/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(g,"host","D:/work/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(m,"port","D:/work/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(p,"fullUrl","D:/work/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(D,"wstimer","D:/work/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(i,"clear","D:/work/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(A,"stop","D:/work/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(E,"start","D:/work/screenshare/src/main.js"),__REACT_HOT_LOADER__.register(h,"default","D:/work/screenshare/src/main.js"))})()}])}); |
@@ -15,7 +15,6 @@ | @@ -15,7 +15,6 @@ | ||
15 | import Emiter from 'Emiter'; | 15 | import Emiter from 'Emiter'; |
16 | import Loger from 'Loger'; | 16 | import Loger from 'Loger'; |
17 | let loger = Loger.getLoger('EverSocket'); | 17 | let loger = Loger.getLoger('EverSocket'); |
18 | - | ||
19 | class EverSocket extends Emiter { | 18 | class EverSocket extends Emiter { |
20 | constructor() { | 19 | constructor() { |
21 | super(); | 20 | super(); |
@@ -60,11 +59,14 @@ class EverSocket extends Emiter { | @@ -60,11 +59,14 @@ class EverSocket extends Emiter { | ||
60 | 59 | ||
61 | _newConnection() { | 60 | _newConnection() { |
62 | this.websocket = new WebSocket(this.wsURL); | 61 | this.websocket = new WebSocket(this.wsURL); |
63 | - this.websocket.binaryType = 'arraybuffer'; | ||
64 | - this.websocket.onopen = this._onOpen.bind(this); | ||
65 | - this.websocket.onclose = this._onClose.bind(this); | ||
66 | - this.websocket.onerror = this._onError.bind(this); | ||
67 | - this.websocket.onmessage = this._onMessage.bind(this); | 62 | + if( this.websocket){ |
63 | + this.websocket.binaryType = 'arraybuffer'; | ||
64 | + this.websocket.onopen = this._onOpen.bind(this); | ||
65 | + this.websocket.onclose = this._onClose.bind(this); | ||
66 | + this.websocket.onerror = this._onError.bind(this); | ||
67 | + this.websocket.onmessage = this._onMessage.bind(this); | ||
68 | + } | ||
69 | + | ||
68 | } | 70 | } |
69 | 71 | ||
70 | _reConnection() { | 72 | _reConnection() { |
@@ -80,10 +82,13 @@ class EverSocket extends Emiter { | @@ -80,10 +82,13 @@ class EverSocket extends Emiter { | ||
80 | loger.log('WebSocket,Timers销毁'); | 82 | loger.log('WebSocket,Timers销毁'); |
81 | window.clearInterval(this.pingTimer); | 83 | window.clearInterval(this.pingTimer); |
82 | window.clearInterval(this.pongTimer); | 84 | window.clearInterval(this.pongTimer); |
83 | - this.websocket.onopen = undefined; | ||
84 | - this.websocket.onclose = undefined; | ||
85 | - this.websocket.onerror = undefined; | ||
86 | - this.websocket.onmessage = undefined; | 85 | + if(this.websocket){ |
86 | + this.websocket.onopen = undefined; | ||
87 | + this.websocket.onclose = undefined; | ||
88 | + this.websocket.onerror = undefined; | ||
89 | + this.websocket.onmessage = undefined; | ||
90 | + } | ||
91 | + | ||
87 | try { | 92 | try { |
88 | this.websocket.close(); | 93 | this.websocket.close(); |
89 | } catch (e) { | 94 | } catch (e) { |
@@ -15,7 +15,7 @@ | @@ -15,7 +15,7 @@ | ||
15 | 15 | ||
16 | import Emiter from './Emiter.js'; | 16 | import Emiter from './Emiter.js'; |
17 | const e = new Emiter(); | 17 | const e = new Emiter(); |
18 | - | 18 | +let shareVersion='v1.1.0.20170825'; |
19 | function utf16to8(str) { | 19 | function utf16to8(str) { |
20 | var out, i, len, c; | 20 | var out, i, len, c; |
21 | 21 | ||
@@ -414,10 +414,12 @@ function start() { | @@ -414,10 +414,12 @@ function start() { | ||
414 | } | 414 | } |
415 | //ws = new WebSocket('ws://' + host + ':' + port); | 415 | //ws = new WebSocket('ws://' + host + ':' + port); |
416 | ws = new WebSocket(fullUrl);//wss或ws地址 由外部传递 | 416 | ws = new WebSocket(fullUrl);//wss或ws地址 由外部传递 |
417 | + clearTimeout(wstimer); | ||
417 | wstimer = setTimeout(() => { | 418 | wstimer = setTimeout(() => { |
418 | clearTimeout(wstimer); | 419 | clearTimeout(wstimer); |
419 | clear(); | 420 | clear(); |
420 | }, 1500) | 421 | }, 1500) |
422 | + if(ws){ | ||
421 | ws.timeout = 1500; | 423 | ws.timeout = 1500; |
422 | ws.binaryType = 'arraybuffer'; | 424 | ws.binaryType = 'arraybuffer'; |
423 | ws.onopen = () => { | 425 | ws.onopen = () => { |
@@ -437,122 +439,126 @@ function start() { | @@ -437,122 +439,126 @@ function start() { | ||
437 | clear(); | 439 | clear(); |
438 | } | 440 | } |
439 | 441 | ||
440 | - ws.onmessage = (evt) => { | ||
441 | - const msg = evt.data; | ||
442 | - if (typeof (evt.data) === "string") { | ||
443 | - console.log('on message [string] ignore.'); | ||
444 | - } else { | ||
445 | - var dv = new DataView(msg); | ||
446 | - var result = dv.getUint16(0, true); | ||
447 | - console.log('onmessage code->', result); | ||
448 | - var byte_order = dv.getUint8(2, true); | ||
449 | - var data_len = dv.getUint32(4, true); | ||
450 | - if (result >= 0 && result < CODE.length) { | ||
451 | - var resultString = CODE[result]; | ||
452 | - } else {} | ||
453 | - if (0 == result || 6 == result || 8 == result) { //mov_start,mov_pause,mov_seek success | ||
454 | - console.log('mov_start,mov_pause,mov_seek success'); | ||
455 | - //playRTMPStream("rtmp://127.0.0.1:" + rtmp_port + "/live/ms"); | ||
456 | - } else if (10 == result) { //movie property | ||
457 | - if (data_len > 7 * 4 + 8) { | ||
458 | - var uint32params = new Uint32Array(msg, 8, 8); | ||
459 | - var info = "width:" + uint32params[0] + " height:" + uint32params[1]; | ||
460 | - info = "framerate:" + uint32params[2] + " duration:" + uint32params[3]; | ||
461 | - info = "playpos:" + uint32params[4] + " filesize:" + uint32params[5]; | ||
462 | - movieInfo = info; | ||
463 | - var file_name_len = uint32params[6]; | ||
464 | - var file_name = new Uint8Array(msg, 40, file_name_len); | ||
465 | - var file_name_string = utf8to16(file_name); | ||
466 | - movieInfo.filename = file_name_string; | ||
467 | 442 | ||
468 | - e.emit(e.MOVIE_INFO_CHANGE, movieInfo); | ||
469 | - } | ||
470 | - } else if (11 == result) { | ||
471 | - console.log('ss_start success'); | ||
472 | - e.emit(e.SS_START); | ||
473 | - } else if (24 <= result && 26 >= result) { | ||
474 | - if (data_len >= 4) { | ||
475 | - var version = dv.getUint32(8, true); | ||
476 | - versionInfo = version.toString(); | ||
477 | - e.emit(e.VERSION_INFO_CHANGE, versionInfo); | ||
478 | - } | ||
479 | - } else if (55 == result) { //ds_start success | ||
480 | - console.log('ds_start success'); | ||
481 | - //playRTMPStream("rtmp://127.0.0.1:" + rtmp_port + "/live/ds"); | ||
482 | - } else if (59 == result) { //as start success | ||
483 | - console.log('as start success'); | ||
484 | - //playRTMPStream("rtmp://127.0.0.1:" + rtmp_port + "/live/as"); | ||
485 | - } else if (result == 83) { //get camera sucess | ||
486 | - console.log('get camera sucess'); | ||
487 | - if (data_len > 4) { | ||
488 | - var cam_num = dv.getUint32(8, true); | ||
489 | - var offset = 12; | ||
490 | - cameraInfo.length = 0; | ||
491 | - for (var i = 0; i < cam_num; i++) { | ||
492 | - var cam_name_len = dv.getUint32(offset, true); | ||
493 | - offset += 4; | ||
494 | - var cam_name = new Uint8Array(msg, offset, cam_name_len - 1); | ||
495 | - offset += cam_name_len; | ||
496 | - //var data_sting = new TextDecoder("utf-8").decode(cam_name); | ||
497 | - var data_sting = utf8to16(cam_name); | ||
498 | - cameraInfo.push(data_sting) | 443 | + ws.onmessage = (evt) => { |
444 | + const msg = evt.data; | ||
445 | + if (typeof (evt.data) === "string") { | ||
446 | + console.log('on message [string] ignore.'); | ||
447 | + } else { | ||
448 | + var dv = new DataView(msg); | ||
449 | + var result = dv.getUint16(0, true); | ||
450 | + console.log('onmessage code->', result); | ||
451 | + var byte_order = dv.getUint8(2, true); | ||
452 | + var data_len = dv.getUint32(4, true); | ||
453 | + if (result >= 0 && result < CODE.length) { | ||
454 | + var resultString = CODE[result]; | ||
455 | + } else {} | ||
456 | + if (0 == result || 6 == result || 8 == result) { //mov_start,mov_pause,mov_seek success | ||
457 | + console.log('mov_start,mov_pause,mov_seek success'); | ||
458 | + //playRTMPStream("rtmp://127.0.0.1:" + rtmp_port + "/live/ms"); | ||
459 | + } else if (10 == result) { //movie property | ||
460 | + if (data_len > 7 * 4 + 8) { | ||
461 | + var uint32params = new Uint32Array(msg, 8, 8); | ||
462 | + var info = "width:" + uint32params[0] + " height:" + uint32params[1]; | ||
463 | + info = "framerate:" + uint32params[2] + " duration:" + uint32params[3]; | ||
464 | + info = "playpos:" + uint32params[4] + " filesize:" + uint32params[5]; | ||
465 | + movieInfo = info; | ||
466 | + var file_name_len = uint32params[6]; | ||
467 | + var file_name = new Uint8Array(msg, 40, file_name_len); | ||
468 | + var file_name_string = utf8to16(file_name); | ||
469 | + movieInfo.filename = file_name_string; | ||
470 | + | ||
471 | + e.emit(e.MOVIE_INFO_CHANGE, movieInfo); | ||
499 | } | 472 | } |
500 | - e.emit(e.CAMERA_INFO_CHANGE, cameraInfo); | ||
501 | - } | ||
502 | - } else if (53 == result) { //get mic success | ||
503 | - if (data_len > 4) { | ||
504 | - var mic_num = dv.getUint32(8, true); | ||
505 | - var offset = 12; | ||
506 | - micInfo.length = 0; | ||
507 | - for (var i = 0; i < mic_num; i++) { | ||
508 | - var mic_name_len = dv.getUint32(offset, true); | ||
509 | - offset += 4; | ||
510 | - var mic_name = new Uint8Array(msg, offset, mic_name_len - 1); | ||
511 | - offset += mic_name_len; | ||
512 | - //var data_sting = new TextDecoder("utf-8").decode(mic_name); | ||
513 | - var data_sting = utf8to16(mic_name); | ||
514 | - micInfo.push(data_sting); | 473 | + } else if (11 == result) { |
474 | + console.log('ss_start success'); | ||
475 | + e.emit(e.SS_START); | ||
476 | + } else if (24 <= result && 26 >= result) { | ||
477 | + if (data_len >= 4) { | ||
478 | + var version = dv.getUint32(8, true); | ||
479 | + versionInfo = version.toString(); | ||
480 | + e.emit(e.VERSION_INFO_CHANGE, versionInfo); | ||
481 | + } | ||
482 | + } else if (55 == result) { //ds_start success | ||
483 | + console.log('ds_start success'); | ||
484 | + //playRTMPStream("rtmp://127.0.0.1:" + rtmp_port + "/live/ds"); | ||
485 | + } else if (59 == result) { //as start success | ||
486 | + console.log('as start success'); | ||
487 | + //playRTMPStream("rtmp://127.0.0.1:" + rtmp_port + "/live/as"); | ||
488 | + } else if (result == 83) { //get camera sucess | ||
489 | + console.log('get camera sucess'); | ||
490 | + if (data_len > 4) { | ||
491 | + var cam_num = dv.getUint32(8, true); | ||
492 | + var offset = 12; | ||
493 | + cameraInfo.length = 0; | ||
494 | + for (var i = 0; i < cam_num; i++) { | ||
495 | + var cam_name_len = dv.getUint32(offset, true); | ||
496 | + offset += 4; | ||
497 | + var cam_name = new Uint8Array(msg, offset, cam_name_len - 1); | ||
498 | + offset += cam_name_len; | ||
499 | + //var data_sting = new TextDecoder("utf-8").decode(cam_name); | ||
500 | + var data_sting = utf8to16(cam_name); | ||
501 | + cameraInfo.push(data_sting) | ||
502 | + } | ||
503 | + e.emit(e.CAMERA_INFO_CHANGE, cameraInfo); | ||
504 | + } | ||
505 | + } else if (53 == result) { //get mic success | ||
506 | + if (data_len > 4) { | ||
507 | + var mic_num = dv.getUint32(8, true); | ||
508 | + var offset = 12; | ||
509 | + micInfo.length = 0; | ||
510 | + for (var i = 0; i < mic_num; i++) { | ||
511 | + var mic_name_len = dv.getUint32(offset, true); | ||
512 | + offset += 4; | ||
513 | + var mic_name = new Uint8Array(msg, offset, mic_name_len - 1); | ||
514 | + offset += mic_name_len; | ||
515 | + //var data_sting = new TextDecoder("utf-8").decode(mic_name); | ||
516 | + var data_sting = utf8to16(mic_name); | ||
517 | + micInfo.push(data_sting); | ||
518 | + } | ||
519 | + e.emit(e.MIC_INFO_CHANGE, micInfo); | ||
515 | } | 520 | } |
516 | - e.emit(e.MIC_INFO_CHANGE, micInfo); | 521 | + } else if (85 == result) { //cam_share success |
522 | + console.log('cam_share success'); | ||
523 | + //playRTMPStream("rtmp://127.0.0.1:" + rtmp_port + "/live/cs"); | ||
524 | + } else if (95 == result) { //get_videoparam success | ||
525 | + console.log('get_videoparam success'); | ||
526 | + var data = new Uint8Array(msg, 8, msg.byteLength - 8 - 1); | ||
527 | + //var data_sting = new TextDecoder("utf-8").decode(data); | ||
528 | + var data_sting = utf8to16(data); | ||
529 | + videoInfo = data_sting; | ||
530 | + e.emit(e.VIDEO_INFO_CHANGE, videoInfo); | ||
531 | + } else if (105 == result) { //get_rtmp_port_success | ||
532 | + console.log('get_rtmp_port_success'); | ||
533 | + var data = new Uint8Array(msg, 8, msg.byteLength - 8 - 1); | ||
534 | + //var data_sting = new TextDecoder("utf-8").decode(data); | ||
535 | + var data_sting = utf8to16(data); | ||
536 | + rtmpPort = data_sting; | ||
537 | + e.emit(e.RTMP_PORT_CHANGE, rtmpPort); | ||
538 | + } else if (109 == result) { //get_mic_vol success | ||
539 | + console.log('get_mic_vol success'); | ||
540 | + var data = new Uint8Array(msg, 8, msg.byteLength - 8 - 1); | ||
541 | + //var data_sting = new TextDecoder("utf-8").decode(data); | ||
542 | + var data_sting = utf8to16(data); | ||
543 | + micVol = data_sting; | ||
544 | + e.emit(e.MIC_VOL_CHANGE, micVol); | ||
545 | + } else if (111 <= result && 114 >= result) { | ||
546 | + var data = new Uint8Array(msg, 8, msg.byteLength - 8); | ||
547 | + var url = utf8to16(data); | ||
548 | + console.log('url->', url); | ||
549 | + } else if (13 == result) { | ||
550 | + e.emit(e.SS_STOP); | ||
551 | + } else { | ||
552 | + var data = new Uint8Array(msg, 8, msg.byteLength - 8); | ||
553 | + //var data_sting = new TextDecoder("utf-8").decode(data); | ||
554 | + var data_sting = utf8to16(data); | ||
555 | + console.log('data ->', data_sting); | ||
517 | } | 556 | } |
518 | - } else if (85 == result) { //cam_share success | ||
519 | - console.log('cam_share success'); | ||
520 | - //playRTMPStream("rtmp://127.0.0.1:" + rtmp_port + "/live/cs"); | ||
521 | - } else if (95 == result) { //get_videoparam success | ||
522 | - console.log('get_videoparam success'); | ||
523 | - var data = new Uint8Array(msg, 8, msg.byteLength - 8 - 1); | ||
524 | - //var data_sting = new TextDecoder("utf-8").decode(data); | ||
525 | - var data_sting = utf8to16(data); | ||
526 | - videoInfo = data_sting; | ||
527 | - e.emit(e.VIDEO_INFO_CHANGE, videoInfo); | ||
528 | - } else if (105 == result) { //get_rtmp_port_success | ||
529 | - console.log('get_rtmp_port_success'); | ||
530 | - var data = new Uint8Array(msg, 8, msg.byteLength - 8 - 1); | ||
531 | - //var data_sting = new TextDecoder("utf-8").decode(data); | ||
532 | - var data_sting = utf8to16(data); | ||
533 | - rtmpPort = data_sting; | ||
534 | - e.emit(e.RTMP_PORT_CHANGE, rtmpPort); | ||
535 | - } else if (109 == result) { //get_mic_vol success | ||
536 | - console.log('get_mic_vol success'); | ||
537 | - var data = new Uint8Array(msg, 8, msg.byteLength - 8 - 1); | ||
538 | - //var data_sting = new TextDecoder("utf-8").decode(data); | ||
539 | - var data_sting = utf8to16(data); | ||
540 | - micVol = data_sting; | ||
541 | - e.emit(e.MIC_VOL_CHANGE, micVol); | ||
542 | - } else if (111 <= result && 114 >= result) { | ||
543 | - var data = new Uint8Array(msg, 8, msg.byteLength - 8); | ||
544 | - var url = utf8to16(data); | ||
545 | - console.log('url->', url); | ||
546 | - } else if (13 == result) { | ||
547 | - e.emit(e.SS_STOP); | ||
548 | - } else { | ||
549 | - var data = new Uint8Array(msg, 8, msg.byteLength - 8); | ||
550 | - //var data_sting = new TextDecoder("utf-8").decode(data); | ||
551 | - var data_sting = utf8to16(data); | ||
552 | - console.log('data ->', data_sting); | ||
553 | } | 557 | } |
554 | } | 558 | } |
559 | + | ||
555 | } | 560 | } |
561 | + | ||
556 | } | 562 | } |
557 | 563 | ||
558 | e.infos = { movieInfo, versionInfo, cameraInfo, micInfo, videoInfo, rtmpPort, micVol } | 564 | e.infos = { movieInfo, versionInfo, cameraInfo, micInfo, videoInfo, rtmpPort, micVol } |
-
请 注册 或 登录 后发表评论