Setting Up Live Streaming

To see the live view the user will have to obtain a LiveViewModel from LiveViewObjectStore, which creates the model or returns the cached one for that camera. Streaming starts when you call connect on it — see Rendering Live View.


Initiating a Live Stream Connection

To create a LiveViewModel you will need

  • objectType (required): .liveView for a live stream, .cvrPlayback for SD card playback.
  • spaceId (required): The spaceId of the space to which the camera belongs.
  • deviceId (required): The deviceId of the camera you want to connect to.
  • wakeup (required): This should be set to true for cameras that are battery operated.
  • supportsCalling (optional): This should be set to true if camera supports 2 way video call.
  • supportRSSI (optional): This should be set to true if camera supports wifi rssi feature.
  • hardwareConfig (optional): Pass hardware config of camera for display resolution, sensor resolution, stitched sensors and multi-stream sensors — the latter decides how many IVVideoViews the model renders into.
  • supportTemperature (optional): This should be set to true if camera supports Temperature.
  • supportHumidity (optional): This should be set to true if camera supports Humidity.
  • sensorId (optional): If the camera has multi sensors(lens) the send the sensorId you want to see live view/cvr playback.

You can create an object likewise:

let liveViewObject = LiveViewObjectStore.objectFor(
    .liveView,
    spaceId: "spaceId",
    deviceId: "deviceId",
    wakeup: device.isMcuSupported,
    supportsCalling: device.supportsVideoCall,
    supportRSSI: clusters.supportRSSI,
    hardwareConfig: clusters.hardwareConfig,
    supportTemperature: clusters.supportsTemperature,
    supportHumidity: clusters.supportsHumidity,
    sensorId: "sensorId"
    )

clusters is the CameraClustersModel returned by getDeviceClusters; supportRSSI and hardwareConfig are extensions on it.

Except hardwareConfig, these flags are honoured only when the object is first created. A later objectFor for the same camera returns the cached object unchanged; to change a flag, drop the cached object first with terminateConnectionForDevice(…, deleteCamera: true).


Terminating the connection for a device

To terminate the live view and/or the playback session of a single camera, The following method can be used:

  • objectType (optional): Pass .liveView or .cvrPlayback to terminate only that session. Pass nil to terminate both.
  • spaceId (required): The spaceId of the space to which the camera belongs.
  • deviceId (required): The deviceId of the camera.
  • privacyEnable (required): Whether the camera is entering privacy mode.
  • deleteCamera (optional): Pass true when the camera is being unpaired, which also removes the cached object.
LiveViewObjectStore.terminateConnectionForDevice(
    objectType: LiveViewObjectStore.ObjectType?,
    spaceId: String,
    deviceId: String,
    privacyEnable: Bool,
    deleteCamera: Bool
)

Clearing all objects on logout

To terminate every live view and playback session, remove their callbacks and empty the cache, The following method can be used:

LiveViewObjectStore.logout()

Disconnecting on app termination

To close the running WebRTC connections when the app is being terminated, The following method can be used:

LiveViewObjectStore.disconnectOnAppTermination()