Skip to content

IP Camera

Khaos Tian edited this page Sep 25, 2016 · 18 revisions

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.

High Level Overview of Camera Object

A camera object in HAP-NodeJS must implements the following:

  • services

Array of Service

iOS expects a CameraControl service and a CameraRTPStreamManagement service. The accessory can provide multiple CameraRTPStreamManagement services to iOS. To simplify the stream parameter negotiation, HAP-NodeJS provides a helper class StreamController which handles the stream request from iOS device.

The number of CameraRTPStreamManagement services 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 request contains width and height of the requested snapshot. The callback is a function that expects error or snapshot image buffer.

iOS expects the snapshot to be under JPEG format. Please try to honor the requested width and height and 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 request contains information like sessionID, targetAddress and other informations that will be used to setup RTP/RTCP stream. The callback expects 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 sessionID along with other parameters that will be helpful for streaming. For more information about handling stream request, please refer to section Handle Stream Request.

Prepare Stream

Handle Stream Request

Clone this wiki locally