> Can you provide a little more detail on how to use mmap()? I have done the
> actual mmap part but how do i use the buffers? Also - i am using v4l2 - is
> it different from what you have specified below? Can i still do this?
>
> > // initialize
> > ioctl(VIDIOCMCAPTURE, frame0);
> >
> > while {
> > ioctl(VIDIOCMCAPTURE, frame1);
> > ioctl(VIDIOCMSYNC, frame0);
> > ioctl(VIDIOCMCAPTURE, frame1);
> > ioctl(VIDIOCMSYNC, frame0);
> > }
I'm using VFL1 presently.
Check out this excellent resource:
http://alpha.dyndns.org/ov511/v4l_api.html
Here's how to set up the buffer:
struct video_mbuf BufferInfo;
struct video_mmap MemoryInfo;
int fd;
fd = open("/dev/video0", O_RDWR);
//
// Set up the window and picture here
//
ioctl(fd, VIDIOCGMBUF, &BufferInfo);
buffer = (unsigned char *)mmap(0, BufferInfo.size, PROT_READ |
PROT_WRITE, MAP_SHARED, fd, 0);
//
// Set the following appropriately:
//
MemoryInfo.format = VIDEO_PALETTE_YUV420P;
MemoryInfo.width = 320;
MemoryInfo.height = 240;
MemoryInfo.frame = 0;
ioctl(fd, VIDIOCMCAPTURE, &MemoryInfo);
while (capturing) {
MemoryInfo.frame = 1;
ioctl(fd, VIDIOCMCAPTURE, &MemoryInfo);
MemoryInfo.frame = 0;
ioctl(fd, VIDIOCSYNC, &MemoryInfo);
memcpy(frame0, buffer + BufferInfo.offsets[0], 3 * 320 * 240 / 2);
//
// Now process frame0. If using threads, make sure to protect the
// pointers as needed with mutexes.
//
MemoryInfo.frame = 1;
ioctl(fd, VIDIOCMCAPTURE, &MemoryInfo);
MemoryInfo.frame = 0;
ioctl(fd, VIDIOCSYNC, &MemoryInfo);
memcpy(frame1, buffer + BufferInfo.offsets[1], 3 * 320 * 240 / 2);
//
// Now process frame1.
//
}
_______________________________________________
Video4linux-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/video4linux-list