Skip to content

Conversation

@leeebo
Copy link
Collaborator

@leeebo leeebo commented Nov 12, 2025

Description

  1. Support user-provided frame buffers for zero-copy operation. Right now, You can now pass your own buffers to the driver through the user_frame_buffers field. The driver will write frames directly to your buffers, skipping the copy entirely.
  2. Fixed assertion failure when receiving packets with unexpected frame_id. In some cameras, we encountered this situation. Perhaps it was because the USB transfer speed was insufficient that some data packets were lost inside the camera.

Backward Compatibility

The new user_frame_buffers field is optional and defaults to NULL. If you don't set it, everything works exactly as before - no code changes needed.

However, out of caution, I've bumped the minor version to 2.4.0. While this shouldn't technically break anything (it's an additive change), the buffer management behavior does change when the new field is used. Better safe than sorry - this gives users a clear signal that something noteworthy was added.

Related

Testing

  • Test ESP32-P4 with USB Camera with 720P resolution

Checklist

Before submitting a Pull Request, please ensure the following:

  • 🚨 This PR does not introduce breaking changes.
  • All CI checks (GH Actions) pass.
  • Documentation is updated as needed.
  • Tests are updated or added as necessary.
  • Code is well-commented, especially in complex areas.
  • Git history is clean — commits are squashed to the minimum necessary.

Note

Adds zero-copy streaming via user-provided frame buffers and fixes bulk handling for unexpected frame_id, with tests and version bump to 2.4.0.

  • API:
    • Add advanced.user_frame_buffers to uvc_host_stream_config_t for user-provided frame buffers.
    • Extend uvc_frame_allocate() to accept user_frame_buffers.
  • Driver/Memory:
    • Track user_provided_fb and avoid freeing user buffers in uvc_frame_free().
    • Validate user buffers in uvc_host_stream_open() and pass into uvc_frame_allocate().
  • Streaming (Bulk):
    • Treat packets with unexpected frame_id as errors and skip the frame (instead of asserting).
  • Tests:
    • Update unit tests to new uvc_frame_allocate() signature.
    • Add integration test for streaming with user-provided buffers (pointer verification).
  • Release:
    • Bump component version to 2.4.0 and update CHANGELOG.md.

Written by Cursor Bugbot for commit bf96b6f. This will update automatically on new commits. Configure here.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is being reviewed by Cursor Bugbot

Details

Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

@leeebo leeebo force-pushed the feat/usb_host_uvc_support_user_buffers branch 2 times, most recently from f51830e to afe693e Compare November 12, 2025 09:20
@leeebo leeebo force-pushed the feat/usb_host_uvc_support_user_buffers branch from afe693e to bf96b6f Compare November 12, 2025 09:40
if (payload_header->bmHeaderInfo.end_of_frame) {
assert(payload_header->bmHeaderInfo.frame_id == uvc_stream->single_thread.current_frame_id);
if (payload_header->bmHeaderInfo.error) {
if (payload_header->bmHeaderInfo.error || payload_header->bmHeaderInfo.frame_id != uvc_stream->single_thread.current_frame_id) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a workaround to prevent a system assert in this case. However, the issue still remains — the SOF of the next frame is not handled, causing both the current and the next frame to be dropped. We plan to include a better fix in #308

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant