handleData method

void handleData(
  1. VideoData newData
)

Updates the data for a given camera.

Implementation

void handleData(VideoData newData) {
	if (
		(newData.hasFrame() && newData.details.name == CameraName.CAMERA_NAME_UNDEFINED) ||
		newData.details.status == CameraStatus.CAMERA_HAS_NO_NAME
	) {
		models.home.setMessage(severity: Severity.critical, text: "Received feed from camera #${newData.id} with no name");
		return;
	}
	final name = newData.details.name;
	final data = feeds[name]!
		..details = newData.details
		..id = newData.id;

	// Some [VideoData] packets are just representing metadata, not an empty video frame.
	// If this is one such packet (doesn't have a frame but status == enabled), don't save.
	if (newData.hasFrame() && newData.details.status == CameraStatus.CAMERA_ENABLED) {
		data.frame = newData.frame;
		framesThisSecond[name] = (framesThisSecond[name] ?? 0) + 1;
	}
}