示例#1
0
 public void SetUp()
 {
     byteArrayPool = new ByteArrayPool();
     var pclWorkarounds = new PckWorkaroundsMock();
     codec = new CpuSideCodec(pclWorkarounds, byteArrayPool);
     random = new Random(234234);
 }
示例#2
0
文件: Program.cs 项目: Zulkir/RAVC
        static void Run(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var statistics = new HostStatistics();

            var eye = new Beholder.Eyes.SharpDX11.Winforms.WinformsEye();
            var graphicsWindowHandle = eye.CreateNewWindow(200, 150, "Stream", true);
            var colorFormatInfo = eye.Adapters[0].GetSupportedWindowedDisplayFormats().First(x => x.ExplicitFormat == ExplicitFormat.R8G8B8A8_UNORM);
            #if DEBUG
            var deviceFlags = DeviceInitializationFlags.Debug;
            #else
            var deviceFlags = DeviceInitializationFlags.None;
            #endif
            eye.Initialize(eye.Adapters[0], graphicsWindowHandle, new SwapChainDescription(2, colorFormatInfo.ID, false, 0, Sampling.NoMultisampling, true), deviceFlags, new StraightforwardFileSystem());
            var device = eye.Device;

            var pclWorkarounds = new PclWorkarounds();
            var byteArrayPool = new ByteArrayPool();

            var logger = new FileLogger();
            var settings = new HostSettings();
            var globalEvents = new HostGlobalEvents();

            var broadcaster = settings.FromFile
                ? (IStreamBroadcaster)new FileStreamBroadcaster()
                : new TcpStreamBroadcaster(settings, globalEvents, logger);
            var broadcastingStage = new BroadcastStage(broadcaster);
            var cpuSideCodec = new CpuSideCodec(pclWorkarounds, byteArrayPool);
            var cpuCompressionStage = new CpuCompressionStage(statistics, cpuSideCodec);
            var gpuReadBackStage = new GpuReadBackStage(statistics, device, byteArrayPool, 1);
            var debugStage = new DebugStage(device);
            var gpuProcessingStage = new GpuProcessingStage(device);
            //var screenCaptor = new ScreenCaptor9(statistics, device);
            var screenCaptor = new ScreenCaptor11(statistics, device);
            var mainLoop = new MainLoop(statistics, globalEvents, device, screenCaptor);

            PipelineBuilder
                .BeginWith(mainLoop)
                .ContinueWith(gpuProcessingStage)
                //.ContinueWith(debugStage)
                .ContinueWith(gpuReadBackStage)
                .ContinueWith(cpuCompressionStage)
                .EndWith(broadcastingStage);

            broadcaster.Start();
            cpuCompressionStage.Start();

            eye.NewFrame += mainLoop.OnNewFrame;

            statistics.ShowForm();

            using (mainLoop)
            using (eye)
                eye.RunLoop(device.PrimarySwapChain.Window);

            cpuCompressionStage.Stop();
            broadcaster.Stop();
        }