RenderHeads / UnityPlugin-AVProVideo

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

Rtsp with httpheader not working in Windows or UWP by hololens2 #831

Open deskmath opened 3 years ago

deskmath commented 3 years ago

Describe the issue We have a problem to receive streaming by rtsp that contains username and password, if the streaming is anonymous the video plays correctly, but since we need httpheader it is impossible for us to connect, we put Authorization / Basic user: pass. We need an example and help to solve this problem, we are working with the free version before buying the premium.

Your Setup (please complete the following information):

Unity version: 2019.4.21f1 AVPro Video version: 2.1.5 trial Operating system version: Windows 10 / UWP Device model: Hololens2 Video specs (resolution, frame-rate, codec, file size): 1920*1080

Logs error: [AVProVideo] Error: Loading failed. File not found, codec not supported, video resolution too high or insufficient system resources.

Screenshots image image

AndrewRH commented 3 years ago

@deskmath have you tried changing the Video API to WinRT? HTTP headers on Windows/UWP is only supported using the WinRT API.

deskmath commented 3 years ago

With the AVPRO-Core version which is the one we had purchased:

With the AVPRO-Trial version:

image

deskmath commented 3 years ago

Greetings.

We are in a deadlock with this matter, we see from comments from other AV PRO buyers that this problem does not seem to be solved and we need to know if we are going to have help from you or look for another alternative, the waiting time is not acceptable .

We need more direct attention service. #RTSP #UWP

AndrewRH commented 3 years ago

Hmm, have you tried using this format for the URL instead of using HTTP Headers?

rtsp://username:password@url

deskmath commented 3 years ago

We have already tried in all possible ways according to your indications, and we cannot display video in UWP hololens 2 which is what we need.

Is it possible to have a more direct way of technical resolution with you? by mail or video call.

fallo

AndrewRH commented 3 years ago

I have found a crash bug in the WinRT implementation for parsing the Authorization HTTP header... busy working on a fix for this now. I will attach a new DLL for you to try shortly. Hopefully it works and we won't need to organise a video call.

Thanks,

AndrewRH commented 3 years ago

I believe the user:pass section for basic authorization needs to be base64 encoded. Could you try this please?

The website https://www.base64encode.org/ can be used to quickly convert your text, so that you have:

Basic

Thanks,

deskmath commented 3 years ago

The links that we put in AVpro are the same that we verify that they work from VLC, they are not encrypted as far as we know.

Does the core edition UWP version of AVPRO work with user: pass? or requires enterprise version.

AndrewRH commented 3 years ago

Custom HTTP Headers isn't supported in the Core edition, it is an Ultra edition feature (also included in Trial version).

