/// <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_VIDEO_DATA to client.
        /// </summary>
        /// <param name="presentationId">This is the same number as the PresentationId field in the TSMM_PRESENTATION_REQUEST message.</param>
        /// <param name="flags">The bits of this integer indicate attributes of this message. </param>
        /// <param name="packetIndex">This field contains the index of the current packet within the larger sample. </param>
        /// <param name="totalPacketsInSample">This field contains the number of packets that make up the current sample.</param>
        /// <param name="SampleNumber">This field contains the index of current sample in current presentation.</param>
        /// <param name="packetData">The video data in bytes which to be sent.</param>
        public void SendVideoPacket(byte presentationId, TsmmVideoData_FlagsValues flags, ushort packetIndex, ushort totalPacketsInSample, uint SampleNumber, byte[] packetData, ulong timeStamp)
        {
            TSMM_VIDEO_DATA videoDataPacket = rdpevorServer.CreateVideoDataPacket(presentationId, flags, packetIndex, totalPacketsInSample, SampleNumber, packetData, timeStamp);

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

            rdpevorServer.SendRdpevorDataPdu(videoDataPacket);
        }