-
-
Notifications
You must be signed in to change notification settings - Fork 73
1) Fix splitting options by coma. 2) Also decode POST arguments. 3) Fix handling Array of Rectangles #170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
libcamera_parse_control_value() splits options by coma which makes sense for many options but it mishandles options like: "AfWindows=(1152,1296)/2304x1296" or "ScalerCrop=(0,0)/4608x2592". Example: ./camera-streamer --camera-path=/base/soc/i2c0mux/i2c@1/imx708@1a --camera-type=libcamera --camera-options="AfWindows=(1152,1296)/2304x1296" 2>&1 |grep AfWindows device/libcamera/options.cc: CAMERA: Configuring option 'AfWindows' (00000025, type=9) = [ (0, 0)/0x0, (0, 0)/0x0 ] It parsed option incorrectly end got [ (0, 0)/0x0, (0, 0)/0x0 ] result. Same for ScalerCrop: ./camera-streamer --camera-path=/base/soc/i2c0mux/i2c@1/imx708@1a --camera-type=libcamera --camera-options="ScalerCrop=(0,0)/4608x2592" 2>&1 |grep ScalerCrop device/libcamera/options.cc: CAMERA: Configuring option 'ScalerCrop' (0000001b, type=9) = [ (0, 0)/0x0, (0, 0)/0x0 ] With fix options are parsed and interpreted correctly: ./camera-streamer --camera-path=/base/soc/i2c0mux/i2c@1/imx708@1a --camera-type=libcamera --camera-options="AfWindows=(1152,1296)/2304x1296" 2>&1 |grep AfWindows device/libcamera/options.cc: CAMERA: Configuring option 'AfWindows' (00000025, type=9) = (1152, 1296)/2304x1296 ./camera-streamer --camera-path=/base/soc/i2c0mux/i2c@1/imx708@1a --camera-type=libcamera --camera-options="ScalerCrop=(0,0)/4608x2592" 2>&1 |grep ScalerCrop device/libcamera/options.cc: CAMERA: Configuring option 'ScalerCrop' (0000001b, type=9) = (0, 0)/4608x2592 Fixes #114
libcamera_parse_control_value needs to create Span (Array) of Rectangles when original type is an Span (Array). This change implements that. Avoids assert: $ ./camera-streamer --camera-path=/base/soc/i2c0mux/i2c@1/imx708@1a --camera-type=libcamera --camera-options="AfWindows=(0,0)/500x500" --http-listen=0.0.0.0 [...] device/libcamera/options.cc: CAMERA: Configuring option 'AfWindows' (00000025, type=9) = (0, 0)/500x500 [... and when stream client connects...] camera-streamer: ../include/libcamera/controls.h:204: T libcamera::ControlValue::get() const [with T = libcamera::Span<const libcamera::Rectangle>; typename std::enable_if<(libcamera::details::is_span<U>::value || std::is_same<std::__cxx11::basic_ string<char>, typename std::remove_cv< <template-parameter-1-1> >::type>::value), std::nullptr_t>::type <anonymous> = nullptr]: Assertion `isArray_' failed. Aborted
ayufan
requested changes
Jun 8, 2025
| } | ||
|
|
||
| // Helper function to decode percent-encoded strings | ||
| char *url_decode(const char *str) { |
Owner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arekm Would you mind opening separate PR with this change only? And put opening brace on a new line.
Contributor
Author
Closed
ayufan
added a commit
that referenced
this pull request
Jul 2, 2025
ayufan
added a commit
that referenced
this pull request
Jul 2, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
libcamera_parse_control_value() splits options by coma which makes sense for many options but it mishandles options like:
"AfWindows=(1152,1296)/2304x1296" or "ScalerCrop=(0,0)/4608x2592".
Example:
./camera-streamer --camera-path=/base/soc/i2c0mux/i2c@1/imx708@1a --camera-type=libcamera --camera-options="AfWindows=(1152,1296)/2304x1296" 2>&1 |grep AfWindows device/libcamera/options.cc: CAMERA: Configuring option 'AfWindows' (00000025, type=9) = [ (0, 0)/0x0, (0, 0)/0x0 ]It parsed option incorrectly end got wrong [ (0, 0)/0x0, (0, 0)/0x0 ] result.
Same for ScalerCrop:
./camera-streamer --camera-path=/base/soc/i2c0mux/i2c@1/imx708@1a --camera-type=libcamera --camera-options="ScalerCrop=(0,0)/4608x2592" 2>&1 |grep ScalerCrop device/libcamera/options.cc: CAMERA: Configuring option 'ScalerCrop' (0000001b, type=9) = [ (0, 0)/0x0, (0, 0)/0x0 ]With fix options are parsed and interpreted correctly:
./camera-streamer --camera-path=/base/soc/i2c0mux/i2c@1/imx708@1a --camera-type=libcamera --camera-options="AfWindows=(1152,1296)/2304x1296" 2>&1 |grep AfWindows device/libcamera/options.cc: CAMERA: Configuring option 'AfWindows' (00000025, type=9) = (1152, 1296)/2304x1296so expected (1152, 1296)/2304x1296
./camera-streamer --camera-path=/base/soc/i2c0mux/i2c@1/imx708@1a --camera-type=libcamera --camera-options="ScalerCrop=(0,0)/4608x2592" 2>&1 |grep ScalerCrop device/libcamera/options.cc: CAMERA: Configuring option 'ScalerCrop' (0000001b, type=9) = (0, 0)/4608x2592and also expected (0, 0)/4608x2592
Fixes #114
Also decode POST arguments, so if you set option like ScalerCrop fro web UI you will get it correctly applied.
For example set via web ui: ScalerCrop to (964,436)/3000x1920
With fix:
util/http/http.c: HTTP8080/5: Request 'POST' '/option' 'device=CAMERA&key=scalercrop&value=(964%2C436)%2F3000x1920' device/libcamera/options.cc: CAMERA: Configuring option 'ScalerCrop' (0000001b, type=9) = (964, 436)/3000x1920Fixes #115
Also libcamera_parse_control_value needs to create Span (Array) of Rectangles
when original type is an Span (Array).
This change implements that.
Avoids assert:
$ ./camera-streamer --camera-path=/base/soc/i2c0mux/i2c@1/imx708@1a --camera-type=libcamera --camera-options="AfWindows=(0,0)/500x500" --http-listen=0.0.0.0 [...] device/libcamera/options.cc: CAMERA: Configuring option 'AfWindows' (00000025, type=9) = (0, 0)/500x500 [... and when stream client connects...] camera-streamer: ../include/libcamera/controls.h:204: T libcamera::ControlValue::get() const [with T = libcamera::Span<const libcamera::Rectangle>; typename std::enable_if<(libcamera::details::is_span<U>::value || std::is_same<std::__cxx11::basic_ string<char>, typename std::remove_cv< <template-parameter-1-1> >::type>::value), std::nullptr_t>::type <anonymous> = nullptr]: AssertionisArray_' failed.Aborted
`
Fixes #171