简体   繁体   中英

Open Source URL with login and password

I am working on preparing a Media Foundation session that reads a video stream from a network security camera, displays it on screen and encodes it to disk. I have everything working with a webcam and now I'm trying to connect to the network camera using the IMFSourceResolver 's CreateObjectFromURL() . The problem is that the camera requires a login and password and formatting the URL as:

rtsp://login:password@IPaddr

still results in a "permission denied" response.

MSDN has a few pages on using IMFNetCredentialManager to provide the user name and password, but it is not working and I still get permission denied. Using WireShark I can see that the camera responds with the "Unauthorized" RTSP response to the first MF connection attempt, and then MF just gives up and doesn't check the credential manager, ending in failure.

I don't find any other example using IMFNetCredentialManager out there. It seems like reading a video stream from an IP camera that requires a password should be a common task yet I can find no evidence of it being done in practice. Is it possible to do with Media Foundation or is there another approach that I missed?

After completing my research, here is the conclusion that I have reached.

Windows Media Foundation provides good (but not thorough) support for USB webcams and basic streaming. It is just a foundation though. Anything more advanced like communicating with a networked IP camera requires a lot of extra work by the programmer to fully implement their protocol of choice, like RTSP, HTTP or ONVIF.

I was expecting that I could set up a media session for a webcam and then simply switch the source to a network camera with RTSP by using the source resolver with a URL. Authorization using the network credential manager as shown in MSDN is not part of the media source provided by Media Foundation, which is why BeginGetCredentials() is not called. It is just an example of what you need to implement with your own scheme.

My solution is therefore to abandon using Media Foundation and go with a 3rd party library from LEADTOOLS, etc. It costs money, but otherwise it would cost a lot more development time for me to create what I need.

I hope this answer helps save someone all the time I spent chasing this rabbit into the abyss!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM