/// <summary>
 /// The callback method to receive data from transport layer.
 /// </summary>
 private void OnDataReceived(byte[] data, uint channelId)
 {
     lock (receivedList)
     {
         RdpevorPdu pdu      = new RdpevorPdu();
         bool       fSucceed = false;
         bool       fResult  = PduMarshaler.Unmarshal(data, pdu);
         if (fResult)
         {
             byte[] pduData = new byte[pdu.Header.cbSize];
             Array.Copy(data, pduData, pduData.Length);
             if (pdu.Header.PacketType == PacketTypeValues.TSMM_PACKET_TYPE_PRESENTATION_REQUEST)
             {
                 TSMM_PRESENTATION_REQUEST request = new TSMM_PRESENTATION_REQUEST();
                 try
                 {
                     fSucceed = PduMarshaler.Unmarshal(pduData, request);
                     receivedList.Add(request);
                 }
                 catch (PDUDecodeException decodeExceptioin)
                 {
                     RdpevorUnkownPdu unkown = new RdpevorUnkownPdu();
                     fSucceed = PduMarshaler.Unmarshal(decodeExceptioin.DecodingData, unkown);
                     receivedList.Add(unkown);
                 }
             }
             else if (pdu.Header.PacketType == PacketTypeValues.TSMM_PACKET_TYPE_VIDEO_DATA)
             {
                 TSMM_VIDEO_DATA notficatioin = new TSMM_VIDEO_DATA();
                 try
                 {
                     fSucceed = PduMarshaler.Unmarshal(pduData, notficatioin);
                     receivedList.Add(notficatioin);
                 }
                 catch (PDUDecodeException decodeExceptioin)
                 {
                     RdpevorUnkownPdu unkown = new RdpevorUnkownPdu();
                     fSucceed = PduMarshaler.Unmarshal(decodeExceptioin.DecodingData, unkown);
                     receivedList.Add(unkown);
                 }
             }
         }
         if (!fResult || !fSucceed)
         {
             RdpevorUnkownPdu unkown = new RdpevorUnkownPdu();
             PduMarshaler.Unmarshal(data, unkown);
             receivedList.Add(unkown);
         }
     }
 }
        /// <summary>
        /// Method to send a TSMM_PRESENTATION_REQUEST to client.
        /// </summary>
        /// <param name="presentationId">A number that uniquely identifies the video stream on the server.</param>
        /// <param name="command">A number that identifies which operation the client is to perform. </param>
        /// <param name="srcWidth">This is the width of the video stream after scaling back to the original resolution.</param>
        /// <param name="srcHeight">This is the height of the video stream after scaling back to the original resolution.</param>
        /// <param name="scaledWidth">This is the width of the video stream.</param>
        /// <param name="scaledHeight">This is the height of the video stream.</param>
        /// <param name="geometryId">This field is used to correlate this video data with its geometry.</param>
        /// <param name="videoType">This field identifies the Media Foundation video subtype of the video stream.</param>
        public void SendPresentationRequest(byte presentationId, CommandValues command, uint srcWidth, uint srcHeight, uint scaledWidth, uint scaledHeight, ulong geometryId, VideoSubtype videoType, byte[] extraData)
        {
            TSMM_PRESENTATION_REQUEST request = rdpevorServer.CreatePresentationRequest(presentationId, command, srcWidth, srcHeight, scaledWidth, scaledHeight, geometryId, videoType, extraData);

            if (this.testType == RdpevorNegativeType.PresentationRequest_InvalidPacketLength)
            {
                //Set the packet length to an invalid value.
                request.Header.cbSize = (uint)(request.Header.cbSize - 1);
            }
            else if (this.testType == RdpevorNegativeType.PresentationRequest_InvalidVersion)
            {
                //Set version to an invalid value.
                request.Version = RdpevorVersionValues.InvalidValue;
            }

            rdpevorServer.SendRdpevorControlPdu(request);
        }