-
Notifications
You must be signed in to change notification settings - Fork 65
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
basic multi-plane support #71
base: master
Are you sure you want to change the base?
Conversation
I would like to see this merged into a release as I am also interested in using this on an imx8 system. |
match self { | ||
Type::VideoCaptureMplane | Type::VideoOutputMplane => true, | ||
_ => false, | ||
} |
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.
Nit: there's a matches!(self, Type::VideoCaptureMplane | Type::VideoOutputMplane)
macro for this:
match self { | |
Type::VideoCaptureMplane | Type::VideoOutputMplane => true, | |
_ => false, | |
} | |
matches!(self, Type::VideoCaptureMplane | Type::VideoOutputMplane) |
let ptr = v4l2::mmap( | ||
ptr::null_mut(), | ||
plane.length as usize, | ||
libc::PROT_READ | libc::PROT_WRITE, | ||
libc::MAP_SHARED, | ||
self.handle.fd(), | ||
plane.m.mem_offset as libc::off_t, | ||
)?; | ||
|
||
planes.push(slice::from_raw_parts_mut::<u8>( | ||
ptr as *mut u8, plane.length as usize | ||
)); |
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.
When I tried to use this branch for my application, which use both multi plane and single plane, I received error with single plane device. This fix works with my environment.
let ptr = v4l2::mmap( | |
ptr::null_mut(), | |
plane.length as usize, | |
libc::PROT_READ | libc::PROT_WRITE, | |
libc::MAP_SHARED, | |
self.handle.fd(), | |
plane.m.mem_offset as libc::off_t, | |
)?; | |
planes.push(slice::from_raw_parts_mut::<u8>( | |
ptr as *mut u8, plane.length as usize | |
)); | |
let length = if !self.buf_type.planar() { v4l2_buf.length as usize } else { plane.length as usize }; | |
let ptr = v4l2::mmap( | |
ptr::null_mut(), | |
length, | |
libc::PROT_READ | libc::PROT_WRITE, | |
libc::MAP_SHARED, | |
self.handle.fd(), | |
plane.m.mem_offset as libc::off_t, | |
)?; | |
planes.push(slice::from_raw_parts_mut::<u8>( | |
ptr as *mut u8, length, | |
)); |
@raymanfx, @illegalprime, and @anatawa12 I have a project that uses a single plane, and a plan to add support for a multiple plane device. This PR only introduced only 1 breaking change (this project is still in 0 major, so that shouldn't be an issue) to my project, which is that |
Thank you for cleaning up the conflicts! Even though nobody's experience would necessarily break with this addition it should still not be merged until the author decides this is the abstraction they prefer. |
I care about creating a capture stream with a multi-plane camera. I have a basic version of it working, with inspiration from your mplane branch. What works: