/// <summary>
        /// Method to send RDPRFX raw data.
        /// </summary>
        /// <param name="surfStreamCmd">TS_SURFCMD_STREAM_SURF_BITS to be send.</param>
        private void SendSurfaceCmd_StreamSurfBits(TS_SURFCMD_STREAM_SURF_BITS surfStreamCmd)
        {
            if (rdpbcgrAdapter != null)
            {
                rdpbcgrAdapter.SendStreamSurfaceBitsCommand(surfStreamCmd);
            }
            else if (this.rdpbcgrServerStack != null && this.rdpbcgrSessionContext != null)
            {
                //TS_FRAME_MARKER frameMakerCmdBegin = new TS_FRAME_MARKER();
                //frameMakerCmdBegin.cmdType = cmdType_Values.CMDTYPE_FRAME_MARKER;
                //frameMakerCmdBegin.frameAction = frameAction_Values.SURFACECMD_FRAMEACTION_BEGIN;
                //frameMakerCmdBegin.frameId = frameIndex;

                //TS_FRAME_MARKER frameMakerCmdEnd = new TS_FRAME_MARKER();
                //frameMakerCmdEnd.cmdType = cmdType_Values.CMDTYPE_FRAME_MARKER;
                //frameMakerCmdEnd.frameAction = frameAction_Values.SURFACECMD_FRAMEACTION_END;
                //frameMakerCmdEnd.frameId = frameIndex++;

                TS_FP_SURFCMDS surfCmds = new TS_FP_SURFCMDS();
                surfCmds.updateHeader = (byte)(((int)updateCode_Values.FASTPATH_UPDATETYPE_SURFCMDS & 0x0f)
                                               | (((int)fragmentation_Value.FASTPATH_FRAGMENT_SINGLE) << 4)
                                               | ((int)compressedType_Values.None << 6));
                surfCmds.compressionFlags   = compressedType_Values.None;
                surfCmds.size               = (ushort)(8 + 8 + 22 + surfStreamCmd.bitmapData.bitmapDataLength);//size of TS_SURFCMD_STREAM_SURF_BITS;
                surfCmds.surfaceCommands    = new TS_SURFCMD[1];
                surfCmds.surfaceCommands[0] = surfStreamCmd;

                TS_FP_UPDATE_PDU fpOutput;
                TS_FP_UPDATE[]   updates = new TS_FP_UPDATE[1];
                updates[0] = surfCmds;
                fpOutput   = rdpbcgrServerStack.CreateFastPathUpdatePdu(rdpbcgrSessionContext, updates);
                rdpbcgrServerStack.SendPdu(rdpbcgrSessionContext, fpOutput);
            }
        }
        /// <summary>
        /// Method to send all pending encoded data of a frame to RDP client.
        /// </summary>
        /// <param name="destLeft">Left bound of the frame.</param>
        /// <param name="destTop">Left bound of the frame.</param>
        /// <param name="width">The width of the frame.</param>
        /// <param name="height">The height of the frame.</param>
        public void FlushEncodedData(ushort destLeft, ushort destTop, ushort width = RdprfxServer.TileSize, ushort height = RdprfxServer.TileSize)
        {
            lock (syncLocker)
            {
                if (pendingBuffer.Count > 0)
                {
                    LogServerADMInfo();

                    TS_SURFCMD_STREAM_SURF_BITS surfStreamCmd = Create_TS_SURFCMD_STREAM_SURF_BITS();
                    surfStreamCmd.bitmapData.bitmapDataLength = (uint)(pendingBuffer.Count);
                    surfStreamCmd.bitmapData.bitmapData       = pendingBuffer.ToArray();
                    pendingBuffer.Clear();

                    surfStreamCmd.destLeft = destLeft;
                    surfStreamCmd.destTop  = destTop;
                    checked
                    {
                        surfStreamCmd.destBottom = (ushort)(destTop + height);
                        surfStreamCmd.destRight  = (ushort)(destLeft + width);
                    }
                    surfStreamCmd.bitmapData.width  = width;
                    surfStreamCmd.bitmapData.height = height;
                    SendSurfaceCmd_StreamSurfBits(surfStreamCmd);
                }
            }

            if (this.rdpbcgrAdapter.SimulatedScreen != null)
            {
                this.rdpbcgrAdapter.SimulatedScreen.RenderRemoteFXTile(destLeft, destTop);
            }
        }
