Beispiel #1
0
        public static void startReplay(string filename)
        {
            if (captureInProgress)
            {
                VideoEngine.log_Renamed.error("Ignoring startReplay, capture is in progress");
                return;
            }

            VideoEngine.log_Renamed.info("Starting replay: " + filename);

            try
            {
                System.IO.Stream @in = new BufferedInputStream(new System.IO.FileStream(filename, System.IO.FileMode.Open, System.IO.FileAccess.Read));

                while (@in.available() > 0)
                {
                    CaptureHeader header     = CaptureHeader.read(@in);
                    int           packetType = header.PacketType;

                    switch (packetType)
                    {
                    case CaptureHeader.PACKET_TYPE_LIST:
                        CaptureList list = CaptureList.read(@in);
                        list.commit();
                        break;

                    case CaptureHeader.PACKET_TYPE_RAM:
                        CaptureRAM ramFragment = CaptureRAM.read(@in);
                        ramFragment.commit();
                        break;

                    // deprecated
                    case CaptureHeader.PACKET_TYPE_DISPLAY_DETAILS:
                        CaptureDisplayDetails displayDetails = CaptureDisplayDetails.read(@in);
                        displayDetails.commit();
                        break;

                    case CaptureHeader.PACKET_TYPE_FRAMEBUF_DETAILS:
                        // don't replay this one immediately, wait until after the list has finished executing
                        replayFrameBufDetails = CaptureFrameBufDetails.read(@in);
                        break;

                    default:
                        throw new Exception("Unknown packet type " + packetType);
                    }
                }

                @in.Close();
            }
            catch (Exception e)
            {
                VideoEngine.log_Renamed.error("Failed to start replay: " + e.Message);
                Console.WriteLine(e.ToString());
                Console.Write(e.StackTrace);
            }
        }
Beispiel #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static CaptureDisplayDetails read(java.io.InputStream in) throws java.io.IOException
        public static CaptureDisplayDetails read(System.IO.Stream @in)
        {
            CaptureDisplayDetails details = new CaptureDisplayDetails();

            DataInputStream data          = new DataInputStream(@in);
            int             sizeRemaining = data.readInt();

            if (sizeRemaining >= packetSize)
            {
                details.fbp    = data.readInt();
                sizeRemaining -= 4;
                details.fbw    = data.readInt();
                sizeRemaining -= 4;
                details.zbp    = data.readInt();
                sizeRemaining -= 4;
                details.zbw    = data.readInt();
                sizeRemaining -= 4;
                details.psm    = data.readInt();
                sizeRemaining -= 4;

                details.topaddrFb     = data.readInt();
                sizeRemaining        -= 4;
                details.bufferwidthFb = data.readInt();
                sizeRemaining        -= 4;
                details.pixelformatFb = data.readInt();
                sizeRemaining        -= 4;
                details.sync          = data.readInt();
                sizeRemaining        -= 4;

                data.skipBytes(sizeRemaining);

                if (captureRenderTargets)
                {
                    // read draw, depth and display buffers
                    CaptureHeader header     = CaptureHeader.read(@in);
                    int           packetType = header.PacketType;
                    if (packetType != CaptureHeader.PACKET_TYPE_RAM)
                    {
                        throw new IOException("Expected CaptureRAM(" + CaptureHeader.PACKET_TYPE_RAM + ") packet, found " + packetType);
                    }
                    details.drawBuffer = CaptureRAM.read(@in);

                    header     = CaptureHeader.read(@in);
                    packetType = header.PacketType;
                    if (packetType != CaptureHeader.PACKET_TYPE_RAM)
                    {
                        throw new IOException("Expected CaptureRAM(" + CaptureHeader.PACKET_TYPE_RAM + ") packet, found " + packetType);
                    }
                    details.depthBuffer = CaptureRAM.read(@in);

                    header     = CaptureHeader.read(@in);
                    packetType = header.PacketType;
                    if (packetType != CaptureHeader.PACKET_TYPE_RAM)
                    {
                        throw new IOException("Expected CaptureRAM(" + CaptureHeader.PACKET_TYPE_RAM + ") packet, found " + packetType);
                    }
                    details.displayBuffer = CaptureRAM.read(@in);
                }
            }
            else
            {
                throw new IOException("Not enough bytes remaining in stream");
            }

            return(details);
        }