CameraRecordingDelegate is responsible for handling recordings of a HomeKit Secure Video camera.
Before recording is considered enabled two things must happen:
A typical recording event scenario happens as follows:
This method is called once the HomeKit Controller acknowledges the
endOfStream is sent by the accessory by setting isLast to
true in the last packet yielded
by the handleRecordingStreamRequest
The streamId of the acknowledged stream.
This method is called to notify the delegate that a recording stream started via handleRecordingStreamRequest was closed.
The method is also called if an ongoing recording stream is closed gracefully (using NORMAL).
In either case, the delegate should stop supplying further fragments to the recording stream.
AsyncGenerator function must return without yielding any further RecordingPackets.
HAP-NodeJS won't send out any fragments from this point onwards.
The streamId for which the close event was sent.
The reason with which the stream was closed.
NOTE: This method is also called in case of a closed connection. This is encoded by setting the
reason to undefined.
This method is called to stream the next recording event. It is guaranteed that there is only ever one ongoing recording stream request at a time.
When this method is called return the currently ongoing (or next in case of a potentially queued)
recording via a
yield of the generator represents a complete recording
The first packet MUST always be the MEDIA_INITIALIZATION packet.
Any following packet will transport the actual mp4 fragments in MEDIA_FRAGMENT packets,
starting with the content of the prebuffer. Every MEDIA_FRAGMENT starts with a key frame
and must not be longer than the specified duration set via the
selected by the HomeKit Controller in updateRecordingConfiguration.
NOTE: You MUST respect the value of RecordingAudioActive characteristic of the CameraOperatingMode
service. When the characteristic is set to false you MUST NOT include audio in the mp4 fragments. You can access the characteristic via
There are three ways an ongoing recording stream can be closed:
true. Once the HomeKit Controller receives this last fragment it will call acknowledgeStream to notify the accessory about the successful transmission.
Once a close of stream is signaled, the
AsyncGenerator function must return gracefully.
For more information about
AsyncGenerators you might have a look at:
NOTE: HAP-NodeJS guarantees that this method is only called with a valid selected CameraRecordingConfiguration.
NOTE: Don't rely on the streamId for unique identification. Two DataStreamConnections might share the same identifier space.
The streamId of the currently ongoing stream.
A call to this method notifies the
CameraRecordingDelegate about a change to the
CameraRecordingManagement.Active characteristic. This characteristic controls
if the camera should react to recording events.
If recording is disabled the camera can stop maintaining its prebuffer. If recording is enabled the camera should start recording into its prebuffer.
CameraRecordingDelegate should assume active to be
false on startup.
HAP-NodeJS will persist the state of the
Active characteristic across reboots
and will call updateRecordingActive accordingly on startup, if recording was previously enabled.
NOTE: HAP-NodeJS cannot guarantee that a CameraRecordingConfiguration is present
when recording is activated (e.g. the selected configuration might be erased due to changes
in the supplied CameraRecordingOptions, but the camera is still
active; or we can't otherwise
influence the order which a HomeKit Controller might call those characteristics).
However, HAP-NodeJS guarantees that if there is a valid CameraRecordingConfiguration,
updateRecordingConfiguration is called before updateRecordingActive (when enabling)
to avoid any unnecessary and potentially expensive reconfigurations.
Specifies if recording is active or not.
A call to this method signals that the selected (by the HomeKit Controller) recording configuration of the camera has changed.
On startup the delegate should assume
configuration = undefined.
HAP-NodeJS will persist the state of both across reboots and will call
updateRecordingConfiguration on startup if there is a selected configuration present.
NOTE: An update to the recording configuration might happen while there is still a running recording stream. The camera MUST continue to use the previous configuration for the currently running stream and only apply the updated configuration to the next stream.
The CameraRecordingConfiguration. Reconfigure your recording pipeline accordingly.
The parameter might be
undefined when the selected configuration became invalid. This typically ony happens
e.g. due to a factory reset (when all pairings are removed). Disable the recording pipeline in such a case
even if recording is still enabled for the camera.