[−][src]Function v4l::v4l2::api::mmap
pub unsafe fn mmap(
start: *mut c_void,
length: usize,
prot: c_int,
flags: c_int,
fd: c_int,
offset: i64
) -> Result<*mut c_void>
A convenience wrapper around v4l2_mmap.
In case of errors, the last OS error will be reported, aka errno on Linux.
Arguments
start
- Starting address of the new mapping, usually NULLlength
- Length of the mapped regionprot
- Desired memory protection of the mapped regionflags
- Mapping flagsfd
- File descriptor representing an opened deviceoffset
- Offset in the source region, usually 0
Safety
Start must be a raw pointer. Thus, the entire function is unsafe.
Example
extern crate v4l; use std::ptr; use v4l::v4l2; let fd = v4l2::open("/dev/video0", libc::O_RDWR); if let Ok(fd) = fd { /* VIDIOC_REQBUFS */ /* VIDIOC_QUERYBUF */ let mapping_length: usize = 1000; unsafe { let mapping = v4l2::mmap(ptr::null_mut(), mapping_length, libc::PROT_READ | libc::PROT_WRITE, libc::MAP_SHARED, fd, 0); } v4l2::close(fd).unwrap(); }