Example
Creating and configuring a WebRTC camera
// In your device.js file
async onInit() {
const video = await this.homey.videos.createVideoWebRTC({
options: {}
});
video.registerOfferListener(async (offerSdp) => {
// Handle WebRTC negotiation
return this.handleWebRTCOffer(offerSdp);
});
video.registerKeepAliveListener(async (streamId) => {
// Maintain active stream
await this.refreshStream(streamId);
});
await this.setCameraVideo('front_door', 'Front Door', video);
}
Instance Methods
registerKeepAliveListener
registerKeepAliveListener(listener): VideoWebRTCRegister a listener for WebRTC keep alive events. This is invoked when Homey sends keep alive signals for active WebRTC streams.
Parameters
Name | Type | Description |
---|---|---|
listener
|
function | Function that receives the stream ID. |
Returns
registerOfferListener
registerOfferListener(listener): VideoWebRTCRegister a listener for WebRTC offer events. This is invoked when Homey requests an SDP answer for a WebRTC offer.
Parameters
Name | Type | Description |
---|---|---|
listener
|
function | Function that receives the offer SDP and returns a promise that resolves with the answer SDP. |