Skip to content

Commit

Permalink
Reject bad commands for realsense
Browse files Browse the repository at this point in the history
  • Loading branch information
Levi-Lesches committed Jan 30, 2024
1 parent b0a3ec3 commit d6f2c2f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/src/isolates/child.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<IsolatePayload, VideoCommand> {
/// Holds the current details of the camera.
final CameraDetails details;
Expand Down Expand Up @@ -44,7 +51,13 @@ abstract class CameraIsolate extends IsolateChild<IsolatePayload, VideoCommand>
}

@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) {
Expand Down

0 comments on commit d6f2c2f

Please sign in to comment.