Beispiel #3
0
        // TODO: alignment need captures to verifty flags = TSBitmapDataExFlags_Values.EX_COMPRESSED_BITMAP_HEADER_PRESENT
        private TS_SURFCMD_STREAM_SURF_BITS Create_TS_SURFCMD_STREAM_SURF_BITS(TSBitmapDataExFlags_Values flags, byte codecId)
        {
            TS_SURFCMD_STREAM_SURF_BITS surfStreamCmd = new TS_SURFCMD_STREAM_SURF_BITS();

            surfStreamCmd.cmdType    = cmdType_Values.CMDTYPE_STREAM_SURFACE_BITS;
            surfStreamCmd.destLeft   = 0;
            surfStreamCmd.destTop    = 0;
            surfStreamCmd.destRight  = 0;
            surfStreamCmd.destBottom = 0;
            surfStreamCmd.bitmapData = Create_TS_BITMAP_DATA_EX(flags, codecId);
            return(surfStreamCmd);
        }
        private TS_SURFCMD_STREAM_SURF_BITS Create_TS_SURFCMD_STREAM_SURF_BITS(byte codecId)
        {
            TS_SURFCMD_STREAM_SURF_BITS surfStreamCmd = new TS_SURFCMD_STREAM_SURF_BITS();

            surfStreamCmd.cmdType              = cmdType_Values.CMDTYPE_STREAM_SURFACE_BITS;
            surfStreamCmd.destLeft             = 0;
            surfStreamCmd.destTop              = 0;
            surfStreamCmd.destRight            = 0;
            surfStreamCmd.destBottom           = 0;
            surfStreamCmd.bitmapData           = new TS_BITMAP_DATA_EX();
            surfStreamCmd.bitmapData.bpp       = 32;
            surfStreamCmd.bitmapData.reserved1 = 0;
            surfStreamCmd.bitmapData.reserved2 = 0;
            surfStreamCmd.bitmapData.codecID   = codecId;
            surfStreamCmd.bitmapData.width     = 0;
            surfStreamCmd.bitmapData.height    = 0;
            return(surfStreamCmd);
        }
        /// <summary>
        /// Method to send one frame of unencoded data message to client.
        /// </summary>
        /// <param name="image">The image to be sent.</param>
        /// <param name="opMode">Indicates the operational mode.</param>
        /// <param name="entropy">Indicates the entropy algorithm.</param>
        /// <param name="destLeft">Left bound of the frame.</param>
        /// <param name="destTop">Left bound of the frame.</param>
        public void SendImageToClientWithoutEncoding(System.Drawing.Image image, ushort destLeft, ushort destTop)
        {
            if (image == null)
            {
                Site.Log.Add(LogEntryKind.Debug, "[In iRdprfxAdapter.SendImageToClient Method] The image to be send is null.");
                return;
            }

            TS_SURFCMD_STREAM_SURF_BITS surfStreamCmd = Create_TS_SURFCMD_STREAM_SURF_BITS(0);
            MemoryStream memoryStream = new MemoryStream();

            image.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Bmp);
            Byte[] byteImage = memoryStream.ToArray();

            // remove the BITMAP header data at the beginning
            int rgbLength = RgbTile.TileSize * RgbTile.TileSize * 4;

            Byte[] rgbArray = new Byte[rgbLength];
            int    delta    = byteImage.Length - rgbLength;

            for (int i = 0; i < rgbLength; i++)
            {
                rgbArray[i] = byteImage[delta + i];
            }

            surfStreamCmd.bitmapData.bitmapDataLength = (uint)rgbArray.Length;
            surfStreamCmd.bitmapData.bitmapData       = rgbArray;

            surfStreamCmd.destLeft = destLeft;
            surfStreamCmd.destTop  = destTop;
            checked
            {
                surfStreamCmd.destBottom = (ushort)(destTop + image.Width);
                surfStreamCmd.destRight  = (ushort)(destLeft + image.Height);
            }
            surfStreamCmd.bitmapData.width  = (ushort)image.Width;
            surfStreamCmd.bitmapData.height = (ushort)image.Height;
            SendSurfaceCmd_StreamSurfBits(surfStreamCmd);

            if (this.rdpbcgrAdapter.SimulatedScreen != null)
            {
                this.rdpbcgrAdapter.SimulatedScreen.RenderUncompressedImage(image, destLeft, destTop);
            }
        }
Beispiel #6
0
        /// <summary>
        /// Method to send RDPRFX raw data.
        /// </summary>
        /// <param name="surfStreamCmd">TS_SURFCMD_STREAM_SURF_BITS to be send.</param>
        private void SendSurfaceCmd_StreamSurfBits(TS_SURFCMD_STREAM_SURF_BITS surfStreamCmd)
        {
            if (rdpbcgrAdapter != null)
            {
                rdpbcgrAdapter.SendStreamSurfaceBitsCommand(surfStreamCmd);
            }
            else if (this.rdpbcgrServerStack != null && this.rdpbcgrSessionContext != null)
            {
                //TS_FRAME_MARKER frameMakerCmdBegin = new TS_FRAME_MARKER();
                //frameMakerCmdBegin.cmdType = cmdType_Values.CMDTYPE_FRAME_MARKER;
                //frameMakerCmdBegin.frameAction = frameAction_Values.SURFACECMD_FRAMEACTION_BEGIN;
                //frameMakerCmdBegin.frameId = frameIndex;

                //TS_FRAME_MARKER frameMakerCmdEnd = new TS_FRAME_MARKER();
                //frameMakerCmdEnd.cmdType = cmdType_Values.CMDTYPE_FRAME_MARKER;
                //frameMakerCmdEnd.frameAction = frameAction_Values.SURFACECMD_FRAMEACTION_END;
                //frameMakerCmdEnd.frameId = frameIndex++;

                TS_FP_SURFCMDS surfCmds = new TS_FP_SURFCMDS();

                surfCmds.updateHeader = new nested_TS_FP_UPDATE_updateHeader(updateCode_Values.FASTPATH_UPDATETYPE_SURFCMDS);

                surfCmds.AssignUpdateDataAndSize();

                surfCmds.surfaceCommands    = new TS_SURFCMD[1];
                surfCmds.surfaceCommands[0] = surfStreamCmd;

                TS_FP_UPDATE_PDU fpOutput;
                TS_FP_UPDATE[]   updates = new TS_FP_UPDATE[1];
                updates[0] = surfCmds;

                surfCmds.updateData = surfCmds.EncodeBody();

                fpOutput = rdpbcgrServerStack.CreateFastPathUpdatePdu(rdpbcgrSessionContext, updates);
                rdpbcgrServerStack.SendPdu(rdpbcgrSessionContext, fpOutput);
            }
        }