public VideoEncoderReadThread(VideoEncoder encoder, Process process, BufferPool encodedBuffers) { this.encoder = encoder; this.process = process; this.encodedBuffers = encodedBuffers; this.stream = process.StandardOutput.BaseStream; }
public VideoEncoderWriteThread(VideoEncoder encoder, Process process, BufferPool frameBuffers) { this.encoder = encoder; this.frameBuffers = frameBuffers; this.stream = process.StandardInput.BaseStream; }
public void StartEncoding(EncoderSettings settings) { if (IsEncoding) { return; } lock (this) { started = true; } totalBytes = 0; frameBuffers.Clear(); // Create new buffer pools in case threads are still doing things frameBuffers = new BufferPool(); encodedBuffers = new BufferPool(); process = new Process(); process.StartInfo.Arguments = GetFFMpegArguments(settings); process.StartInfo.FileName = ffmpeg.Path; process.StartInfo.RedirectStandardInput = true; process.StartInfo.RedirectStandardError = true; process.StartInfo.RedirectStandardOutput = true; process.StartInfo.UseShellExecute = false; process.StartInfo.CreateNoWindow = true; process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; process.Start(); readThread = new VideoEncoderReadThread(this, process, encodedBuffers); writeThread = new VideoEncoderWriteThread(this, process, frameBuffers); errorThread = new VideoEncoderErrorThread(this, process); errorThread.Start(); readThread.Start(); writeThread.Start(); }
public VideoDecoderWriteThread(VideoDecoder decoder, Process process, BufferPool encodedBuffers) { this.decoder = decoder; this.encodedBuffers = encodedBuffers; this.stream = process.StandardInput.BaseStream; }
public VideoDecoderReadThread(VideoDecoder decoder, Process process, BufferPool decodedBuffers) { this.decoder = decoder; this.screen = decoder.VideoPreview; this.decodedBuffers = decodedBuffers; this.lockBounds = new Rectangle(0, 0, decoder.VideoWidth, decoder.VideoHeight); this.decodeBuffer = new Bitmap(decoder.VideoWidth, decoder.VideoHeight, PixelFormat.Format24bppRgb); this.stream = process.StandardOutput.BaseStream; this.frameSize = decoder.VideoWidth * decoder.VideoHeight * 3; this.readBuffer = new byte[frameSize]; this.pos = 0; }
public ServerWriteThread(ServerSession server, BufferPool outputBuffers, List<ConnectedClient> clients, List<ConnectedClient> killList) { this.server = server; this.outputBuffers = outputBuffers; this.clients = clients; this.killList = killList; }
/// <summary> /// Stops the server from capturing, encoding video, and all network activity. It's /// safe to stop a server more than once. /// </summary> public void StopServer() { if (!IsRunning) { return; } lock (this) { running = false; } if (videoCapture != null) { videoCapture.StopCapturing(); videoCapture = null; } if (videoEncoder != null) { videoEncoder.StopEncoding(); videoEncoder = null; } if (socket != null) { socket.Close(); socket = null; } if (outputBuffers != null) { outputBuffers.Clear(); } if (readThread != null) { readThread.Stop(); readThread = null; } if (writeThread != null) { writeThread.Stop(); writeThread = null; } if (listenThread != null) { listenThread.Stop(); listenThread = null; } if (inputPlayback != null) { inputPlayback.StopPlayback(); inputPlayback = null; } outputBuffers = new BufferPool(); }