RenderHeads / UnityPlugin-AVProVideo

AVPro Video is a multi-platform Unity plugin for advanced video playback
https://www.renderheads.com/products/avpro-video/
238 stars 28 forks source link

[macOS] Add support for playing from server with self-signed certificate #1575

Open kijz opened 1 year ago

kijz commented 1 year ago

I am encountering problems when trying to view the Livestream of Hololens 2 via Device Portal API

When trying to load the URL (https://{ip}/api/holographic/stream/live.mp4) via the Demo_MediaPlayer.MediaPlayer in Unity, i get the following error:

[AVProVideo] Error: Loading failed.  File not found, codec not supported, video resolution too high or insufficient system resources.
UnityEngine.Debug:LogError (object)
RenderHeads.Media.AVProVideo.MediaPlayer:UpdateErrors () (at Assets/AVProVideo/Runtime/Scripts/Components/MediaPlayer.cs:1399)
RenderHeads.Media.AVProVideo.MediaPlayer:Update () (at Assets/AVProVideo/Runtime/Scripts/Components/MediaPlayer.cs:827)

, where the IP is the hololens device ip on my local network. I made sure that i provide Authentication via HTTP headers, so that is not the problem.

Via chrome developer tools, i could find out that the incoming data is of Content-Type video/mp4, and i think that i read that it is h264 encoded, so that should work.

On safari however, this stream does not work, which seems to be an underlying rendering problem with safari. Because of this issue, i am looking for alternatives as i want to support iOS devices, and my current solution of using a browser instance inside of unity does not work because of iOS always using some type of safari browser.

My gut tells me that this might be some kind of security/ SSL certificate issue with the Hololens 2 server, which provides the stream over API. For other communication with the Device Portal API, I use Unity Web Request like this:

        var request = UnityWebRequest.Get(url);
        request.certificateHandler = new ForceAcceptAll();
        request.SetRequestHeader("Authorization", ConfigReader.RESTApiConfig.BasicAuth)

Note that we have to explicity allow every certificate. Could this cause issue with the VideoPlayer and/or the underlying Platform specific implementation? I know that this might raise security concerns, but in this case the Devices are not connected via Internet but rather in a local network, so attacks are kind of a non issue. I attached a screenshot of the error that UnityWebRequest when i make a GET Request on the Device Portal API without request.certificateHandler = new ForceAcceptAll();

Any kind of help or nudge in the right direction is greatly appreciated.

Your Setup (please complete the following information):

To Reproduce

  1. Have an unsafe server (unfortunately this is the case for Hololens 2)
  2. Request live stream via url
  3. Error occurs

Screenshots

Screenshot showing the Hololens server is considered unsafe: Screenshot 2023-06-28 at 17 17 19

Unity error that happens when I do not ForceAcceptAll certificates: Screenshot 2023-06-28 at 17 19 41

kijz commented 1 year ago

wanted to also mention issue https://github.com/RenderHeads/UnityPlugin-AVProVideo/issues/1145, since i think this is basically the same problem. I also saw some certificate errors in his logs, so that's why i assume it is the same in my case. Hope that helps in any way

Chris-RH commented 1 year ago

From reading, this should be possible, but we need to do a bit more research into supporting self-signed certificates on (i|mac)OS.

kijz commented 1 year ago

Thanks for replying. Please let me know if i can do anything to help out.