public static string Get(VideoSubtype videoSubType)
        {
            if (videoSubType == VideoSubtype.YUY2)
            {
                return("YUY2");
            }
            else if (videoSubType == VideoSubtype.MJPG)
            {
                return("MJPG");
            }
            else if (videoSubType == VideoSubtype.NV12)
            {
                return("NV12");
            }

            throw new Exception("Video subtype not exists.");
        }
        /// <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);
        }
        /// <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);
        }
        /// <summary>
        /// Method to create a TSMM_PRESENTATION_REQUEST packet.
        /// </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="videoSubTypeId">This field identifies the Media Foundation video subtype of the video stream.</param>
        public TSMM_PRESENTATION_REQUEST CreatePresentationRequest(
            byte presentationId,
            CommandValues command,
            uint srcWidth,
            uint srcHeight,
            uint scaledWidth,
            uint scaledHeight,
            UInt64 geometryId,
            VideoSubtype videoSubType,
            byte[] extraData)
        {
            TSMM_PRESENTATION_REQUEST request = new TSMM_PRESENTATION_REQUEST();

            request.Header.PacketType = PacketTypeValues.TSMM_PACKET_TYPE_PRESENTATION_REQUEST;
            request.PresentatioinId   = presentationId;
            request.Version           = RdpevorVersionValues.RDP8;
            request.Command           = command;

            //The InvalidCommand packet is just for negative test, all other fiels are set same as Start packet.
            if (command == CommandValues.Start || command == CommandValues.InvalidCommand)
            {
                request.FrameRate          = FrameRate;
                request.AverageBitrateKbps = AverageBitrateKbps;
                request.Reserved           = 0;
                request.SourceWidth        = srcWidth;
                request.SourceHeight       = srcHeight;
                request.ScaledWidth        = srcWidth;
                request.ScaledHeight       = srcHeight;
                request.hnsTimestampOffset = (ulong)DateTime.Now.ToFileTimeUtc();
                request.GeometryMappingId  = geometryId;
                request.VideoSubtypeId     = RdpevorTestData.GetH264VideoSubtypeId();
                if (videoSubType == VideoSubtype.MFVideoFormat_H264)
                {
                    request.VideoSubtypeId = RdpevorTestData.GetH264VideoSubtypeId();
                }
                request.pExtraData    = extraData;
                request.cbExtra       = (uint)extraData.Length;
                request.Reserved2     = 0;
                request.Header.cbSize = (uint)(sizeOfPresentationFixedFields + request.pExtraData.Length);
            }
            else if (command == CommandValues.Stop)
            {
                request.Header.cbSize = 0x45;

                //If the command is to stop the presentation, only the Header, PresentationId, Version, and Command fields are valid.
                //So set all other fields to 0.
                request.FrameRate          = 0;
                request.AverageBitrateKbps = 0;
                request.Reserved           = 0;
                request.SourceWidth        = 0;
                request.SourceHeight       = 0;
                request.ScaledWidth        = 0;
                request.ScaledHeight       = 0;
                request.hnsTimestampOffset = 0;
                request.GeometryMappingId  = 0;
                request.VideoSubtypeId     = new byte[16];
                request.cbExtra            = 0;
                request.pExtraData         = null;//TDI
                request.Reserved2          = 0;
            }
            return(request);
        }