예제 #1
0
        /// <summary>
        /// Load H264 test data for a test suite.
        /// </summary>
        /// <param name="H264TestDataPath"></param>
        /// <returns></returns>
        private RdpegfxH264TestDatas GetH264TestData(string H264TestDataPath)
        {
            RdpegfxH264TestDatas H264TestData = null;

            XmlSerializer serializer = new XmlSerializer(typeof(RdpegfxH264TestDatas));
            FileStream    fs         = new FileStream(H264TestDataPath, FileMode.Open);
            XmlTextReader reader     = new XmlTextReader(fs);

            reader.XmlResolver   = null;
            reader.DtdProcessing = System.Xml.DtdProcessing.Prohibit; // Prohibit DTD processing when using XmlTextReader on untrusted sources
            H264TestData         = (RdpegfxH264TestDatas)serializer.Deserialize(reader);
            fs.Close();

            return(H264TestData);
        }
        /// <summary>
        /// Common function to send H264 data to the client
        /// </summary>
        /// <param name="h264DataFile">XML file of H264 data</param>
        /// <param name="isAVC444">Whether need RDP client support AVC444/AVC444v2</param>
        private void SendH264CodecStream(string h264DataFile, bool isAVC444)
        {
            //Load H264 data
            RdpegfxH264TestDatas h264TestData = GetH264TestData(h264DataFile);

            // Init for capability exchange
            this.TestSite.Log.Add(LogEntryKind.Comment, "Do capability exchange.");
            RDPEGFX_CapabilityExchange();
            if (isAVC444)
            {
                this.TestSite.Assume.IsTrue(this.isH264AVC444Supported, "This test case requires RDP client to support AVC444/AVC444v2.");
            }
            else
            {
                this.TestSite.Assume.IsTrue(this.isH264AVC420Supported, "To test H264 codec, client must indicate support for H264 codec in RDPGFX_CAPS_ADVERTISE_PDU");
            }

            this.TestSite.Log.Add(LogEntryKind.Comment, "Create a surface and fill it with green color.");
            // Create & output a surface
            RDPGFX_POINT16 surfPos     = new RDPGFX_POINT16((ushort)h264TestData.SurfaceInfo.outputOriginX, (ushort)h264TestData.SurfaceInfo.outputOriginY);
            RDPGFX_RECT16  surfRect    = RdpegfxTestUtility.ConvertToRect(surfPos, h264TestData.SurfaceInfo.width, h264TestData.SurfaceInfo.height);
            RDPGFX_RECT16  compareRect = RdpegfxTestUtility.ConvertToRect(surfPos, h264TestData.SurfaceInfo.width, h264TestData.SurfaceInfo.height);

            if (isWindowsImplementation && compareRect.top < 32 && compareRect.bottom > 32)
            {
                // Ignore the field of RDP client connection bar
                compareRect.top = 32;
            }
            Surface surf = this.rdpegfxAdapter.CreateAndOutputSurface(surfRect, (PixelFormat)h264TestData.SurfaceInfo.pixelFormat);

            this.TestSite.Assert.IsNotNull(surf, "Surface {0} is created", surf.Id);

            // Send solid fill request to client to fill surface with green color
            RDPGFX_RECT16[] fillRects = { new RDPGFX_RECT16(h264TestData.TestDataList[0].DestRect.left,
                                                            h264TestData.TestDataList[0].DestRect.top,
                                                            h264TestData.TestDataList[0].DestRect.right,
                                                            h264TestData.TestDataList[0].DestRect.bottom) }; // Relative to surface
            uint            fid = this.rdpegfxAdapter.SolidFillSurface(surf, RdpegfxTestUtility.fillColorGreen, fillRects);

            this.TestSite.Log.Add(LogEntryKind.Debug, "Surface is filled with solid color in frame: {0}", fid);
            this.rdpegfxAdapter.ExpectFrameAck(fid);

            // Send H264 codec data
            foreach (TestData data in h264TestData.TestDataList)
            {
                ushort        codecId   = data.codecId;
                PixelFormat   pixFormat = (PixelFormat)data.pixelFormat;
                RDPGFX_RECT16 bmRect    = new RDPGFX_RECT16();
                bmRect.left   = data.DestRect.left;
                bmRect.top    = data.DestRect.top;
                bmRect.right  = data.DestRect.right;
                bmRect.bottom = data.DestRect.bottom;

                if (codecId == (ushort)CodecType.RDPGFX_CODECID_AVC420 && data.AVC420BitmapStream != null)
                {
                    this.TestSite.Log.Add(LogEntryKind.Comment, "Sending H264 AVC420 Encoded Bitmap Data Messages to client.");
                    fid = this.rdpegfxAdapter.SendImageWithH264AVC420Codec(surf.Id, pixFormat, bmRect, data.AVC420BitmapStream.To_RFX_AVC420_BITMAP_STREAM(), data.GetBaseImage());
                    // Test case pass if frame acknowledge is received.
                    this.rdpegfxAdapter.ExpectFrameAck(fid);
                }
                else if (codecId == (ushort)CodecType.RDPGFX_CODECID_AVC444 && data.AVC444BitmapStream != null)
                {
                    this.TestSite.Log.Add(LogEntryKind.Comment, "Sending H264 AVC444 Encoded Bitmap Data Messages to client.");
                    fid = this.rdpegfxAdapter.SendImageWithH264AVC444Codec(surf.Id, pixFormat, bmRect, CodecType.RDPGFX_CODECID_AVC444, data.AVC444BitmapStream.To_RFX_AVC444_BITMAP_STREAM(), data.GetBaseImage());
                    // Test case pass if frame acknowledge is received.
                    this.rdpegfxAdapter.ExpectFrameAck(fid);
                }
                else if (codecId == (ushort)CodecType.RDPGFX_CODECID_AVC444v2 && data.AVC444v2BitmapStream != null)
                {
                    this.TestSite.Log.Add(LogEntryKind.Comment, "Sending H264 AVC444v2 Encoded Bitmap Data Messages to client.");
                    fid = this.rdpegfxAdapter.SendImageWithH264AVC444Codec(surf.Id, pixFormat, bmRect, CodecType.RDPGFX_CODECID_AVC444v2, data.AVC444v2BitmapStream.To_RFX_AVC444V2_BITMAP_STREAM(), data.GetBaseImage());
                    // Test case pass if frame acknowledge is received.
                    this.rdpegfxAdapter.ExpectFrameAck(fid);
                }
                else
                {
                    Site.Assert.Fail("Test data doesn't contain proper H264 encoded data corresponding to codec ID.");
                }

                this.TestSite.Log.Add(LogEntryKind.Comment, "Verify output on SUT Display if the verifySUTDisplay entry in PTF config is true.");
                this.VerifySUTDisplay(true, compareRect, 2);
            }

            // Delete the surface
            this.rdpegfxAdapter.DeleteSurface(surf.Id);
            this.TestSite.Log.Add(LogEntryKind.Debug, "Surface {0} is deleted", surf.Id);
        }