VideoWebRTC

The VideoWebRTC class represents a video stream that can be viewed through Homey. It provides functionality to implement WebRTC-based video streaming.

Camera instances are created through ManagerVideos#createVideoWebRTC and should be associated with a device using Device#setCameraVideo to enable video streaming in the Homey interface.

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): VideoWebRTC

Register 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): VideoWebRTC

Register 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.

Returns