The Stream Surface Bits Command is used to transport encoded bitmap data destined for a rectangular region of the current target surface from an RDP server to an RDP client.
Inheritance: TS_SURFCMD
        /// <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;
                int subLength = 8 + 8 + 22;
                if(surfStreamCmd.bitmapData.exBitmapDataHeader != null)
                {
                    subLength += 24;
                }
                surfCmds.size = (ushort)(subLength + 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);
            }
        }
 // 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 byte[] EncodeSurfStream(TS_SURFCMD_STREAM_SURF_BITS surfStreamData)
        {
            List<byte> buffer = new List<byte>();

            RdpbcgrEncoder.EncodeStructure(buffer, (ushort)surfStreamData.cmdType);
            RdpbcgrEncoder.EncodeStructure(buffer, surfStreamData.destLeft);
            RdpbcgrEncoder.EncodeStructure(buffer, surfStreamData.destTop);
            RdpbcgrEncoder.EncodeStructure(buffer, surfStreamData.destRight);
            RdpbcgrEncoder.EncodeStructure(buffer, surfStreamData.destBottom);
            RdpbcgrEncoder.EncodeStructure(buffer, surfStreamData.bitmapData.bpp);
            RdpbcgrEncoder.EncodeStructure(buffer, surfStreamData.bitmapData.reserved1);
            RdpbcgrEncoder.EncodeStructure(buffer, surfStreamData.bitmapData.reserved2);
            RdpbcgrEncoder.EncodeStructure(buffer, surfStreamData.bitmapData.codecID);
            RdpbcgrEncoder.EncodeStructure(buffer, surfStreamData.bitmapData.width);
            RdpbcgrEncoder.EncodeStructure(buffer, surfStreamData.bitmapData.height);
            RdpbcgrEncoder.EncodeStructure(buffer, surfStreamData.bitmapData.bitmapDataLength);
            if (surfStreamData.bitmapData.bitmapData != null)
            {
                RdpbcgrEncoder.EncodeBytes(buffer, surfStreamData.bitmapData.bitmapData);
            }

            return buffer.ToArray();
        }
 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;
 }
        private byte[] EncodeSurfStream(TS_SURFCMD_STREAM_SURF_BITS surfStreamData)
        {
            List<byte> buffer = new List<byte>();

            RdpbcgrEncoder.EncodeStructure(buffer, (ushort)surfStreamData.cmdType);
            RdpbcgrEncoder.EncodeStructure(buffer, surfStreamData.destLeft);
            RdpbcgrEncoder.EncodeStructure(buffer, surfStreamData.destTop);
            RdpbcgrEncoder.EncodeStructure(buffer, surfStreamData.destRight);
            RdpbcgrEncoder.EncodeStructure(buffer, surfStreamData.destBottom);
            RdpbcgrEncoder.EncodeStructure(buffer, surfStreamData.bitmapData.bpp);
            RdpbcgrEncoder.EncodeStructure(buffer, (byte)surfStreamData.bitmapData.flags);
            RdpbcgrEncoder.EncodeStructure(buffer, surfStreamData.bitmapData.reserved);
            RdpbcgrEncoder.EncodeStructure(buffer, surfStreamData.bitmapData.codecID);
            RdpbcgrEncoder.EncodeStructure(buffer, surfStreamData.bitmapData.width);
            RdpbcgrEncoder.EncodeStructure(buffer, surfStreamData.bitmapData.height);
            RdpbcgrEncoder.EncodeStructure(buffer, surfStreamData.bitmapData.bitmapDataLength);
            if(surfStreamData.bitmapData.exBitmapDataHeader != null)
            {
                RdpbcgrEncoder.EncodeStructure(buffer, surfStreamData.bitmapData.exBitmapDataHeader.highUniqueId);
                RdpbcgrEncoder.EncodeStructure(buffer, surfStreamData.bitmapData.exBitmapDataHeader.lowUniqueId);
                RdpbcgrEncoder.EncodeStructure(buffer, surfStreamData.bitmapData.exBitmapDataHeader.tmMilliseconds);
                RdpbcgrEncoder.EncodeStructure(buffer, surfStreamData.bitmapData.exBitmapDataHeader.tmSeconds);
            }
            if (surfStreamData.bitmapData.bitmapData != null)
            {
                RdpbcgrEncoder.EncodeBytes(buffer, surfStreamData.bitmapData.bitmapData);
            }

            return buffer.ToArray();
        }