Exemple #1
0
        /// <summary>
        /// Stops the ServerSession and any recording.
        /// </summary>
        public void StopServer()
        {
            if (serverSession != null)
            {
                serverSession.StopServer();
            }

            if (videoCapture != null)
            {
                videoCapture.StopCapturing();
                videoCapture = null;
            }

            statusLabel.Text = "Not Recording";
            videoScreen.Refresh();
        }
Exemple #2
0
        /// <summary>
        /// Starts the recording and server.
        /// </summary>
        public bool StartServer()
        {
            sessionDialog.addressBox.Text = "0.0.0.0";
            sessionDialog.portBox.Text = "9999";
            sessionDialog.finishButton.Text = "Begin Recording";

            switch (sessionDialog.ShowDialog())
            {
                case DialogResult.OK:
                    break;
                default:
                    return false;
            }

            if (videoCapture == null)
            {
                videoCapture = new VideoCapture(areaDialog.Width, areaDialog.Height);
                videoCapture.SetPosition(areaDialog.Left, areaDialog.Top);
            }

            videoScreen.SetVideoSize(videoCapture.Width, videoCapture.Height);

            serverSettings.Address = sessionDialog.addressBox.Text;
            serverSettings.PortString = sessionDialog.portBox.Text;

            serverSession = new ServerSession(FFmpeg, videoCapture, serverSettings);
            //serverSession.TargetWindow = areaDialog.TargetWindow;
            serverSession.Preview = videoScreen;
            serverSession.StartServer();
            statusLabel.Text = "Recording...";

            return true;
        }
Exemple #3
0
        /// <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();
        }
Exemple #4
0
 public CaptureThread(VideoCapture videoCapture)
 {
     this.videoCapture = videoCapture;
     this.size = new Size(videoCapture.Width, videoCapture.Height);
 }
Exemple #5
0
 public ServerSession(FFMpeg ffmpeg, VideoCapture videoCapture, ServerSettings settings)
 {
     this.ffmpeg = ffmpeg;
     this.videoCapture = videoCapture;
     this.settings = settings;
 }