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(); }
public void SetUp() { byteArrayPool = new ByteArrayPool(); var pclWorkarounds = new PckWorkaroundsMock(); codec = new CpuSideCodec(pclWorkarounds, byteArrayPool); random = new Random(234234); }
public AssetStreamReceiver(AssetManager assets, ByteArrayPool byteArrayPool, string fileName) { this.assets = assets; this.byteArrayPool = byteArrayPool; this.fileName = fileName; metadataBuffer = new byte[4]; }
public CpuSideCodec(IPclWorkarounds pclWorkarounds, ByteArrayPool byteArrayPool) { this.pclWorkarounds = pclWorkarounds; this.byteArrayPool = byteArrayPool; partInfoArrayPool = new Pool<PartInfo[]>(() => new PartInfo[PartCount]); dottedEncodingReadLut = new byte[DottedEncoding.ReadLutSize]; fixed (byte* pReadLut = dottedEncodingReadLut) DottedEncoding.BuildReadLut(pReadLut); }
public TcpStreamReceiver(IPclWorkarounds pclWorkarounds, IClientSettings settings, ByteArrayPool byteArrayPool) { this.byteArrayPool = byteArrayPool; primaryHostname = settings.PrimaryTcpHostName; secondaryHostname = settings.SecondaryTcpHostName; port = settings.TcpPort; tcpClient = pclWorkarounds.CreateTcpClient(); metaDataBuffer = new byte[4]; tcpClient.NoDelay = true; }
private void Init() { context = new ObjectGL.CachingImpl.Context(gl, nativeGraphicsContext); var pclWorkarounds = new PclWorkarounds(); var textureLoader = new TextureLoader(assetManager); var spritefont = new Spritefont(settings, context, textureLoader); var statisticsRenderer = new OnScreenClientStatisticsRenderer(spritefont); var statistics = new ClientStatistics(statisticsRenderer); var byteArrayPool = new ByteArrayPool(); var streamReceiver = settings.AreFromFile ? (IStreamReceiver)new AssetStreamReceiver(assetManager, byteArrayPool, "stream.dat") : new TcpStreamReceiver(pclWorkarounds, settings, byteArrayPool); streamReceivingStage = new StreamReceivingStage(pclWorkarounds, streamReceiver); cpuDecompressionStage = new CpuDecompressionStage(pclWorkarounds, statistics, byteArrayPool); var mainThreadBorderStage = new MainThreadBorderStage(statistics); var textureInitializer = new TextureInitializer(); //var textureRenderer = new TextureRenderer(pclWorkarounds, settings, context); var gpuProcessingStage = new GpuProcessingStage(pclWorkarounds, statistics, settings, context, textureInitializer); var timedBufferingStage = new TimeBufferingStage(settings, statistics, context); mainLoop = new MainLoop(pclWorkarounds, statistics, settings, context, this, mainThreadBorderStage, timedBufferingStage, statisticsRenderer, textureLoader); //statisticsRenderer.ShowForm(); PipelineBuilder .BeginWith(streamReceivingStage) .ContinueWith(cpuDecompressionStage) .ContinueWith(mainThreadBorderStage) .ContinueWith(gpuProcessingStage) .EndWith(timedBufferingStage); cpuDecompressionStage.Start(); streamReceivingStage.Start(); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); context = new Context(gl, nativeGraphicsContext); var pclWorkarounds = new PclWorkarounds(); var settings = new ClientSettings(); var textureLoader = new TextureLoader(); var spritefont = new Spritefont(settings, context, textureLoader); var statisticsRenderer = new OnScreenClientStatisticsRenderer(spritefont); //var statisticsRenderer = new FormClientStatisticsRenderer(); var statistics = new ClientStatistics(statisticsRenderer); var byteArrayPool = new ByteArrayPool(); var streamReceiver = settings.AreFromFile ? (IStreamReceiver)new FileStreamReceiver(pclWorkarounds, byteArrayPool, fileName ?? "stream.dat") : new TcpStreamReceiver(pclWorkarounds, settings, byteArrayPool); streamReceivingStage = new StreamReceivingStage(pclWorkarounds, streamReceiver); cpuDecompressionStage = new CpuDecompressionStage(pclWorkarounds, statistics, byteArrayPool); var mainThreadBorderStage = new MainThreadBorderStage(statistics); var textureInitializer = new TextureInitializer(); var gpuProcessingStage = new GpuProcessingStage(pclWorkarounds, statistics, settings, context, textureInitializer); var timedBufferingStage = new TimeBufferingStage(settings, statistics, context); mainLoop = new MainLoop(pclWorkarounds, statistics, settings, context, this, mainThreadBorderStage, timedBufferingStage, statisticsRenderer, textureLoader); //statisticsRenderer.ShowForm(); PipelineBuilder .BeginWith(streamReceivingStage) .ContinueWith(cpuDecompressionStage) .ContinueWith(mainThreadBorderStage) .ContinueWith(gpuProcessingStage) .EndWith(timedBufferingStage); cpuDecompressionStage.Start(); streamReceivingStage.Start(); }