/// <summary>
        /// Called for each frame
        /// </summary>
        /// <param name="sampleTime">Time of sample</param>
        /// <param name="pBuffer">Buffer containing image</param>
        /// <param name="bufferLen">size of buffer</param>
        /// <returns></returns>
        public int BufferCB(double sampleTime, IntPtr pBuffer, int bufferLen)
        {
            _frameCount++;

            //stuff todo when we start up
            if (!firstFrame)
            {
                firstFrame = true;
                var vm = ViewModel.Get();
                _startTime    = DateTime.Now;
                vm.FirstFrame = DateTime.Now.ToString("g");
                vm.BufferSize = bufferLen;
            }

            //copy the frame to our local memory
            if (_map != IntPtr.Zero)
            {
                CopyMemory(_map, pBuffer, bufferLen);
            }

            // Calculate framerate
            if ((DateTime.Now - _startTime).TotalMilliseconds >= 2000)
            {
                ViewModel.Get().CurrentFrameRate = _frameCount / ((DateTime.Now - _startTime).TotalMilliseconds / 1000);
                _frameCount = 0;
                _startTime  = DateTime.Now;
            }
            return(0);
        }
 /// <summary>
 /// Create a bitmap
 /// </summary>
 private void AllocateBitmap()
 {
     try
     {
         Bitmap = Imaging.CreateBitmapSourceFromMemorySection
                      (_section, _width, _height,
                      PixelFormats.Bgr32, _width * PixelFormats.Bgr32.BitsPerPixel / 8, 0)
                  as InteropBitmap;
         ViewModel.Get().CaptureImageCommand.OnCanExecuteChanged();
     }
     catch (Exception ex)
     {
     }
 }
Exemplo n.º 3
0
        private static void Main(string[] args)
        {
            _startColor = Console.ForegroundColor;
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                _handler      = ConsoleCtrlCheck;
                _processEvent = Program_Exited;

                SetConsoleCtrlHandler(_handler, true);
                Process.GetCurrentProcess().Exited += _processEvent;
                string url = args.Length != 1 ? InputBox.GetUrl() : args[0];
                LogSuccess(url);
                if (string.IsNullOrEmpty(url))
                {
                    LogError("No RTSPsource url specified");
                    return;
                }
                bool restart = true;
                while (restart)
                {
                    using (_dlg = new VideoStatus())
                    {
                        _dlg.LoadUrl(url);
                        Application.Run(_dlg);
                    }
                    Thread.Sleep(5000);
                    restart = ViewModel.Get().AutoRestart;
                }
            }
            catch (Exception ex)
            {
                LogError("Error: " + ex.Message);
                LogError("-------------------------------");
                LogError("Program Terminating");
            }
            finally
            {
                Console.ForegroundColor = _startColor;
            }
            if (_dlg != null && !_dlg.IsDisposed)
            {
                _dlg.Dispose();
            }

            LogError("Program ended");
        }
Exemplo n.º 4
0
 /// <summary>
 /// Called for each frame.
 /// Check the buffer for the presence of the lost
 /// video tag, if found set the view model flags and count
 /// </summary>
 /// <param name="sampleTime">Time of sample</param>
 /// <param name="pBuffer">Buffer containing image</param>
 /// <param name="bufferLen">size of buffer</param>
 /// <returns></returns>
 public int BufferCB(double sampleTime, IntPtr pBuffer, int bufferLen)
 {
     if (Marshal.ReadByte(pBuffer, 0) == 0x21 &&
         Marshal.ReadByte(pBuffer, 1) == 0x44 &&
         Marshal.ReadByte(pBuffer, 2) == 0x4d &&
         Marshal.ReadByte(pBuffer, 3) == 0x48 &&
         Marshal.ReadByte(pBuffer, 4) == 0x21)
     {
         ViewModel.Get().LostVideoFrameCount++;
         ViewModel.Get().LostVideo = true;
     }
     else
     {
         ViewModel.Get().LostVideo           = false;
         ViewModel.Get().LostVideoFrameCount = 0;
     }
     return(0);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Constructor
 /// </summary>
 public FilterStatus()
 {
     InitializeComponent();
     _viewModel  = ViewModel.Get();
     DataContext = _viewModel;
 }