Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by HazelShi103 · Dec 03, 2018 at 06:40 AM · unityeditoraugmented-realitywebrequestvideo streamingauthentication

HttpWebRequest doesn't work with Hololens

Hey guys, I'm trying to stream CCTV live video to Hololens, it works fine in Unity Editor but failed in Hololens with an exception of "connect failure TLS support not available".

I know UnityWebRequest works better for Hololens but I have to use the HttpWebRequestin this case because of the credentials.

Is it because Hololens doesn't support HttpWebRequest? I'm using unity 2018.1.9f2.

My code:

 public void GetVideo() 
 {
     texture = new Texture2D(2, 2);
     HttpWebRequest www = (HttpWebRequest)WebRequest.Create(sourceURL);
     www.Credentials = new NetworkCredential("Username", "password");
     ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback((sender, certificate, chain, policyErrors) => { return true; });
     debugText.text += "\ngetting certification";
     try
     {
         HttpWebResponse resp = (HttpWebResponse)www.GetResponse();
         stream = resp.GetResponseStream();
     }
     catch(Exception ex)
     {
         debugText.text += "\n"+ex.Message.ToString();
     }
     StartCoroutine(GetFrame());
 }

 IEnumerator GetFrame()
 {
     Byte[] JpegData = new Byte[65536];
     while (stream != null)
     {
         if(streamOnce == false)
         {
             streamOnce = true;
         }
         int bytesToRead = FindLength(stream);
         print(bytesToRead);
         if (bytesToRead == -1)
         {
             print("End of stream");
             yield break;
         }
         int leftToRead = bytesToRead;
         while (leftToRead > 0)
         {
             leftToRead -= stream.Read(JpegData, bytesToRead - leftToRead, leftToRead);
             yield return null;
         }
         MemoryStream ms = new MemoryStream(JpegData, 0, bytesToRead, false, true);
         texture.LoadImage(ms.GetBuffer());
         frame.material.mainTexture = texture;
         stream.ReadByte(); // CR after bytes
         stream.ReadByte(); // LF after bytes
     }
 }

 int FindLength(Stream stream)
 {
     int b;
     string line = "";
     int result = -1;
     bool atEOL = false;

     while ((b = stream.ReadByte()) != -1)
     {
         if (b == 10) continue; // ignore LF char
         if (b == 13)
         { // CR
             if (atEOL)
             {  // two blank lines means end of header
                 stream.ReadByte(); // eat last LF
                 return result;
             }
             if (line.StartsWith("Content-Length:"))
             {
                 result = Convert.ToInt32(line.Substring("Content-Length:".Length).Trim());
             }
             else
             {
                 line = "";
             }
             atEOL = true;
         }
         else
         {
             atEOL = false;
             line += (char)b;
         }
     }
     return -1;
 }
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

163 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Help with options menu in unity 0 Answers

Stream while simultaneously downloading video from URL using video player 0 Answers

UnityWebRequest.Post Returning Empty String 0 Answers

AR Game Crashes after launch (AR Foundation/Android) 0 Answers

How to solve PrecompiledAssemblyException? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges