示例#1
0
 public void WaitForStop()
 {
     if (VideoSource != null)
     {
         VideoSource.WaitForStop();
     }
 }
示例#2
0
 private void StopCamera()
 {
     if (videoSource != null && videoSource.IsRunning)
     {
         videoSource.SignalToStop();
         videoSource.WaitForStop();
         videoSource.NewFrame -= new NewFrameEventHandler(video_NewFrame);
     }
 }
示例#3
0
 // 等待视频源终止
 public void WaitForStop()
 {
     Monitor.Enter(this);
     if (videoSource != null)
     {
         videoSource.WaitForStop();
     }
     Monitor.Exit(this);
 }
示例#4
0
        public void WaitForStop()
        {
            Monitor.Enter(this);

            if (ivideo != null)
            {
                ivideo.WaitForStop();
            }
            Monitor.Exit(this);
        }
示例#5
0
文件: Camera.cs 项目: unixcrh/Motion
 // Wait video source for stop
 public void WaitForStop()
 {
     lock (this)
     {
         if (mVideoSource != null)
         {
             mVideoSource.WaitForStop();
         }
     }
 }
示例#6
0
        public void Stop()
        {
            if (_videoSource != null && _videoSource.IsRunning)
            {
                _videoSource.SignalToStop();
                _videoSource.WaitForStop();
                _videoSource.NewFrame -= new NewFrameEventHandler(this.DisplayWindow.video_NewFrame);
            }

            DisplayWindow.Image = null;
        }
示例#7
0
        // Wait video source for stop
        public void WaitForStop()
        {
            // lock
            Monitor.Enter(this);

            if (VideoSource != null)
            {
                VideoSource.WaitForStop();
            }
            // unlock
            Monitor.Exit(this);
        }
示例#8
0
        /// <summary>
        ///   Waits until the video source has stopped.
        /// </summary>
        ///
        public void WaitForStop()
        {
            if (!requestedToStop)
            {
                SignalToStop();
            }

            if (videoSource != null)
            {
                videoSource.WaitForStop();
            }
        }
示例#9
0
 private void StartCamera()
 {
     if (CurrentDevice != null)
     {
         _videoSource           = new VideoCaptureDevice(CurrentDevice.MonikerString);
         _videoSource.NewFrame += video_NewFrame;
         _videoSource.Start();
     }
     else
     {
         _videoSource.WaitForStop();
     }
 }
        public void CameraOff()
        {
            if (_videoCaptureDevice != null)
            {
                if (_videoCaptureDevice.IsRunning)
                {
                    _videoCaptureDevice.SignalToStop();
                    _videoCaptureDevice.WaitForStop();
                }
            }

            //write line to output class for testing purpose
            _output.OutputLine("Camera off");
        }
        /// <summary>
        /// Wait for video source has stopped.
        /// </summary>
        ///
        /// <remarks><para>Waits for video source stopping after it was signalled to stop using
        /// <see cref="SignalToStop"/> method.</para></remarks>
        ///
        public void WaitForStop( )
        {
            lock (this)
            {
                if (videoSource != null)
                {
                    videoSource.WaitForStop( );

                    if (currentFrame != null)
                    {
                        currentFrame.Dispose( );
                        currentFrame = null;
                    }
                    Invalidate( );
                }
            }
        }
示例#12
0
 public void WaitForStop()
 {
     CheckForCrossThreadAccess();
     if (!requestedToStop)
     {
         SignalToStop();
     }
     if (videoSource != null)
     {
         videoSource.WaitForStop();
         if (currentFrame != null)
         {
             currentFrame.Dispose();
             currentFrame = null;
         }
         Invalidate();
     }
 }
示例#13
0
文件: Camera.cs 项目: zmaples/iSpy
 public void WaitForStop()
 {
     VideoSource?.WaitForStop();
 }
 public void WaitForStop()
 {
     nestedVideoSource.WaitForStop();
     Free();
 }
 // 等待停止
 public void WaitForStop()
 {
     videoSource.WaitForStop();
 }
示例#16
0
		public override void CheckDeviceConnection()
		{
			//--------------------------------------------------------------------------------------------------
			//
			// Automatic reconnection mechanism.
			//
			// Issue: We are not notified when the source disconnects, we need to figure it out ourselves.
			//
			// Mechanism : count the number of frames we received since last check. (heartbeat = 1 second).
			// If we are supposed to do grabbing and we received nothing, we are in one of two conditions:
			// 1. The device has been disconnected.
			// 2. We are in PAUSE state.
			//
			// The problem is that even in condition 1, we may still succeed in reconnecting for a few attempts.
			// If we detect that we CONSTANTLY succeed in reconnecting but there are still no frames coming,
			// we are probably in condition 2. Thus we'll stop trying to disconnect/reconnect, and just wait
			// for the source to start sending frames again.
			//
			// On first connection and after a size change, we keep waiting for frames without disconnecting until 
			// we receive the first one. Otherwise we would constantly trigger the mechanism as the newly connected 
			// device doesn't start to stream before the next heartbeat.
			//
			// Note:
			// This prevents working with very slow capturing devices (when fps < heartbeat).
			// Can't check if we are not currently grabbing.
			//--------------------------------------------------------------------------------------------------
			
			// bHasJustConnected : prevent triggerring the mechanism if we just changed device or conf.
			// bStayConnected : do not trigger either if we are on network device.
			// m_iConnectionsWithoutFrames : we allow for a few attempts at reconnection without a single frame grabbed.
			bool bHasJustConnected = !m_bSizeKnown || m_bSizeChanged;
			bool bStayConnected = m_CurrentVideoDevice.Empty || m_CurrentVideoDevice.Network || bHasJustConnected;
			
			if(!bStayConnected && m_iConnectionsWithoutFrames < 2)
			{
				if(m_bIsGrabbing && m_iGrabbedSinceLastCheck == 0)
				{
					log.DebugFormat("{0} has been disconnected.", m_CurrentVideoDevice.Name);
					
					// Close properly.
					m_VideoSource.SignalToStop();
					m_VideoSource.WaitForStop();
					m_bIsGrabbing = false;
					m_bIsConnected = false;
					m_Container.AlertConnectionLost();
					 
					// Set connection attempts so we don't show the initial error message.
					m_iConnectionsAttempts = 2;
				}
				else
				{
					/*if(m_bIsGrabbing)
						log.DebugFormat("Device is still connected");	
					else
						log.DebugFormat("We are not grabbing and can't check if the device is still connected.");*/
				}
			}
			else
			{
				//log.Debug("Device has succeeded in reconnecting twice, but still doesn't send frames.");
				//log.Debug("This probably means it is on STOP state, we will wait for frames without disconnecting.");
			}
			
			m_iGrabbedSinceLastCheck = 0;
		}