"Basic user:pass" needs the user:pass encoded as Base64 (https://en.wikipedia.org/wiki/Basic_access_authentication#Client_side). Some others players might do this automatically, but we currently aren't.

Currently using the "Basic user:pass" format cases a crash because a colon isn't value in this field. We have fixed it so that it doesn't crash now, but if you could test with the Base64 encoded user:pass using the Trial/Ultra version, then you should see whether it works or not.

Thanks,

AndrewRH commented 3 years ago

Via code, this might look like:

string username = "user";
string password = "password";
var buffer = Windows.Security.Cryptography.CryptographicBuffer.ConvertStringToBinary(username + ":" + password, Windows.Security.Cryptography.BinaryStringEncoding.Utf16LE);
string base64token = Windows.Security.Cryptography.CryptographicBuffer.EncodeToBase64String(buffer);

mediaPlayer.PlatformOptionsWindows.httpHeaders.Add("Authorization", "Basic " + base64token);
mediaPlayer.PlatformOptionsWindowsUWP.httpHeaders.Add("Authorization", "Basic " + base64token);
deskmath commented 3 years ago

We are going to test what you indicate with the trial version for UWP in windows and hololens2 and we report what happens.

Taimloech commented 3 years ago

and the asset decodes base64 to read the header correctly? because have no result.

is the fixed of this bug uploaded? the new dll

deskmath commented 3 years ago

What is the dependency required for Unity to accept "CryptographicBuffer"? Can you pass a complete code example? manually we can't get it to work.

image

deskmath commented 3 years ago

image

We have solved the encoding in this way and after doing all the tests we confirmed that we cannot play video with WinRT in UWP or in Windows from rtsp, with username and pass and anonymous. We have only managed to play video from rtsp through windows foundation and anonymous. Sure this software can play rtsp streaming from WinRT? If so, we need more help.

AndrewRH commented 3 years ago

I see. Yeah when it comes to RTSP we're not really sure what Windows/WinRT supports - the documentation from Microsoft is very thin. We basically have to just try and see what works...

We don't have any Hololens hardware to test with. So basically we're not sure what sort of RTSP is supported, if any using WinRT... I was hoping it would work since Hololens supports RTSP and is based on WinRT/UWP......

deskmath commented 3 years ago

In case it helps there is a way that we have already tried and it works over RTSP in Holololens 2 and it is when the broadcast is anonymous, it does not need user: pass and AVPRO is configured in Media foundation.

If with this configuration we can see the streaming, it is better to find a solution to put the password on Media Foundation than to try to make it work through Win RT.

deskmath commented 3 years ago

I want you to understand that we have spent a lot of time trying to solve this problem several people thinking that it was something on our side, if it is something that you have not tried and it does not work you should put it in your documentation.

I do not know if you are going to dedicate resources to solve this bug , but at the cost of your product you should have the necessary resources and materials.

It is not normal for us to be your tester.

AndrewRH commented 3 years ago

I understand that, and am sorry that you spent a lot of time on this and in the end we weren't able to support RTSP with custom HTTP Headers.

It is not necessarily a bug - we rely on the features that the operating system supports for video playback features, and these are often poorly documented. This is certainly the case for RTSP which is why we do not really advertise that as a reliable feature (https://www.renderheads.com/content/docs/AVProVideo/articles/supportedmedia.html#streaming-formats) but we do our best to document these things.

On Media Foundation we might be able to add support for custom http headers, but it is a LOT of work so it's unlikely to happen. Even then it may have the same issue because we don't know whether Microsoft's implementation of RTSP even supports authentication using HTTP header....

Perhaps there is someone a Microsoft dev team that could shed some light on supporting this in Windows Media APIs

deskmath commented 3 years ago

Have you been able to work on a solution for this problem? You commented that you were going to create a dll as a temporary patch, at the moment we are waiting for a new update, it would be very helpful.

Thanks you.

AndrewRH commented 3 years ago

The new DLL just fixes the crash issue where passing in a HTTP header with "Basic user:pass" would cause a crash due to an exception thrown internally due to non base64 encoding. It doesn't add any new capabilities unfortunatly.

One thing you could try with DirectShow API - if you install LAV Filters and then add "LAV Video Decoder" to the list of preferred filters: image

And then instead of using HTTP headers for your user:pass, instead pass them in via the url in the format rtsp://user:pass@url.rtsp

We've been looking into this and have had some success.

Let me know if that works with your stream.

Thanks,

deskmath commented 3 years ago

Thanks for the quick response, the problem we have that the application is for hololens 2 and ARM64 and LAVfilters is for win10 so I don't know if there is any way to do it with dll we are at the same starting point.

deskmath commented 2 years ago

Greetings, I ask again about this topic, since I do not know if you have created a solution for rtsp transmission with username and password for arm64 in UWP. Thank you.

deskmath commented 2 years ago

@AndrewRH Greetings, we have a project that requires having this problem solved and we would like to know if you are working on it. We have an arrangement using other assets but it is not entirely efficient. Would it be possible to have some help with this problem?

mertusta1996 commented 1 year ago

With the AVPRO-Core version which is the one we had purchased:

  • rtsp (Anonymous) Foundation - Plays on UWP Hololens2 and win10.
  • rtsp (User Pass with HTTP Header) Foundation - Does not play
  • rtsp (User Pass with HTTP Header) Win RT - Does not play

With the AVPRO-Trial version:

  • rtsp (Anonymous) Foundation - Plays on AWP Hololens2.
  • rtsp (User Pass with HTTP Header) Foundation - Crash in Unity, win 10 and Hololens 2
  • rtsp (User Pass with HTTP Header) Win RT - Crash in Unity, win 10 and Hololens 2

image

Hi @deskmath , I want to ask a question about this message. You talk about "Plays on UWP Hololens2 and win10" with "rtsp (Anonymous) Foundation". I need to play rtsp stream in Unity Hololens2. But, while I'm testing the ways for playing rtsp video stream in Hololens2 with Unity app (Selecting Media Foundation) when using AVPro, I couldn't start the video stream in my application. It says the error I saw in debugging; "Error: Loading failed. File not found, codec not supported, video resolution too high or insufficient system resources."

Which type of stream (H264?, H265? or any other), which type of configurations for AVProManager and what's the key point for playing rtsp stream in Hololens2. I'm not using "HTTP Header", I'm trying the "Anonymous" pass type too.

I tried the stream link is like : rtsp://ip:port/xxx.sdp (But, I could change this link, with your successfull rtsp link like) I need the instructions for rtsp stream, and could apply the steps your succesfull rtsp streaming for hololens2. If you response my message and help, it would make me happy.