This project has moved. For the latest updates, please go here.

Need an Authentication Option

Feb 11, 2011 at 4:37 PM
Edited Feb 11, 2011 at 4:43 PM

There is no option to provide credentials when connecting to the camera.  Many IP cameras support basic HTTP authentication.  It would be nice if this was an option.  I added one to my code as follows:

 

        public void ParseStream(Uri uri)
        {
            ParseStream(uri, string.Empty, string.Empty);
        }

        public void ParseStream(Uri uri, string username, string password)
		{
#if SILVERLIGHT
			HttpWebRequest.RegisterPrefix("http://", WebRequestCreator.ClientHttp);
#endif
			HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri);
            //set the username and password if provided
            if (!(string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password)))
            {
                request.Credentials = new NetworkCredential(username, password);
            }
#if SILVERLIGHT
			// start the stream immediately
			request.AllowReadStreamBuffering = false;
#endif
			// asynchronously get a response
			request.BeginGetResponse(OnGetResponse, request);
		}