Beispiel #1
0
        /// <summary>
        /// Start receiving jpeg frames via the FrameAvailable event.
        /// </summary>
        /// <param name="dispatcher">The UI dispatcher</param>
        /// <param name="sizeHint">The size you plan to display, this is just a hint</param>
        /// <param name="fps">The fps setting, defaults to maximum FPS</param>
        public void StartJpegStream(CoreDispatcher dispatcher, int sizeHint = 640, CameraFps fps = CameraFps.Max)
        {
            int resolution = (sizeHint <= 320) ? 8 : 32;

            if (CameraUrl == null)
            {
                return;
            }

            try
            {
                mjpeg             = new MjpegDecoder(dispatcher);
                mjpeg.FrameReady += OnFrameReady;
                mjpeg.Error      += OnError;

                string requestStr = String.Format("{0}videostream.cgi?resolution={1}&rate={2}", CameraUrl, resolution, (byte)fps);

                int msPerFrames = GetMillisecondsPerFrame(fps);

                mjpeg.GetVideoStream(new Uri(requestStr), msPerFrames, GetCredentials());
            }
            catch (Exception e)
            {
                OnError(this, new ErrorEventArgs()
                {
                    Message = e.Message
                });
                Log.WriteLine("{0}: couldn't talk to the camera. are the arguments correct?\n exception details: {1}", this.ToString(), e.ToString());
                throw;
            }
        }