コード例 #1
0
        protected override void StartVideoInternal()
        {
            if (stream != null)
            {
                stream.StopStream();
            }
            stream = new MjpegProcessor.MjpegDecoder();

            stream.OnError += err =>
            {
                ErrorArrived(err.Message);
                Trace.WriteLine("[KICK] Restarting video...");
                StopVideoInternal();
                StartVideoInternal();
            };

            stream.ParseStream(new Uri(Url));
            stream.FrameReady += (_, e) =>
            {
                using (var ptr = new GDIPtr(e.Bitmap.GetHbitmap()))
                {
                    FrameArrived(System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
                                     ptr.Ptr, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()));
                }
            };
        }
コード例 #2
0
        protected override void StartVideoInternal()
        {
            if (stream != null)
            {
                stream.StopStream();
            }
            stream = new MjpegProcessor.MjpegDecoder();

            if (!Settings.Keys.Contains("User"))
            {
                var kv = OnCredentialsRequired(Environment.UserName);
                Settings["User"] = kv.Key;
                Settings["Pass"] = kv.Value;

                // sick of losing settings
                SaveSettings();
            }

            stream.OnError += err =>
            {
                ErrorArrived(err.Message);
                Trace.WriteLine("[KICK] Restarting video...");
                //StopVideoInternal();
                // StartVideoInternal();
            };

            stream.ParseStream(new Uri(string.Format(
                                           "http://{0}/videostream.cgi?user={1}&pwd={2}", UID, Settings["User"], Settings["Pass"])));
            stream.FrameReady += (_, e) =>
            {
                using (var ptr = new GDIPtr(e.Bitmap.GetHbitmap()))
                {
                    FrameArrived(System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
                                     ptr.Ptr, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()));
                }
            };

            try
            {
                currentController = new Controller("http://" + UID + "/", Settings["User"], Settings["Pass"]);

                UpdateValuesFromController();
            }
            catch (WebException ex)
            {
                Trace.WriteLine("Error: " + ex.Message);

                if ((ex.Response as HttpWebResponse).StatusCode == HttpStatusCode.Unauthorized)
                {
                    var kv = OnCredentialsRequired(Settings["User"]);
                    Settings["User"] = kv.Key;
                    Settings["Pass"] = kv.Value;
                    StartVideoInternal();
                }
                else
                {
                    ErrorArrived(ex.Message);
                }
            }
        }
コード例 #3
0
        private void GetVideoMjpegDecoder()
        {
            _mjpeg             = new MjpegProcessor.MjpegDecoder();
            _mjpeg.FrameReady += mjpeg_FrameReady;
            _mjpeg.Error      += mjpeg_Error;

            string requestStr = String.Format("{0}videostream.cgi?resolution=32", CameraUrl);

            _mjpeg.ParseStream(new Uri(requestStr), cameraCredential.UserName, cameraCredential.Password);
        }
コード例 #4
0
        public CCTVLock(string url,string username,string   pwd,bool TimeLimit):this()
        {

            decoder = new MjpegProcessor.MjpegDecoder();
            decoder.FrameReady += decoder_FrameReady;
            decoder.Error += decoder_Error;
            //#	Result	Protocol	Host	URL	Body	Caching	Content-Type	Process	Comments	Custom	
            //24	 - 	HTTP	210.241.67.167	/abs2mjpg/mjpg?camera=14&resolution=352x240&1399178264829	-1			chrome:25404			


            CnCnt++;
            decoder.ParseStream(new Uri(url, UriKind.Absolute), username, pwd, TimeLimit);

        }
コード例 #5
0
        public CCTVLock(int ch):this()
        {
            decoder = new MjpegProcessor.MjpegDecoder();
            decoder.FrameReady += decoder_FrameReady;
            decoder.Error += decoder_Error;
            //#	Result	Protocol	Host	URL	Body	Caching	Content-Type	Process	Comments	Custom	
            //24	 - 	HTTP	210.241.67.167	/abs2mjpg/mjpg?camera=14&resolution=352x240&1399178264829	-1			chrome:25404			

            //    decoder.ParseStream(new Uri("http://210.241.67.167/abs2mjpg/mjpg?resolution=352x240&camera="+ch, UriKind.Absolute));
            CnCnt++;
            decoder.ParseStream(new Uri("http://210.241.67.167/abs2mjpg/mjpg?resolution=352x240&camera=" + ch, UriKind.Absolute));
             // decoder.ParseStream(new Uri("http://192.192.85.20:11000/getimage?fmt=320x240", UriKind.Absolute),"admin","pass",true); 

             // decoder.ParseStream(new Uri("http://192.192.161.17:90/axis-cgi/mjpg/video.cgi?resolution=CIF&camera=1", UriKind.Absolute),"admin","admin");
#if DEBUG
            //this.browser.Navigate(new Uri("http://localhost:65254/CCTVLock.aspx?ch=" + ch, UriKind.Absolute));
#else
            //  this.browser.Navigate(new Uri("http://192.192.85.40/sl/CCTVLock.aspx?ch=" + ch, UriKind.Absolute));
#endif
            // this.browser.Source=new Uri("http://localhost:65254/CCTVLock.aspx?ch="+ch,UriKind.Absolute);
           
        }
コード例 #6
0
ファイル: DriverFoscam.cs プロジェクト: smosgin/labofthings
        private void GetVideoMjpegDecoder()
        {
            _mjpeg = new MjpegProcessor.MjpegDecoder();
            _mjpeg.FrameReady += mjpeg_FrameReady;
            _mjpeg.Error += mjpeg_Error;

            string requestStr = String.Format("{0}videostream.cgi?resolution=32", CameraUrl);

            _mjpeg.ParseStream(new Uri(requestStr), cameraCredential.UserName, cameraCredential.Password);
        }
コード例 #7
0
ファイル: DriverFoscam.cs プロジェクト: smosgin/labofthings
        public override void Start()
        {
            worker1 = null;
            worker2 = null;
            _mjpeg = null;
            fileToRead = Constants.AddInRoot + "\\AddIns\\" + moduleInfo.BinaryName() + "\\logo-green.jpg";

            try
            {
                string[] words = moduleInfo.Args();

                cameraId = words[0];
                cameraUser = words[1];
                cameraPwd = words[2];
            }
            catch (Exception e)
            {
                logger.Log("{0}: Improper arguments: {1}. Exiting module", this.ToString(), e.ToString());
                return;
            }

            //get the IP address
            cameraIp = GetCameraIp(cameraId);

            if (cameraIp == null)
                return;

            //check the username and password
            cameraCredential = new NetworkCredential(cameraUser, cameraPwd);

            try
            {
                HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(CameraUrl);
                webRequest.Credentials = cameraCredential;
                HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();

                if (webResponse.StatusCode == HttpStatusCode.Unauthorized)
                {
                    logger.Log("{0} credentials ({1}/{2}) are not correct", this.ToString(), cameraUser, cameraPwd);
                    return;
                }

                logger.Log("Started: {0} with response code {1}", ToString(), webResponse.StatusCode.ToString());
                webResponse.Close();
            }
            catch (Exception e)
            {
                logger.Log("{0}: couldn't talk to the camera. are the arguments correct?\n exception details: {1}", this.ToString(), e.ToString());

                //don't return. maybe the camera will come online later
                //return;
            }

            //add the camera service port
            VPortInfo pInfo = GetPortInfoFromPlatform("foscam-" + cameraId);

            //List<VRole> roles = new List<VRole>() {RoleCamera.Instance, RolePTCamera.Instance};
            List<VRole> roles = new List<VRole>() { RolePTCamera.Instance };

            cameraPort = InitPort(pInfo);
            BindRoles(cameraPort, roles, OnOperationInvoke);

            RegisterPortWithPlatform(cameraPort);

            switch (videoFetchMode)
            {
                case VideoFetchMode.SelfParse:
                    worker1 = new SafeThread(delegate()
                    {
                        GetVideoSelfParse();
                    }, "GetVideoSelfParse", logger);
                    worker1.Start();
                    break;
                case VideoFetchMode.FromFile:
                    worker2 = new SafeThread(delegate()
                    {
                        GetVideoFromFile();
                    }, "GetVideoFromFile", logger);
                    worker2.Start();
                    break;
                case VideoFetchMode.MjpegDecoder:
                    GetVideoMjpegDecoder();
                    break;
                default:
                    logger.Log("Unknown video fetching mode");
                    break;
            }

            imageServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger);
        }
コード例 #8
0
        public override void Start()
        {
            worker1    = null;
            worker2    = null;
            _mjpeg     = null;
            fileToRead = Constants.AddInRoot + "\\AddIns\\" + moduleInfo.BinaryName() + "\\logo-green.jpg";

            try
            {
                string[] words = moduleInfo.Args();

                cameraId   = words[0];
                cameraUser = words[1];
                cameraPwd  = words[2];
            }
            catch (Exception e)
            {
                logger.Log("{0}: Improper arguments: {1}. Exiting module", this.ToString(), e.ToString());
                return;
            }


            //get the IP address
            cameraIp = GetCameraIp(cameraId);

            if (cameraIp == null)
            {
                return;
            }

            //check the username and password
            cameraCredential = new NetworkCredential(cameraUser, cameraPwd);

            try
            {
                HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(CameraUrl);
                webRequest.Credentials = cameraCredential;
                HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();

                if (webResponse.StatusCode == HttpStatusCode.Unauthorized)
                {
                    logger.Log("{0} credentials ({1}/{2}) are not correct", this.ToString(), cameraUser, cameraPwd);
                    return;
                }

                logger.Log("Started: {0} with response code {1}", ToString(), webResponse.StatusCode.ToString());
                webResponse.Close();
            }
            catch (Exception e)
            {
                logger.Log("{0}: couldn't talk to the camera. are the arguments correct?\n exception details: {1}", this.ToString(), e.ToString());

                //don't return. maybe the camera will come online later
                //return;
            }

            //add the camera service port
            VPortInfo pInfo = GetPortInfoFromPlatform("foscam-" + cameraId);

            //List<VRole> roles = new List<VRole>() {RoleCamera.Instance, RolePTCamera.Instance};
            List <VRole> roles = new List <VRole>()
            {
                RolePTCamera.Instance
            };

            cameraPort = InitPort(pInfo);
            BindRoles(cameraPort, roles, OnOperationInvoke);

            RegisterPortWithPlatform(cameraPort);


            switch (videoFetchMode)
            {
            case VideoFetchMode.SelfParse:
                worker1 = new SafeThread(delegate()
                {
                    GetVideoSelfParse();
                }, "GetVideoSelfParse", logger);
                worker1.Start();
                break;

            case VideoFetchMode.FromFile:
                worker2 = new SafeThread(delegate()
                {
                    GetVideoFromFile();
                }, "GetVideoFromFile", logger);
                worker2.Start();
                break;

            case VideoFetchMode.MjpegDecoder:
                GetVideoMjpegDecoder();
                break;

            default:
                logger.Log("Unknown video fetching mode");
                break;
            }

            imageServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger);
        }
コード例 #9
0
        private void cctv_Unloaded(object sender, RoutedEventArgs e)
        {
            if (decoder != null)
            {
                decoder.Close();
                 
                decoder = null;
               CnCnt--;
            }

           
        }