Latest news about Bitcoin and all cryptocurrencies. Your daily crypto news habit.
Being able to control your house, open doors, view in real time your living room, control the lights is a childhood dream! I was really delighted to develop an app and a pod to ease the development of ONVIF iOSÂ apps.
ONVIF goal is to standardise how IP products (video surveillance cameras, alarms, doors, audio recorders…) communicate with each others. They created some specifications manufacturers have to conform to be compliant with ONVIF. The goal behind these specifications is to standardise how to connect to these products, for instance if you develop an app for streaming video from an ONVIF camera, it should work with every ONVIF camera.
Try it!
If you just want to try the demo project, open a terminal and run pod try ONVIFCamera
You will be able to login on every ONVIF camera and view its live stream:
How to connect to a camera and visualise its live stream on iOS? 👨🏽‍💻
- Create a new project on Xcode
- In your terminal type: pod init
- Add pod `ONVIFCamera` to your Podfile and run pod install
Once it’s done, you can add the following code to connect to the camera and retrieve its information:
To be able to see the live stream of the camera we need to retrieve the different profiles (media profiles, with different configurations available) from the camera, select the one we want to play and retrieve the corresponding stream URI.
Here is how we retrieve the profiles and the stream URI:
Depending on your camera, your URI will look like this one: rtsp://IP_ADDRESS:PORT/cam/realmonitor?channel=1 etc...
The URI does not follow the http protocol, but the rtsp protocol, which is normal because RTSP (Real Time Streaming Protocol) is aiming to make streaming simpler. The problem is, AVPlayer doesn’t handle RTSP. Fortunately, VLC comes to the rescue!
How to read a RTSP stream on iOS? 🎥
- Add the pod MobileVLCKit to your Podfile and run pod install
- After adding VLC as a pod, your project shouldn’t link anymore. On my side, I have 78 link errors. To fix it, simply add an Objective-C++ file (for instance forVLCLink.mm )
- Once your project is compiling you can import MobileVLCKit in your bridging header.
- Here is how you play the video with MobileVLCKit once you have the rtsp URI:
Tip: You can also insert the login and password in the rtsp uri like this: rtsp://login:password@IP_ADDRESS:PORT/cam/realmonitor?channel=1 etc.. . If you use the ONVIFCamera pod, the URI saved in ONVIFCamera.streamURI already contains the login and password.
Creating an ONVIF library was a exciting opportunity, as you can see in my previous posts, I really enjoy having an interaction between my iOS apps and hardware devices, whether it’s a printer for iPhone, a camera, or even a door! I’m really looking forward to test new ONVIF devices and develop apps that can be useful for everyone that has ONVIF devices.
If you have any question, I’ll be happy to read them in the comments!
Live stream an ONVIF Camera on your iOS app! 📱 was originally published in Hacker Noon on Medium, where people are continuing the conversation by highlighting and responding to this story.
Disclaimer
The views and opinions expressed in this article are solely those of the authors and do not reflect the views of Bitcoin Insider. Every investment and trading move involves risk - this is especially true for cryptocurrencies given their volatility. We strongly advise our readers to conduct their own research when making a decision.