bfg-common 1.0.17 → 1.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -26,7 +26,7 @@ wdi.SpiceChannel = $.spcExtend(wdi.EventObject.prototype, {
|
|
|
26
26
|
socketQ: null,
|
|
27
27
|
packetReassembler: null,
|
|
28
28
|
channel: 1,
|
|
29
|
-
codec: wdi.SpiceVideoCodecType.
|
|
29
|
+
codec: wdi.SpiceVideoCodecType.SPICE_VIDEO_CODEC_TYPE_MJPEG,
|
|
30
30
|
proxy: null,
|
|
31
31
|
token: null,
|
|
32
32
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
wdi.SpiceChannel=$.spcExtend(wdi.EventObject.prototype,{counter:0,ackWindow:0,connectionId:0,socketQ:null,packetReassembler:null,channel:1,codec:wdi.SpiceVideoCodecType.
|
|
1
|
+
wdi.SpiceChannel=$.spcExtend(wdi.EventObject.prototype,{counter:0,ackWindow:0,connectionId:0,socketQ:null,packetReassembler:null,channel:1,codec:wdi.SpiceVideoCodecType.SPICE_VIDEO_CODEC_TYPE_MJPEG,proxy:null,token:null,init:function(e){this.superInit(),this.socketQ=e.socketQ||new wdi.SocketQueue,this.packetReassembler=e.packetReassembler||wdi.ReassemblerFactory.getPacketReassembler(this.socketQ),this.setListeners(),this.ackWindow=0},startHandshakeTimeout:function(){var e=this;this.handshakeTimeout=window.setTimeout((function(){var i=new Error("Handshake timeout");i.code=4200,wdi.Debug.error("Handshake timeout reached, raising error"),e.fire("error",i)}),5e3)},cancelHandshakeTimeout:function(){clearTimeout(this.handshakeTimeout)},setListeners:function(){var e,i=this;this.packetReassembler.addListener("packetComplete",(function(t){var s=t;if("spicePacket"===s.status){wdi.Debug.log("packetComplete spicePacket"),i.cancelHandshakeTimeout(),wdi.logOperations&&(wdi.DataLogger.logNetworkTime(),e=Date.now());var a=this.getRawSpiceMessage(s.data);a&&(wdi.logOperations&&a.channel===wdi.SpiceVars.SPICE_CHANNEL_DISPLAY&&wdi.DataLogger.setStartTime(e),this.fire("message",a))}else if("reply"===s.status){wdi.Debug.log("packetComplete reply");var n=this.getRedLinkReplyBytes(s.data);this.send(n)}else if("errorCode"===s.status){wdi.Debug.log("packetComplete errorCode"),(n=this.getErrorCodeBytes(s.data))&&(this.send(n),this.channel===wdi.SpiceVars.SPICE_CHANNEL_DISPLAY&&this.changeCodec(this.codec)),this.fire("channelConnected")}}),this),this.socketQ.addListener("open",(function(){var e=this.getRedLinkMessBytes();this.send(e),this.proxy&&this.proxy.end()}),this),this.socketQ.addListener("close",(function(e){1===this.channel&&this.fire("error",e),this.socketQ.disconnect()}),this),this.socketQ.addListener("error",(function(e){this.fire("error",e),this.socketQ.disconnect()}),this)},changeCodec:function(e){this.sendObject([...wdi.SpiceObject.numberTo16(2),...wdi.SpiceObject.numberTo16(e),...wdi.SpiceObject.numberTo16(3)],wdi.SpiceVars.SPICE_MSGC_DISPLAY_PREFERRED_VIDEO_CODEC_TYPE),wdi.currentCodec=e,console.log(`codec changed: ${e}`)},connect:function(e,i,t,s){var a=wdi.Utils.generateWebSocketUrl(e.protocol,e.host,e.port,e.vmHost,e.vmPort,"spice",e.vmInfoToken,e.vmid);this.channel=i,this.connectionId=t||0,this.socketQ.connect(a),this.startHandshakeTimeout(),this.proxy=s,this.token=e.token,this.packetReassembler.start()},disconnect:function(){wdi.Debug.log("spicechannel disconnect"),this.counter=0,this.ackWindow=0,this.connectionId=0,this.socketQ.disconnect(),this.socketQ=null,this.packetReassembler.dispose(),this.packetReassembler=null,this.channel=1,this.proxy=null,this.token=null},send:function(e,i){this.socketQ.send(e,i)},sendObject:function(e,i,t){for(var s=0;s<e.length;s+=2048){var a=e.slice(s,s+2048),n=new wdi.SpiceDataHeader({type:i,size:a.length}).marshall();n=n.concat(a),this.send(n,t)}},arrayOfNumberToUint32:function(e){let i=0;for(let t of e)i|=1<<t;return i},setAckWindow:function(e){this.ackWindow=e,this.counter=0},getRawSpiceMessage:function(e){var i=wdi.GlobalPool.create("ViewQueue"),t=wdi.GlobalPool.create("ViewQueue"),s=new Uint8Array(e,0,wdi.SpiceDataHeader.prototype.objectSize);i.setData(s);var a=(new wdi.SpiceDataHeader).demarshall(i);wdi.GlobalPool.discard("ViewQueue",i);var n=e.subarray(wdi.SpiceDataHeader.prototype.objectSize);if(t.setData(n),this.counter++,this.ackWindow&&this.counter===this.ackWindow){this.counter=0;var c=new wdi.SpiceDataHeader({type:wdi.SpiceVars.SPICE_MSGC_ACK,size:0}).marshall();this.send(c)}var o=wdi.PacketLinkFactory.extract(a,t)||!1;if(o)return wdi.PacketLinkProcess.process(a,o,this),wdi.GlobalPool.discard("ViewQueue",t),!1;var r=wdi.GlobalPool.create("RawSpiceMessage");return r.set(a,t,this.channel),r},getRedLinkReplyBytes:function(e){if(this.token){var i=new wdi.ViewQueue;i.setData(e),i.eatBytes(wdi.SpiceLinkHeader.prototype.objectSize);var t=(new wdi.SpiceLinkReply).demarshall(i);return wdi.SpiceObject.stringHexToBytes(RSA_public_encrypt(this.token,t.pub_key))}return wdi.SpiceObject.stringToBytesPadding("",128)},getRedLinkMessBytes:function(){var e=new wdi.SpiceLinkHeader({magic:1363428690,major_version:2,minor_version:2,size:26}).marshall(),i=new wdi.SpiceLinkMess({connection_id:this.connectionId,channel_type:this.channel,caps_offset:18,num_common_caps:1,num_channel_caps:1,common_caps:1<<wdi.SpiceVars.SPICE_COMMON_CAP_MINI_HEADER,channel_caps:this.arrayOfNumberToUint32([wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_SIZED_STREAM,wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_STREAM_REPORT,wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_MONITORS_CONFIG,wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_MULTI_CODEC,wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_PREF_VIDEO_CODEC_TYPE,wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_CODEC_MJPEG,wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_CODEC_VP8,wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_CODEC_H264,wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_CODEC_VP9,wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_CODEC_H265,wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_LZ4_COMPRESSION,wdi.SpiceDisplayCaps.SPICE_DISPLAY_CAP_PREF_COMPRESSION])}).marshall();return e.concat(i)},getErrorCodeBytes:function(e){var i=wdi.GlobalPool.create("ViewQueue");i.setData(e);var t=wdi.SpiceObject.bytesToInt32NoAllocate(i);if(wdi.GlobalPool.discard("ViewQueue",i),0!==t)throw new wdi.Exception({message:"Server refused client",errorCode:2});if(this.channel===wdi.SpiceVars.SPICE_CHANNEL_DISPLAY){var s=new wdi.SpiceDataHeader({type:wdi.SpiceVars.SPICE_MSGC_DISPLAY_INIT,size:14}).marshall(),a=new wdi.SpiceCDisplayInit({pixmap_cache_id:1,pixmap_cache_size:1,glz_dictionary_id:0,glz_dictionary_window_size:0}).marshall();return s.concat(a)}if(this.channel==wdi.SpiceVars.SPICE_CHANNEL_MAIN)return new wdi.SpiceDataHeader({type:wdi.SpiceVars.SPICE_MSGC_MAIN_ATTACH_CHANNELS,size:0}).marshall()}});
|