public void Start() { lock (_syncRoot) { if (IsStreaming) return; _streamingServer = new MJpegStreamingServer(Port); _streamingServer.Start(); _device = GetCameraDevice(); if (_device != null) { _device.NewFrameEvent += OnNewFrame; _device.Start(); string address = LocalMachine.HostName; int port = int.Parse(_device.VideoSource.Source); StartStream(_device, address, port); } IsStreaming = true; } }
public void Stop() { lock (_syncRoot) { if (!IsStreaming) return; if (_device != null) { try { string address = LocalMachine.HostName; int port = int.Parse(_device.VideoSource.Source); StopStream(_device, address, port); _device.NewFrameEvent -= OnNewFrame; _device.Stop(); } catch { } _device = null; } if (_streamingServer != null) { try { _streamingServer.Stop(); } catch { } _streamingServer = null; } IsStreaming = false; } }