From d6f2c2fb2ca07266872925958c8529475496393e Mon Sep 17 00:00:00 2001 From: Levi Lesches Date: Mon, 29 Jan 2024 23:30:17 -0500 Subject: [PATCH] Reject bad commands for realsense --- lib/src/isolates/child.dart | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/src/isolates/child.dart b/lib/src/isolates/child.dart index dc969e7..c30b854 100644 --- a/lib/src/isolates/child.dart +++ b/lib/src/isolates/child.dart @@ -9,6 +9,13 @@ import "package:video/video.dart"; const maxPacketLength = 60000; // max UDP packet size in bytes +extension on CameraDetails { + bool get interferesWithAutonomy => hasResolutionHeight() + || hasResolutionWidth() + || hasFps() + || hasStatus(); +} + abstract class CameraIsolate extends IsolateChild { /// Holds the current details of the camera. final CameraDetails details; @@ -44,7 +51,13 @@ abstract class CameraIsolate extends IsolateChild } @override - void onData(VideoCommand data) => updateDetails(data.details); + void onData(VideoCommand data) { + if (data.details.interferesWithAutonomy) { + sendLog(LogLevel.error, "That would break autonomy"); + } else { + updateDetails(data.details); + } + } /// Updates the camera's [details], which will take effect on the next [sendFrame] call. void updateDetails(CameraDetails newDetails) {