-
-
Notifications
You must be signed in to change notification settings - Fork 617
IP Camera
iOS 10 added support for IP Camera to HomeKit. HAP-NodeJS updated to support IP Camera with v0.4.0.
To use IP Camera with HAP-NodeJS, you will need construct a camera object and invoke Accessory. configureCameraSource(camera) to inform HAP-NodeJS the accessory supports IP Camera. You can use Camera.js as the reference and modify from there.
Please notice that due to protocol limitation, it's not possible to expose multiple cameras via a single HAP Endpoint. Aka trying to add a camera to a bridged accessory may result unexpected behavior.
A camera object in HAP-NodeJS must implements the following:
- services
Array of
Service
iOS expects a
CameraControlservice and aCameraRTPStreamManagementservice. The accessory can provide multipleCameraRTPStreamManagementservices to iOS. To simplify the stream parameter negotiation, HAP-NodeJS provides a helper classStreamControllerwhich handles the stream request from iOS device.
The number of
CameraRTPStreamManagementservices determines the number of concurrent streams the accessory can support. Apple recommends accessory to support at least two concurrent streams.
- handleSnapshotRequest(request, callback(error, snapshot))
This method will be invoked when iOS device requests snapshot from the accessory. The
requestcontainswidthandheightof the requested snapshot. Thecallbackis a function that expectserrororsnapshotimage buffer.
iOS expects the snapshot to be under JPEG format. Please try to honor the requested
widthandheightand not send a huge snapshot back to callback. HomeKit on iOS may crash when it receives a huge snapshot.
- prepareStream(request, callback(response))
This method will be invoked when iOS device tries to start video stream. The
requestcontains information likesessionID,targetAddressand other informations that will be used to setup RTP/RTCP stream. Thecallbackexpects a response which contains information supplied by accessory to setup RTP/RTCP stream. For more information about request and response, please refer to section Prepare Stream.
- handleStreamRequest(request)
This method will be invoked when iOS device requests accessory to start, stop or reconfigure the RTP stream. The request will contain basic information like
sessionIDalong with other parameters that will be helpful for streaming. For more information about handling stream request, please refer to section Handle Stream Request.