sendFrame method
- Uint8List image, {
- CameraDetails? detailsOverride,
Sends an individual frame to the dashboard.
This function also checks if the frame is too big to send, and if so, lowers the JPG quality by 1%. If the quality reaches 25% (visually noticeable), an error is logged instead.
Implementation
void sendFrame(Uint8List image, {CameraDetails? detailsOverride}) {
final details = detailsOverride ?? this.details;
if (image.length < maxPacketLength) { // Frame can be sent
sendToParent(FramePayload(details: details, image: image));
} else if (details.quality > 25) { // Frame too large, lower quality
sendLog(LogLevel.debug, "Lowering quality for $name from ${details.quality}");
details.quality -= 1; // maybe next frame can send
} else { // Frame too large, quality cannot be lowered
sendLog(LogLevel.warning, "Frame from camera $name are too large (${image.length})");
updateDetails(CameraDetails(status: CameraStatus.FRAME_TOO_LARGE));
}
}